src/Reflection/ReflectionClass.php
private function parseArrayDefinition($loc): string
    {
        $tokens = $this->getTokenStream();
        $found  = 0;
        $brace  = 0;
        $code   = '';
        do {
            $type = $tokens->type($loc);
            switch ($type) {
                case T_ARRAY:
                    $loc = $tokens->scan($loc, ['(']);
                    $brace++;
                // intentional fallthrough
                case '[':
                    $code .= '[';
                    $found++;
                    break;
                case '(':
                    $brace++;
                    $code .= '(';
                    break;
                case ']':
                    $found--;
                    $code .= ']';
                    break;
                case ')':
                    if (--$brace === 0) {
                        $found--;
                        $code .= ']';
                    } else {
                        $code .= ')';
                    }
                    break;
                default:
                    $code .= $this->arrayWhitespace($loc);
            }
        } while ($found > 0 && ($loc = $tokens->next($loc)));

        return $code;
    }
private function parseArrayDefinition($loc): string
    {
        $tokens = $this->getTokenStream();
        $found  = 0;
        $brace  = 0;
        $code   = '';
        do {
            $type = $tokens->type($loc);
            switch ($type) {
                case T_ARRAY:
                    $loc = $tokens->scan($loc, ['(']);
                    $brace++;
                // intentional fallthrough
                case '[':
                    $code .= '[';
                    $found++;
                    break;
                case '(':
                    $brace++;
                    $code .= '(';
                    break;
                case ']':
                    $found--;
                    $code .= ']';
                    break;
                case ')':
                    if (--$brace === 0) {
                        $found--;
                        $code .= ']';
                    } else {
                        $code .= ')';
                    }
                    break;
                default:
                    $code .= $this->arrayWhitespace($loc);
            }
        } while ($found > 0 && ($loc = $tokens->next($loc)));

        return $code;
    }
private function parseArrayDefinition ( $ loc ) : string { $ tokens = $ this -> getTokenStream ( ) ; $ found = 0 ; $ brace = 0 ; $ code = '' ; do { $ type = $ tokens -> type ( $ loc ) ; switch ( $ type ) { case T_ARRAY : $ loc = $ tokens -> scan ( $ loc , [ '(' ] ) ; $ brace ++ ; // intentional fallthrough case '[' : $ code .= '[' ; $ found ++ ; break ; case '(' : $ brace ++ ; $ code .= '(' ; break ; case ']' : $ found -- ; $ code .= ']' ; break ; case ')' : if ( -- $ brace === 0 ) { $ found -- ; $ code .= ']' ; } else { $ code .= ')' ; } break ; default : $ code .= $ this -> arrayWhitespace ( $ loc ) ; } } while ( $ found > 0 && ( $ loc = $ tokens -> next ( $ loc ) ) ) ; return $ code ; }
Parse an array definition. The definition can contain arrays itself. The
whole content of the array definition is stripped from comments and
excessive whitespaces.

@param int $loc location of the token stream where the array starts.
This should point to a T_ARRAY or [ token.

@return string code representation of the parsed array without any comments or excessive whitespace.
Parse an array definition . The definition can contain arrays itself . The whole content of the array definition is stripped from comments and excessive whitespaces .