token_get_all

Supported Versions: PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8
Split given source into PHP tokens
<?php token_get_all(string $code, int $flags = 0): array
<?php     protected static function hasEvenNumberOfParentheses(string $expression)

    {

        $tokens = token_get_all('<?php '.$expression);



        if (Arr::last($tokens) !== ')') {

            return false;
<?php     protected function getOpenAndClosingPhpTokens($contents)

    {

        return collect(token_get_all($contents))

            ->pluck(0)

            ->filter(function ($token) {

                return in_array($token, [T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, T_CLOSE_TAG]);
<?php         foreach (token_get_all($value) as $token) {

            $result .= is_array($token) ? $this->parseToken($token) : $token;

        }
<?php     protected function hasEvenNumberOfParentheses(string $expression)

    {

        $tokens = token_get_all('<?php '.$expression);



        if (Arr::last($tokens) !== ')') {

            return false;
<?php     protected function escapeSingleQuotesOutsideOfPhpBlocks(string $value)

    {

        return collect(token_get_all($value))->map(function ($token) {

            if (! is_array($token)) {

                return $token;

            }
<?php         $originalContents = file_get_contents($parameters['viewFile']);

        $newContents = str_replace('$'.$parameters['variableName'], '$'.$parameters['variableName']." ?? ''", $originalContents);



        $originalTokens = token_get_all(Blade::compileString($originalContents));

        $newTokens = token_get_all(Blade::compileString($newContents));



        $expectedTokens = $this->generateExpectedTokens($originalTokens, $parameters['variableName']);
<?php         $newContents = str_replace('$'.$parameters['variableName'], '$'.$parameters['variableName']." ?? ''", $originalContents);



        $originalTokens = token_get_all(Blade::compileString($originalContents));

        $newTokens = token_get_all(Blade::compileString($newContents));



        $expectedTokens = $this->generateExpectedTokens($originalTokens, $parameters['variableName']);
<?php         }



        $output = '';

        foreach (token_get_all($source) as $token) {

            if (is_string($token)) {

                $output .= $token;

            } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {