I've stuck with an optimizer

It's me again. I've created my really imperfect optimizer for PHP pregreplace function (learning, to see if i am able to) and reach a point a cannot move forward. A class below does some job (optimizers directory, config file, etc.) but the output of it for invoking from Zephir code: pregreplace("/(mymailaddress(@)?example.com)/sU", "$1", "[email protected]"); is: "mypregreplace(&4,&5, &_6)" it is a string, not process value (at the same time corresponging PHP lines of the same application work correctly (and uchanged string is returned [email protected]) i suppose it has something to do with: http://zephir-lang.com/optimizers.html - "This code must be placed in the ext/ directory where you find appropiate" but if this the case i don't know what exactly i am to do (i tried some things) becaouse i am not experienced enough.

Could anyone help me to go ahead?


namespace Zephir\Optimizers\FunctionCall;

use Zephir\Call;
use Zephir\CompilationContext;
use Zephir\CompilerException;
use Zephir\CompiledExpression;
use Zephir\Optimizers\OptimizerAbstract;

 * PregMatchOptimizer
 * Optimizes calls to 'preg_match' using internal function
class PregReplaceOptimizer extends OptimizerAbstract

    public function optimize(array $expression, Call $call, CompilationContext $context)
        if (!isset($expression['parameters'])) {
            return false;

        if (count($expression['parameters']) != 3) {
            return false;

        $resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression);

        return new CompiledExpression('string', 'my_preg_replace(' . $resolvedParams[0] . ','. $resolvedParams[1] .', '. $resolvedParams[2] .')', $expression);



I admit it's too much for me (i won't be learning C nowadays). I simply initially didn't grasp the idea behind the optimizers. I thought optimizers are for PHP/pure Zephir world programmers too and it is something not that difficult to use.

By the way, i noticed that preg_match is already optimized in Zephir sources (it seems to me so because it's present there) and works somewhat slower even if runned entirely on Zephir userland.

Just trying to get some perspective.