src/Reflection/ReflectionClass.php
private function parseDefaultValue($loc): ?string
    {
        $tokens  = $this->getTokenStream();
        $default = '';
        $loc     = $tokens->next($loc);

        if ($tokens->value($loc) === '=') {
            $loc  = $tokens->next($loc);
            $type = $tokens->type($loc);

            if (\in_array($type, [T_DNUMBER, T_LNUMBER, T_CONSTANT_ENCAPSED_STRING])) {
                // Easy numbers and strings.
                $default = $tokens->value($loc);
            } elseif (\in_array($type, [T_STRING, T_NS_SEPARATOR])) {
                // Constants, definitions and null
                $default = $this->parseNamespace($loc);
                $loc     = $tokens->next($loc, [T_WHITESPACE, T_COMMENT, T_STRING, T_NS_SEPARATOR]);
                if ($tokens->type($loc) === T_PAAMAYIM_NEKUDOTAYIM) {
                    $loc      = $tokens->next($loc);
                    $default .= '::' . $tokens->value($loc);
                }
            } elseif (\in_array($type, [T_ARRAY, '['])) {
                // Array types, both old array() and shorthand [] notation.
                $default = $this->parseArrayDefinition($loc);
            } elseif ($type === T_START_HEREDOC) {
                // Heredoc and Nowdoc
                $default = $this->parseHereNowDocConcat($loc);
            }
        }

        return $default;
    }
private function parseDefaultValue($loc): ?string
    {
        $tokens  = $this->getTokenStream();
        $default = '';
        $loc     = $tokens->next($loc);

        if ($tokens->value($loc) === '=') {
            $loc  = $tokens->next($loc);
            $type = $tokens->type($loc);

            if (\in_array($type, [T_DNUMBER, T_LNUMBER, T_CONSTANT_ENCAPSED_STRING])) {
                // Easy numbers and strings.
                $default = $tokens->value($loc);
            } elseif (\in_array($type, [T_STRING, T_NS_SEPARATOR])) {
                // Constants, definitions and null
                $default = $this->parseNamespace($loc);
                $loc     = $tokens->next($loc, [T_WHITESPACE, T_COMMENT, T_STRING, T_NS_SEPARATOR]);
                if ($tokens->type($loc) === T_PAAMAYIM_NEKUDOTAYIM) {
                    $loc      = $tokens->next($loc);
                    $default .= '::' . $tokens->value($loc);
                }
            } elseif (\in_array($type, [T_ARRAY, '['])) {
                // Array types, both old array() and shorthand [] notation.
                $default = $this->parseArrayDefinition($loc);
            } elseif ($type === T_START_HEREDOC) {
                // Heredoc and Nowdoc
                $default = $this->parseHereNowDocConcat($loc);
            }
        }

        return $default;
    }
private function parseDefaultValue ( $ loc ) : ? string { $ tokens = $ this -> getTokenStream ( ) ; $ default = '' ; $ loc = $ tokens -> next ( $ loc ) ; if ( $ tokens -> value ( $ loc ) === '=' ) { $ loc = $ tokens -> next ( $ loc ) ; $ type = $ tokens -> type ( $ loc ) ; if ( \ in_array ( $ type , [ T_DNUMBER , T_LNUMBER , T_CONSTANT_ENCAPSED_STRING ] ) ) { // Easy numbers and strings. $ default = $ tokens -> value ( $ loc ) ; } elseif ( \ in_array ( $ type , [ T_STRING , T_NS_SEPARATOR ] ) ) { // Constants, definitions and null $ default = $ this -> parseNamespace ( $ loc ) ; $ loc = $ tokens -> next ( $ loc , [ T_WHITESPACE , T_COMMENT , T_STRING , T_NS_SEPARATOR ] ) ; if ( $ tokens -> type ( $ loc ) === T_PAAMAYIM_NEKUDOTAYIM ) { $ loc = $ tokens -> next ( $ loc ) ; $ default .= '::' . $ tokens -> value ( $ loc ) ; } } elseif ( \ in_array ( $ type , [ T_ARRAY , '[' ] ) ) { // Array types, both old array() and shorthand [] notation. $ default = $ this -> parseArrayDefinition ( $ loc ) ; } elseif ( $ type === T_START_HEREDOC ) { // Heredoc and Nowdoc $ default = $ this -> parseHereNowDocConcat ( $ loc ) ; } } return $ default ; }
Parses the default value assignment for a property and returns the
default value or null if there is no default value assigned.

The returned value includes single or double quotes as used in the code.
This way we can keep those and this also enables us to parse a default
value of null.

@param int $loc location of the property name (T_STRING)

@return string|null Null if there is no default value, string otherwise
Parses the default value assignment for a property and returns the default value or null if there is no default value assigned .