|
@@ -107,6 +107,8 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
$fn = PHP_MINOR_VERSION === 4;
|
|
|
}
|
|
|
|
|
|
+ $class_keywords = ['self', 'static', 'parent'];
|
|
|
+
|
|
|
$ns = $this->getNamespaceName();
|
|
|
$nsf = $ns == '' ? '' : ($ns[0] == '\\' ? $ns : '\\' . $ns);
|
|
|
|
|
@@ -207,11 +209,6 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
$state = 'closure';
|
|
|
}
|
|
|
break;
|
|
|
- case '=':
|
|
|
- $code .= $token;
|
|
|
- $lastState = 'closure_args';
|
|
|
- $state = 'ignore_next';
|
|
|
- break;
|
|
|
case ':':
|
|
|
$code .= ':';
|
|
|
$state = 'return';
|
|
@@ -331,13 +328,13 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
$code .= $_namespace;
|
|
|
break;
|
|
|
case T_CLASS_C:
|
|
|
- $code .= $_class;
|
|
|
+ $code .= $inside_anonymous ? $token[1] : $_class;
|
|
|
break;
|
|
|
case T_FUNC_C:
|
|
|
- $code .= $_function;
|
|
|
+ $code .= $inside_anonymous ? $token[1] : $_function;
|
|
|
break;
|
|
|
case T_METHOD_C:
|
|
|
- $code .= $_method;
|
|
|
+ $code .= $inside_anonymous ? $token[1] : $_method;
|
|
|
break;
|
|
|
case T_COMMENT:
|
|
|
if (substr($token[1], 0, 8) === '#trackme') {
|
|
@@ -359,7 +356,9 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
$code .= $token[1];
|
|
|
break;
|
|
|
case T_STATIC:
|
|
|
- $isUsingScope = true;
|
|
|
+ if (!$inside_anonymous) {
|
|
|
+ $isUsingScope = true;
|
|
|
+ }
|
|
|
$code .= $token[1];
|
|
|
break;
|
|
|
case T_NS_SEPARATOR:
|
|
@@ -384,6 +383,7 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
$lastState = 'closure';
|
|
|
break;
|
|
|
case T_INSTANCEOF:
|
|
|
+ case T_INSTEADOF:
|
|
|
$code .= $token[1];
|
|
|
$context = 'instanceof';
|
|
|
$state = 'id_start';
|
|
@@ -501,7 +501,7 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
$open++;
|
|
|
}
|
|
|
if($context === 'new' || false !== strpos($id_name, '\\')){
|
|
|
- if($id_start !== '\\'){
|
|
|
+ if($id_start !== '\\' && !in_array($id_start_ci, $class_keywords)){
|
|
|
if ($classes === null) {
|
|
|
$classes = $this->getClasses();
|
|
|
}
|
|
@@ -529,7 +529,9 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
case T_DOUBLE_COLON:
|
|
|
if($id_start !== '\\') {
|
|
|
if($id_start_ci === 'self' || $id_start_ci === 'static' || $id_start_ci === 'parent'){
|
|
|
- $isUsingScope = true;
|
|
|
+ if (!$inside_anonymous) {
|
|
|
+ $isUsingScope = true;
|
|
|
+ }
|
|
|
} elseif (!($php7 && in_array($id_start_ci, $php7_types))){
|
|
|
if ($classes === null) {
|
|
|
$classes = $this->getClasses();
|
|
@@ -546,15 +548,23 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
$state = $token[0] === T_DOUBLE_COLON ? 'ignore_next' : $lastState;
|
|
|
break;
|
|
|
default:
|
|
|
- if($id_start !== '\\'){
|
|
|
- if($context === 'use' ||
|
|
|
+ if($id_start !== '\\' && !defined($id_start)){
|
|
|
+ if($constants === null){
|
|
|
+ $constants = $this->getConstants();
|
|
|
+ }
|
|
|
+ if(isset($constants[$id_start])){
|
|
|
+ $id_start = $constants[$id_start];
|
|
|
+ } elseif($context === 'use' ||
|
|
|
$context === 'instanceof' ||
|
|
|
$context === 'args' ||
|
|
|
$context === 'return_type' ||
|
|
|
- $context === 'extends'
|
|
|
+ $context === 'extends' ||
|
|
|
+ $context === 'root'
|
|
|
){
|
|
|
if($id_start_ci === 'self' || $id_start_ci === 'static' || $id_start_ci === 'parent'){
|
|
|
- $isUsingScope = true;
|
|
|
+ if (!$inside_anonymous) {
|
|
|
+ $isUsingScope = true;
|
|
|
+ }
|
|
|
} elseif (!($php7 && in_array($id_start_ci, $php7_types))){
|
|
|
if($classes === null){
|
|
|
$classes = $this->getClasses();
|
|
@@ -566,13 +576,6 @@ class ReflectionClosure extends ReflectionFunction
|
|
|
$id_start = $nsf . '\\' . $id_start;
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- if($constants === null){
|
|
|
- $constants = $this->getConstants();
|
|
|
- }
|
|
|
- if(isset($constants[$id_start])){
|
|
|
- $id_start = $constants[$id_start];
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
$code .= $id_start . $id_name;
|