56 $this->
namespace = '';
58 $this->startToken =
null;
71 '#^\t*(?:namespace |(final )?(abstract )?(class|interface|trait) |class_alias\()[^;{]+[;{]\s*\}?#m',
77 $match = trim( $match );
78 if ( str_ends_with( $match,
'{' ) ) {
85 $code =
'<?php ' . implode(
"\n",
$lines ) .
"\n";
87 foreach ( token_get_all( $code ) as $token ) {
88 if ( $this->startToken ===
null ) {
104 if ( is_string( $token ) ) {
109 switch ( $token[0] ) {
116 $this->startToken = $token;
119 if ( $token[1] ===
'class_alias' ) {
120 $this->startToken = $token;
133 switch ( $this->startToken[0] ) {
138 $this->startToken =
null;
142 if ( !is_array( $token ) || $token[0] !== T_WHITESPACE ) {
143 $this->startToken =
null;
147 if ( $token ===
';' || $token ===
'{' ) {
150 $this->tokens[] = $token;
155 if ( $this->alias !==
null ) {
174 if ( $token ===
'(' ) {
176 $this->alias = [
'target' =>
false,
'name' => false ];
177 } elseif ( $token ===
',' ) {
179 if ( $this->alias[
'target'] ===
false ) {
180 $this->alias[
'target'] =
true;
182 } elseif ( is_array( $token ) && $token[0] === T_CONSTANT_ENCAPSED_STRING ) {
183 if ( $this->alias[
'target'] ===
true ) {
186 $this->alias[
'name'] = self::stripQuotes( $token[1] );
188 } elseif ( $token ===
')' ) {
190 $this->classes[] = $this->alias[
'name'];
192 $this->startToken =
null;
193 } elseif ( !is_array( $token ) || (
194 $token[0] !== T_STRING &&
195 $token[0] !== T_DOUBLE_COLON &&
196 $token[0] !== T_CLASS &&
197 $token[0] !== T_WHITESPACE
201 $this->startToken =
null;
209 $this->tokens[] = $token;
210 if ( is_array( $token ) && $token[0] === T_STRING ) {
211 $this->classes[] = $this->
namespace . $this->
implodeTokens();
226 return str_replace(
'\\\\',
'\\', substr( $str, 1, -1 ) );