axy / evil
Necessary evil
Installs: 422
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/axy/evil
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2025-10-08 04:21:46 UTC
README
- The library does not require any dependencies.
- Tested on PHP 5.4+, PHP 7, HHVM (on Linux), PHP 5.5 (on Windows).
- Install:
composer require axy/evil. - License: MIT.
Documentation
Some language features are not recommended for frequent use.
eval(), exit, global variables, direct access to super-global arrays.
But sometimes it is necessary. If you use static code analyzer, it will swear. We'll have to suppress messages.
/** @SuppressWarnings(PHPMD.Superglobals) */ $x = $_POST['x'];
This library encapsulates the "evil" features. You simply call methods and disclaims any sin.
API
Classes are in the namespace axy\evil.
Evil
It contains calls of "evil" functions.
So how exit, echo and etc is keywords methods have other names.
eval - execCode
Evil::execCode('2 + 2'); // 4
exit - stop
Evil::stop(); // exit Evil::stop(5); // exit with code 5
breakpoint()
breakpoint(mixed $message [, bool $line [, bool $file [, int $status]);
Shows debugging information and terminates the current script (with the status from $status).
If $message is not a scalar then used print_r().
If specified $line: shows the line number of the breakpoint.
For $file shows the file name.
Evil::breakpoint('point'); // point Evil::breakpoint('point', true); // 15: point Evil::breakpoint('point', true, true); // /path/to/script.php:15: point
In CLI mode the $message completes new line.
In HTTP mode the $message enclosed in <pre>.
echo - out
Evil::out($message);
Sends a string to the stdout stream.
Superglobals
Static methods of axy\evil\Superglobals:
getSERVER()getGET()getPOST()getREQUEST()getCOOKIE()getFILES()getSESSION()getENV()
Return the corresponding superglobals arrays. The data is returned by reference.
$session = Superglobals::getSESSION(); $session['var'] = 'value'; // no effect $session = &Supeglobals::getSESSION(); $session['var'] = 'value'; // success
Globals
Static methods:
getGLOBALS(): returns$_GLOBALSby referenceget($name [, $default]): returns the value of a global variable (or$defaultif the variable not found)set($name, $value): setremove($name): unset