Library/FunctionCall.php
protected function optimize($funcName, array $expression, Call $call, CompilationContext $compilationContext)
    {
        $optimizer = false;

        /*
         * Check if the optimizer is already cached
         */
        if (!isset(self::$optimizers[$funcName])) {
            $camelizeFunctionName = camelize($funcName);

            /*
             * Check every optimizer directory for an optimizer
             */
            foreach (self::$optimizerDirectories as $directory) {
                $path = $directory.\DIRECTORY_SEPARATOR.$camelizeFunctionName.'Optimizer.php';
                $className = 'Zephir\Optimizers\FunctionCall\\'.$camelizeFunctionName.'Optimizer';

                if (file_exists($path)) {
                    if (!class_exists($className, false)) {
                        require_once $path;
                    }

                    if (!class_exists($className, false)) {
                        throw new Exception("Class {$className} cannot be loaded");
                    }

                    $optimizer = new $className();

                    if (!($optimizer instanceof OptimizerAbstract)) {
                        throw new Exception("Class {$className} must be instance of OptimizerAbstract");
                    }

                    break;
                }
            }

            self::$optimizers[$funcName] = $optimizer;
        } else {
            $optimizer = self::$optimizers[$funcName];
        }

        if ($optimizer) {
            return $optimizer->optimize($expression, $call, $compilationContext);
        }

        return false;
    }
protected function optimize($funcName, array $expression, Call $call, CompilationContext $compilationContext)
    {
        $optimizer = false;

        /*
         * Check if the optimizer is already cached
         */
        if (!isset(self::$optimizers[$funcName])) {
            $camelizeFunctionName = camelize($funcName);

            /*
             * Check every optimizer directory for an optimizer
             */
            foreach (self::$optimizerDirectories as $directory) {
                $path = $directory.\DIRECTORY_SEPARATOR.$camelizeFunctionName.'Optimizer.php';
                $className = 'Zephir\Optimizers\FunctionCall\\'.$camelizeFunctionName.'Optimizer';

                if (file_exists($path)) {
                    if (!class_exists($className, false)) {
                        require_once $path;
                    }

                    if (!class_exists($className, false)) {
                        throw new Exception("Class {$className} cannot be loaded");
                    }

                    $optimizer = new $className();

                    if (!($optimizer instanceof OptimizerAbstract)) {
                        throw new Exception("Class {$className} must be instance of OptimizerAbstract");
                    }

                    break;
                }
            }

            self::$optimizers[$funcName] = $optimizer;
        } else {
            $optimizer = self::$optimizers[$funcName];
        }

        if ($optimizer) {
            return $optimizer->optimize($expression, $call, $compilationContext);
        }

        return false;
    }
protected function optimize ( $ funcName , array $ expression , Call $ call , CompilationContext $ compilationContext ) { $ optimizer = false ; /*
         * Check if the optimizer is already cached
         */ if ( ! isset ( self :: $ optimizers [ $ funcName ] ) ) { $ camelizeFunctionName = camelize ( $ funcName ) ; /*
             * Check every optimizer directory for an optimizer
             */ foreach ( self :: $ optimizerDirectories as $ directory ) { $ path = $ directory . \ DIRECTORY_SEPARATOR . $ camelizeFunctionName . 'Optimizer.php' ; $ className = 'Zephir\Optimizers\FunctionCall\\' . $ camelizeFunctionName . 'Optimizer' ; if ( file_exists ( $ path ) ) { if ( ! class_exists ( $ className , false ) ) { require_once $ path ; } if ( ! class_exists ( $ className , false ) ) { throw new Exception ( "Class {$className} cannot be loaded" ) ; } $ optimizer = new $ className ( ) ; if ( ! ( $ optimizer instanceof OptimizerAbstract ) ) { throw new Exception ( "Class {$className} must be instance of OptimizerAbstract" ) ; } break ; } } self :: $ optimizers [ $ funcName ] = $ optimizer ; } else { $ optimizer = self :: $ optimizers [ $ funcName ] ; } if ( $ optimizer ) { return $ optimizer -> optimize ( $ expression , $ call , $ compilationContext ) ; } return false ; }
Tries to find specific an specialized optimizer for function calls.

@param string             $funcName
@param array              $expression
@param Call               $call
@param CompilationContext $compilationContext

@throws Exception

@return bool|mixed
Tries to find specific an specialized optimizer for function calls .