Library/Backends/ZendEngine2/Backend.php
private function resolveOffsetExprs($offsetExprs, CompilationContext $compilationContext)
    {
        $keys = '';
        $offsetItems = [];
        $numberParams = 0;

        foreach ($offsetExprs as $offsetExpr) {
            if ('a' == $offsetExpr) {
                $keys .= 'a';
                ++$numberParams;
                continue;
            }
            switch ($offsetExpr->getType()) {
                case 'int':
                case 'uint':
                case 'long':
                case 'ulong':
                    $keys .= 'l';
                    $offsetItems[] = $offsetExpr->getCode();
                    ++$numberParams;
                    break;

                case 'string':
                    $keys .= 's';
                    $offsetItems[] = 'SL("'.$offsetExpr->getCode().'")';
                    $numberParams += 2;
                    break;

                case 'variable':
                    $variableIndex = $compilationContext->symbolTable->getVariableForRead(
                        $offsetExpr->getCode(),
                        $compilationContext,
                        null
                    );

                    switch ($variableIndex->getType()) {
                        case 'int':
                        case 'uint':
                        case 'long':
                        case 'ulong':
                            $keys .= 'l';
                            $offsetItems[] = $this->getVariableCode($variableIndex);
                            ++$numberParams;
                            break;
                        case 'string':
                        case 'variable':
                            $keys .= 'z';
                            $offsetItems[] = $this->getVariableCode($variableIndex);
                            ++$numberParams;
                            break;
                        default:
                            throw new CompilerException(
                                sprintf('Variable: %s cannot be used as array index', $variableIndex->getType()),
                                $offsetExpr->getOriginal()
                            );
                    }
                    break;

                default:
                    throw new CompilerException(
                        sprintf('Value: %s cannot be used as array index', $offsetExpr->getType()),
                        $offsetExpr->getOriginal()
                    );
            }
        }

        return [$keys, $offsetItems, $numberParams];
    }
private function resolveOffsetExprs($offsetExprs, CompilationContext $compilationContext)
    {
        $keys = '';
        $offsetItems = [];
        $numberParams = 0;

        foreach ($offsetExprs as $offsetExpr) {
            if ('a' == $offsetExpr) {
                $keys .= 'a';
                ++$numberParams;
                continue;
            }
            switch ($offsetExpr->getType()) {
                case 'int':
                case 'uint':
                case 'long':
                case 'ulong':
                    $keys .= 'l';
                    $offsetItems[] = $offsetExpr->getCode();
                    ++$numberParams;
                    break;

                case 'string':
                    $keys .= 's';
                    $offsetItems[] = 'SL("'.$offsetExpr->getCode().'")';
                    $numberParams += 2;
                    break;

                case 'variable':
                    $variableIndex = $compilationContext->symbolTable->getVariableForRead(
                        $offsetExpr->getCode(),
                        $compilationContext,
                        null
                    );

                    switch ($variableIndex->getType()) {
                        case 'int':
                        case 'uint':
                        case 'long':
                        case 'ulong':
                            $keys .= 'l';
                            $offsetItems[] = $this->getVariableCode($variableIndex);
                            ++$numberParams;
                            break;
                        case 'string':
                        case 'variable':
                            $keys .= 'z';
                            $offsetItems[] = $this->getVariableCode($variableIndex);
                            ++$numberParams;
                            break;
                        default:
                            throw new CompilerException(
                                sprintf('Variable: %s cannot be used as array index', $variableIndex->getType()),
                                $offsetExpr->getOriginal()
                            );
                    }
                    break;

                default:
                    throw new CompilerException(
                        sprintf('Value: %s cannot be used as array index', $offsetExpr->getType()),
                        $offsetExpr->getOriginal()
                    );
            }
        }

        return [$keys, $offsetItems, $numberParams];
    }
private function resolveOffsetExprs ( $ offsetExprs , CompilationContext $ compilationContext ) { $ keys = '' ; $ offsetItems = [ ] ; $ numberParams = 0 ; foreach ( $ offsetExprs as $ offsetExpr ) { if ( 'a' == $ offsetExpr ) { $ keys .= 'a' ; ++ $ numberParams ; continue ; } switch ( $ offsetExpr -> getType ( ) ) { case 'int' : case 'uint' : case 'long' : case 'ulong' : $ keys .= 'l' ; $ offsetItems [ ] = $ offsetExpr -> getCode ( ) ; ++ $ numberParams ; break ; case 'string' : $ keys .= 's' ; $ offsetItems [ ] = 'SL("' . $ offsetExpr -> getCode ( ) . '")' ; $ numberParams += 2 ; break ; case 'variable' : $ variableIndex = $ compilationContext -> symbolTable -> getVariableForRead ( $ offsetExpr -> getCode ( ) , $ compilationContext , null ) ; switch ( $ variableIndex -> getType ( ) ) { case 'int' : case 'uint' : case 'long' : case 'ulong' : $ keys .= 'l' ; $ offsetItems [ ] = $ this -> getVariableCode ( $ variableIndex ) ; ++ $ numberParams ; break ; case 'string' : case 'variable' : $ keys .= 'z' ; $ offsetItems [ ] = $ this -> getVariableCode ( $ variableIndex ) ; ++ $ numberParams ; break ; default : throw new CompilerException ( sprintf ( 'Variable: %s cannot be used as array index' , $ variableIndex -> getType ( ) ) , $ offsetExpr -> getOriginal ( ) ) ; } break ; default : throw new CompilerException ( sprintf ( 'Value: %s cannot be used as array index' , $ offsetExpr -> getType ( ) ) , $ offsetExpr -> getOriginal ( ) ) ; } } return [ $ keys , $ offsetItems , $ numberParams ] ; }
Resolve expressions.

@param CompiledExpression[]|string[] $offsetExprs
@param CompilationContext            $compilationContext

@throws CompilerException

@return array
Resolve expressions .