2017 © Pedro Peláez
 

library optimize-native-functions-fixer

Prefixes native PHP functions which can be replaced with opcodes by the OPcache.

image

leofeyer/optimize-native-functions-fixer

Prefixes native PHP functions which can be replaced with opcodes by the OPcache.

  • Tuesday, July 24, 2018
  • by leofeyer
  • Repository
  • 2 Watchers
  • 4 Stars
  • 4,377 Installations
  • PHP
  • 8 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 59 % Grown

The README.md

Deprecated

This package is no longer needed as the feature is now available in [PHP-CS-Fixer][3]. Use the native_function_invocation fixer with the @compiler_optimized option., (*1)


Optimize Native Functions Fixer

About

This custom PHP-CS-Fixer fixer prefixes native PHP functions which can be replaced with opcodes by the OPcache., (*2)

class MyClass
{
    public function isArray($var): bool
    {
        return \is_array($var);
    }
}

See this pull request to learn how prefixing an optimizable PHP function made the Symfony DI container 783ms faster. And see [this pull request][3] if you want to learn more about how the optimization works., (*3)

Installation

Add the package via Composer:, (*4)

php composer.phar require leofeyer/optimize-native-functions-fixer --dev

Configuration

Modify your .php_cs or .php_cs.dist file as follows:, (*5)

return PhpCsFixer\Config::create()
    ->setRules([
        // …
        'LeoFeyer/optimize_native_functions' => true,
    ])
    ->registerCustomFixers([
        new LeoFeyer\PhpCsFixer\OptimizeNativeFunctionsFixer()
    ])
    ->setRiskyAllowed(true)

Other options

If you do not like prefixing native functions, you can also import them with a use statement (PHP 7 only)., (*6)

use function is_array;

class MyClass
{
    public function isArray($var): bool
    {
        return is_array($var);
    }
}

The Versions

24/07 2018

dev-master

9999999-dev

Prefixes native PHP functions which can be replaced with opcodes by the OPcache.

  Sources   Download

MIT

The Requires

 

The Development Requires

02/03 2018

1.1.1

1.1.1.0

Prefixes native PHP functions which can be replaced with opcodes by the OPcache.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/03 2018

1.1.0

1.1.0.0

Prefixes native PHP functions which can be replaced with opcodes by the OPcache.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/03 2018

1.0.1

1.0.1.0

Prefixes native PHP functions which can be replaced with opcodes by the OPcache.

  Sources   Download

MIT

The Requires

 

The Development Requires

07/02 2018

1.0.0

1.0.0.0

Prefixes native PHP functions which can be replaced with opcodes by the OPcache.

  Sources   Download

MIT

The Requires

 

The Development Requires