mirror of
https://github.com/nikic/PHP-Parser.git
synced 2025-07-09 16:36:31 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
08f97eb4ef | |||
8d18848fb0 | |||
805078e0a9 | |||
52dafafd10 |
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,8 +1,16 @@
|
|||||||
Version 1.2.2-dev
|
Version 1.2.3-dev
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
Nothing yet.
|
Nothing yet.
|
||||||
|
|
||||||
|
Version 1.2.2 (2015-04-03)
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
* The `NameResolver` now resolves parameter type hints when entering the function/method/closure node. As such other
|
||||||
|
visitors running after it will be able to make use of the resolved names at that point already.
|
||||||
|
* The autoloader no longer sets the `unserialize_callback_func` ini option on registration - this is not necessary and
|
||||||
|
may cause issues when running PhpUnit tests with process isolation.
|
||||||
|
|
||||||
Version 1.2.1 (2015-03-24)
|
Version 1.2.1 (2015-03-24)
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ class Autoloader
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ini_set('unserialize_callback_func', 'spl_autoload_call');
|
|
||||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||||
self::$registered = true;
|
self::$registered = true;
|
||||||
self::$runningOnPhp7 = version_compare(PHP_VERSION, '7.0-dev', '>=');
|
self::$runningOnPhp7 = version_compare(PHP_VERSION, '7.0-dev', '>=');
|
||||||
|
@ -15,7 +15,7 @@ class ShellExec extends Expr
|
|||||||
* @param array $parts Encapsed string array
|
* @param array $parts Encapsed string array
|
||||||
* @param array $attributes Additional attributes
|
* @param array $attributes Additional attributes
|
||||||
*/
|
*/
|
||||||
public function __construct($parts, array $attributes = array()) {
|
public function __construct(array $parts, array $attributes = array()) {
|
||||||
parent::__construct(null, $attributes);
|
parent::__construct(null, $attributes);
|
||||||
$this->parts = $parts;
|
$this->parts = $parts;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class Param extends NodeAbstract
|
|||||||
* @param bool $variadic Whether this is a variadic argument
|
* @param bool $variadic Whether this is a variadic argument
|
||||||
* @param array $attributes Additional attributes
|
* @param array $attributes Additional attributes
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) {
|
public function __construct($name, Expr $default = null, $type = null, $byRef = false, $variadic = false, array $attributes = array()) {
|
||||||
parent::__construct(null, $attributes);
|
parent::__construct(null, $attributes);
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->byRef = $byRef;
|
$this->byRef = $byRef;
|
||||||
|
@ -48,15 +48,11 @@ class NameResolver extends NodeVisitorAbstract
|
|||||||
$this->addNamespacedName($node);
|
$this->addNamespacedName($node);
|
||||||
} elseif ($node instanceof Stmt\Function_) {
|
} elseif ($node instanceof Stmt\Function_) {
|
||||||
$this->addNamespacedName($node);
|
$this->addNamespacedName($node);
|
||||||
if ($node->returnType instanceof Name) {
|
$this->resolveSignature($node);
|
||||||
$node->returnType = $this->resolveClassName($node->returnType);
|
|
||||||
}
|
|
||||||
} elseif ($node instanceof Stmt\ClassMethod
|
} elseif ($node instanceof Stmt\ClassMethod
|
||||||
|| $node instanceof Expr\Closure
|
|| $node instanceof Expr\Closure
|
||||||
) {
|
) {
|
||||||
if ($node->returnType instanceof Name) {
|
$this->resolveSignature($node);
|
||||||
$node->returnType = $this->resolveClassName($node->returnType);
|
|
||||||
}
|
|
||||||
} elseif ($node instanceof Stmt\Const_) {
|
} elseif ($node instanceof Stmt\Const_) {
|
||||||
foreach ($node->consts as $const) {
|
foreach ($node->consts as $const) {
|
||||||
$this->addNamespacedName($const);
|
$this->addNamespacedName($const);
|
||||||
@ -83,7 +79,7 @@ class NameResolver extends NodeVisitorAbstract
|
|||||||
$trait = $this->resolveClassName($trait);
|
$trait = $this->resolveClassName($trait);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($node->adaptations as $adaptation) {
|
foreach ($node->adaptations as $adaptation) {
|
||||||
if (null !== $adaptation->trait) {
|
if (null !== $adaptation->trait) {
|
||||||
$adaptation->trait = $this->resolveClassName($adaptation->trait);
|
$adaptation->trait = $this->resolveClassName($adaptation->trait);
|
||||||
}
|
}
|
||||||
@ -95,10 +91,6 @@ class NameResolver extends NodeVisitorAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($node instanceof Node\Param
|
|
||||||
&& $node->type instanceof Name
|
|
||||||
) {
|
|
||||||
$node->type = $this->resolveClassName($node->type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +130,18 @@ class NameResolver extends NodeVisitorAbstract
|
|||||||
$this->aliases[$type][$aliasName] = $use->name;
|
$this->aliases[$type][$aliasName] = $use->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure $node */
|
||||||
|
private function resolveSignature($node) {
|
||||||
|
foreach ($node->params as $param) {
|
||||||
|
if ($param->type instanceof Name) {
|
||||||
|
$param->type = $this->resolveClassName($param->type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($node->returnType instanceof Name) {
|
||||||
|
$node->returnType = $this->resolveClassName($node->returnType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function resolveClassName(Name $name) {
|
protected function resolveClassName(Name $name) {
|
||||||
// don't resolve special class names
|
// don't resolve special class names
|
||||||
if (in_array(strtolower($name->toString()), array('self', 'parent', 'static'))) {
|
if (in_array(strtolower($name->toString()), array('self', 'parent', 'static'))) {
|
||||||
|
Reference in New Issue
Block a user