Php Backslasher Save

[Git hook] Tool to add all PHP internal functions and constants to its namespace by adding backslash to them.

Project README

Build Status Scrutinizer Code Quality SensioLabsInsight Latest Stable Version Total Downloads License Donate

PHP BackSlasher

Tool to add all PHP internal functions and constants to its namespace by adding backslash to them.

Function resolution without the backslash forces the PHP internals to verify for each function call if function or constant belongs to current namespace or the global namespace. With the backslash PHP does not check the current namespace and therefore execution is faster when using OP Cache.

Idea from Nikita Popov talk:

Installation

Use Composer to install the package:

$ composer require --dev nilportugues/php_backslasher

Usage

$ php bin/php_backslasher fix <path/to/directory>

Output

Works for functions in conditional statements, negative conditionals, placed in an array as key or value and any other normal use. Also adds a backslash to defined constants and true, false and null values.

Internal functions and constants

echo strlen('Hello World');
var_dump(null);
var_dump(false);
echo DIRECTORY_SEPARATOR;
return true;

// becomes:
echo \strlen('Hello World');
\var_dump(\null);
\var_dump(\false);
echo \DIRECTORY_SEPARATOR;
return \true;

Contribute

Contributions to the package are always welcome!

Support

Get in touch with me using one of the following means:

Authors

License

The code base is licensed under the MIT license.

Open Source Agenda is not affiliated with "Php Backslasher" Project. README Source: nilportugues/php-backslasher
Stars
87
Open Issues
0
Last Commit
4 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating