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;
132 switch ( $this->startToken[0] ) {
136 $this->startToken =
null;
140 if ( !is_array( $token ) || $token[0] !== T_WHITESPACE ) {
141 $this->startToken =
null;
145 if ( $token ===
';' || $token ===
'{' ) {
148 $this->tokens[] = $token;
153 if ( $this->alias !==
null ) {
172 if ( $token ===
'(' ) {
174 $this->alias = [
'target' =>
false,
'name' => false ];
175 } elseif ( $token ===
',' ) {
177 if ( $this->alias[
'target'] ===
false ) {
178 $this->alias[
'target'] =
true;
180 } elseif ( is_array( $token ) && $token[0] === T_CONSTANT_ENCAPSED_STRING ) {
181 if ( $this->alias[
'target'] ===
true ) {
184 $this->alias[
'name'] = substr( $token[1], 1, -1 );
186 } elseif ( $token ===
')' ) {
188 $this->classes[] = $this->alias[
'name'];
190 $this->startToken =
null;
191 } elseif ( !is_array( $token ) || (
192 $token[0] !== T_STRING &&
193 $token[0] !== T_DOUBLE_COLON &&
194 $token[0] !== T_CLASS &&
195 $token[0] !== T_WHITESPACE
199 $this->startToken =
null;
207 $this->tokens[] = $token;
208 if ( is_array( $token ) && $token[0] === T_STRING ) {
209 $this->classes[] = $this->
namespace . $this->
implodeTokens();