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 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;

            }