classes/PhpSourceStream.php
public function getNextExpectedTerminated($expectedCodesOrValues, $terminationToken)
    {
        $buffer = null;

        if (!is_array($terminationToken)) {
            $terminationToken = [$terminationToken];
        }

        while (($nextToken = $this->getNext()) !== null) {
            $code = $this->getCurrentCode();
            $text = $this->getCurrentText();

            if (in_array($code, $expectedCodesOrValues) || in_array($text, $expectedCodesOrValues)) {
                $buffer .= $text;
                continue;
            }

            if (in_array($code, $terminationToken)) {
                return $buffer;
            }

            if (in_array($text, $terminationToken)) {
                return $buffer;
            }

            // The token should be either expected or termination. 
            // If something else is found, return null.
            return null;
        }

        return $buffer;
    }
public function getNextExpectedTerminated($expectedCodesOrValues, $terminationToken)
    {
        $buffer = null;

        if (!is_array($terminationToken)) {
            $terminationToken = [$terminationToken];
        }

        while (($nextToken = $this->getNext()) !== null) {
            $code = $this->getCurrentCode();
            $text = $this->getCurrentText();

            if (in_array($code, $expectedCodesOrValues) || in_array($text, $expectedCodesOrValues)) {
                $buffer .= $text;
                continue;
            }

            if (in_array($code, $terminationToken)) {
                return $buffer;
            }

            if (in_array($text, $terminationToken)) {
                return $buffer;
            }

            // The token should be either expected or termination. 
            // If something else is found, return null.
            return null;
        }

        return $buffer;
    }
public function getNextExpectedTerminated ( $ expectedCodesOrValues , $ terminationToken ) { $ buffer = null ; if ( ! is_array ( $ terminationToken ) ) { $ terminationToken = [ $ terminationToken ] ; } while ( ( $ nextToken = $ this -> getNext ( ) ) !== null ) { $ code = $ this -> getCurrentCode ( ) ; $ text = $ this -> getCurrentText ( ) ; if ( in_array ( $ code , $ expectedCodesOrValues ) || in_array ( $ text , $ expectedCodesOrValues ) ) { $ buffer .= $ text ; continue ; } if ( in_array ( $ code , $ terminationToken ) ) { return $ buffer ; } if ( in_array ( $ text , $ terminationToken ) ) { return $ buffer ; } // The token should be either expected or termination.  // If something else is found, return null. return null ; } return $ buffer ; }
Reads expected tokens, until the termination token is found.
If any unexpected token is found before the termination token, returns null.
If the method succeeds, the head is positioned on the termination token.
@param array $expectedCodesOrValues Specifies the expected codes or token values.
@param integer|string|array $terminationToken Specifies the termination token text or code.
The termination tokens could be specified as array.
@return string|null Returns the tokens text or null
Reads expected tokens until the termination token is found . If any unexpected token is found before the termination token returns null . If the method succeeds the head is positioned on the termination token .