Library/Optimizers/FunctionCall/PregMatchOptimizer.php
private function processOptionals(array &$expression, Call $call, CompilationContext $context)
    {
        $flags = null;
        $offset = null;

        $offsetParamOffset = 4;
        if (isset($expression['parameters'][4]) && 'int' === $expression['parameters'][4]['parameter']['type']) {
            $offset = $expression['parameters'][4]['parameter']['value'].' ';
            unset($expression['parameters'][4]);
        }

        if (isset($expression['parameters'][3]) && 'int' === $expression['parameters'][3]['parameter']['type']) {
            $flags = $expression['parameters'][3]['parameter']['value'].' ';
            $offsetParamOffset = 3;
            unset($expression['parameters'][3]);
        }

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

            if (null === $offset && isset($resolvedParams[$offsetParamOffset])) {
                $context->headersManager->add('kernel/operators');
                $offset = 'zephir_get_intval('.$resolvedParams[$offsetParamOffset].') ';
            }

            if (null === $flags && isset($resolvedParams[3])) {
                $context->headersManager->add('kernel/operators');
                $flags = 'zephir_get_intval('.$resolvedParams[3].') ';
            }
        } catch (Exception $e) {
            throw new CompilerException($e->getMessage(), $expression, $e->getCode(), $e);
        }

        if (null === $flags) {
            $flags = '0 ';
        }

        if (null === $offset) {
            $offset = '0 ';
        }

        return [$flags, $offset];
    }
private function processOptionals(array &$expression, Call $call, CompilationContext $context)
    {
        $flags = null;
        $offset = null;

        $offsetParamOffset = 4;
        if (isset($expression['parameters'][4]) && 'int' === $expression['parameters'][4]['parameter']['type']) {
            $offset = $expression['parameters'][4]['parameter']['value'].' ';
            unset($expression['parameters'][4]);
        }

        if (isset($expression['parameters'][3]) && 'int' === $expression['parameters'][3]['parameter']['type']) {
            $flags = $expression['parameters'][3]['parameter']['value'].' ';
            $offsetParamOffset = 3;
            unset($expression['parameters'][3]);
        }

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

            if (null === $offset && isset($resolvedParams[$offsetParamOffset])) {
                $context->headersManager->add('kernel/operators');
                $offset = 'zephir_get_intval('.$resolvedParams[$offsetParamOffset].') ';
            }

            if (null === $flags && isset($resolvedParams[3])) {
                $context->headersManager->add('kernel/operators');
                $flags = 'zephir_get_intval('.$resolvedParams[3].') ';
            }
        } catch (Exception $e) {
            throw new CompilerException($e->getMessage(), $expression, $e->getCode(), $e);
        }

        if (null === $flags) {
            $flags = '0 ';
        }

        if (null === $offset) {
            $offset = '0 ';
        }

        return [$flags, $offset];
    }
private function processOptionals ( array & $ expression , Call $ call , CompilationContext $ context ) { $ flags = null ; $ offset = null ; $ offsetParamOffset = 4 ; if ( isset ( $ expression [ 'parameters' ] [ 4 ] ) && 'int' === $ expression [ 'parameters' ] [ 4 ] [ 'parameter' ] [ 'type' ] ) { $ offset = $ expression [ 'parameters' ] [ 4 ] [ 'parameter' ] [ 'value' ] . ' ' ; unset ( $ expression [ 'parameters' ] [ 4 ] ) ; } if ( isset ( $ expression [ 'parameters' ] [ 3 ] ) && 'int' === $ expression [ 'parameters' ] [ 3 ] [ 'parameter' ] [ 'type' ] ) { $ flags = $ expression [ 'parameters' ] [ 3 ] [ 'parameter' ] [ 'value' ] . ' ' ; $ offsetParamOffset = 3 ; unset ( $ expression [ 'parameters' ] [ 3 ] ) ; } try { $ resolvedParams = $ call -> getReadOnlyResolvedParams ( $ expression [ 'parameters' ] , $ context , $ expression ) ; if ( null === $ offset && isset ( $ resolvedParams [ $ offsetParamOffset ] ) ) { $ context -> headersManager -> add ( 'kernel/operators' ) ; $ offset = 'zephir_get_intval(' . $ resolvedParams [ $ offsetParamOffset ] . ') ' ; } if ( null === $ flags && isset ( $ resolvedParams [ 3 ] ) ) { $ context -> headersManager -> add ( 'kernel/operators' ) ; $ flags = 'zephir_get_intval(' . $ resolvedParams [ 3 ] . ') ' ; } } catch ( Exception $ e ) { throw new CompilerException ( $ e -> getMessage ( ) , $ expression , $ e -> getCode ( ) , $ e ) ; } if ( null === $ flags ) { $ flags = '0 ' ; } if ( null === $ offset ) { $ offset = '0 ' ; } return [ $ flags , $ offset ] ; }
Process optional parameters.

preg_match(pattern, subject, matches, flags, offset)

@param array              $expression
@param Call               $call
@param CompilationContext $context

@throws CompilerException

@return array
Process optional parameters .