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 ( substr( $match, -1 ) ===
'{' ) {
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] ) {
137 $this->startToken =
null;
141 if ( !is_array( $token ) || $token[0] !== T_WHITESPACE ) {
142 $this->startToken =
null;
146 if ( $token ===
';' || $token ===
'{' ) {
149 $this->tokens[] = $token;
154 if ( $this->alias !==
null ) {
173 if ( $token ===
'(' ) {
175 $this->alias = [
'target' =>
false,
'name' => false ];
176 } elseif ( $token ===
',' ) {
178 if ( $this->alias[
'target'] ===
false ) {
179 $this->alias[
'target'] =
true;
181 } elseif ( is_array( $token ) && $token[0] === T_CONSTANT_ENCAPSED_STRING ) {
182 if ( $this->alias[
'target'] ===
true ) {
187 } elseif ( $token ===
')' ) {
189 $this->classes[] = $this->alias[
'name'];
191 $this->startToken =
null;
192 } elseif ( !is_array( $token ) || (
193 $token[0] !== T_STRING &&
194 $token[0] !== T_DOUBLE_COLON &&
195 $token[0] !== T_CLASS &&
196 $token[0] !== T_WHITESPACE
200 $this->startToken =
null;
208 $this->tokens[] = $token;
209 if ( is_array( $token ) && $token[0] === T_STRING ) {
210 $this->classes[] = $this->
namespace . $this->
implodeTokens();