mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-27 04:14:44 +01:00
Instantiate a Node_Name for 'static', too. Fix some doc comments.
This commit is contained in:
parent
299893066d
commit
05c514f9c5
@ -564,7 +564,7 @@ function_call:
|
||||
;
|
||||
|
||||
class_name:
|
||||
T_STATIC { $$ = 'static'; }
|
||||
T_STATIC { $$ = Name['static', Name::NORMAL]; }
|
||||
| name { $$ = $1; }
|
||||
;
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @property string|PHPParser_Expr_Name $class Class name
|
||||
* @property string $name Constant name
|
||||
* @property PHPParser_Node_Name|PHPParser_Node_Expr $class Class name
|
||||
* @property string $name Constant name
|
||||
*/
|
||||
class PHPParser_Node_Expr_ClassConstFetch extends PHPParser_Node_Expr
|
||||
{
|
||||
/**
|
||||
* Constructs a class const fetch node.
|
||||
*
|
||||
* @param string|PHPParser_Expr_Name $class Class name
|
||||
* @param string $name Constant name
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
* @param PHPParser_Node_Name|PHPParser_Node_Expr $class Class name
|
||||
* @param string $name Constant name
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
*/
|
||||
public function __construct($class, $name, $line = -1, $docComment = null) {
|
||||
parent::__construct(
|
||||
|
@ -1,18 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @property string|PHPParser_Node_Name $class Class name
|
||||
* @property PHPParser_Node_Expr_FuncCallArg[] $args Arguments
|
||||
* @property PHPParser_Node_Name|PHPParser_Node_Expr $class Class name
|
||||
* @property PHPParser_Node_Expr_FuncCallArg[] $args Arguments
|
||||
*/
|
||||
class PHPParser_Node_Expr_New extends PHPParser_Node_Expr
|
||||
{
|
||||
/**
|
||||
* Constructs a function call node.
|
||||
*
|
||||
* @param string|PHPParser_Node_Name $class Class name
|
||||
* @param PHPParser_Node_Expr_FuncCallArg[] $args Arguments
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
* @param PHPParser_Node_Name|PHPParser_Node_Expr $class Class name
|
||||
* @param PHPParser_Node_Expr_FuncCallArg[] $args Arguments
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
*/
|
||||
public function __construct($class, array $args = array(), $line = -1, $docComment = null) {
|
||||
parent::__construct(
|
||||
|
@ -11,7 +11,7 @@ class PHPParser_Node_Expr_StaticCall extends PHPParser_Node_Expr
|
||||
* Constructs a static method call node.
|
||||
*
|
||||
* @param PHPParser_Node_Name|PHPParser_Node_Expr $class Class name
|
||||
* @param string|PHPParser_Node_Name $name Method name
|
||||
* @param string|PHPParser_Node_Expr $name Method name
|
||||
* @param PHPParser_Node_Expr_FuncCallArg[] $args Arguments
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
|
@ -10,7 +10,7 @@ class PHPParser_Node_Expr_StaticPropertyFetch extends PHPParser_Node_Expr
|
||||
* Constructs a static property fetch node.
|
||||
*
|
||||
* @param PHPParser_Node_Name|PHPParser_Node_Expr $class Class name
|
||||
* @param string|PHPParser_Node_Name $name Property name
|
||||
* @param string|PHPParser_Node_Expr $name Property name
|
||||
* @param int $line Line
|
||||
* @param null|string $docComment Nearest doc comment
|
||||
*/
|
||||
|
@ -19,16 +19,16 @@ class PHPParser_Node_Stmt_Class extends PHPParser_Node_Stmt
|
||||
public function __construct(array $subNodes, $line = -1, $docComment = null) {
|
||||
parent::__construct($subNodes, $line, $docComment);
|
||||
|
||||
if ('self' == $this->name || 'parent' == $this->name) {
|
||||
if ('self' == $this->name || 'parent' == $this->name) { // 'static' cannot occur
|
||||
throw new PHPParser_Error(sprintf('Cannot use "%s" as class name as it is reserved', $this->name));
|
||||
}
|
||||
|
||||
if ('self' == $this->extends || 'parent' == $this->extends) {
|
||||
if ('self' == $this->extends || 'parent' == $this->extends || 'static' == $this->extends) {
|
||||
throw new PHPParser_Error(sprintf('Cannot use "%s" as class name as it is reserved', $this->extends));
|
||||
}
|
||||
|
||||
foreach ($this->implements as $interface) {
|
||||
if ('self' == $interface || 'parent' == $interface) {
|
||||
if ('self' == $interface || 'parent' == $interface || 'static' == $interface) {
|
||||
throw new PHPParser_Error(sprintf('Cannot use "%s" as interface name as it is reserved', $interface));
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ class PHPParser_Node_Stmt_Interface extends PHPParser_Node_Stmt
|
||||
public function __construct(array $subNodes, $line = -1, $docComment = null) {
|
||||
parent::__construct($subNodes, $line, $docComment);
|
||||
|
||||
if ('self' == $this->name || 'parent' == $this->name) {
|
||||
if ('self' == $this->name || 'parent' == $this->name) { // 'static' cannot occur
|
||||
throw new PHPParser_Error(sprintf('Cannot use "%s" as class name as it is reserved', $this->name));
|
||||
}
|
||||
|
||||
foreach ($this->extends as $interface) {
|
||||
if ('self' == $interface || 'parent' == $interface) {
|
||||
if ('self' == $interface || 'parent' == $interface || 'static' == $interface) {
|
||||
throw new PHPParser_Error(sprintf('Cannot use "%s" as interface name as it is reserved', $interface));
|
||||
}
|
||||
}
|
||||
|
@ -1967,7 +1967,7 @@ class PHPParser_Parser
|
||||
}
|
||||
|
||||
protected function yyn243($line, $docComment) {
|
||||
$this->yyval = 'static';
|
||||
$this->yyval = new PHPParser_Node_Name('static', PHPParser_Node_Name::NORMAL, $line, $docComment);
|
||||
}
|
||||
|
||||
protected function yyn244($line, $docComment) {
|
||||
|
@ -319,7 +319,7 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pExpr_StaticCall(PHPParser_Node_Expr_StaticCall $node) {
|
||||
return $this->pClassName($node->class) . '::'
|
||||
return $this->p($node->class) . '::'
|
||||
. ($node->name instanceof PHPParser_Node_Expr ? $this->p($node->name) : $node->name)
|
||||
. '(' . $this->pCommaSeparated($node->args) . ')';
|
||||
}
|
||||
@ -381,7 +381,7 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pExpr_ClassConstFetch(PHPParser_Node_Expr_ClassConstFetch $node) {
|
||||
return $this->pClassName($node->class) . '::' . $node->name;
|
||||
return $this->p($node->class) . '::' . $node->name;
|
||||
}
|
||||
|
||||
public function pExpr_PropertyFetch(PHPParser_Node_Expr_PropertyFetch $node) {
|
||||
@ -389,7 +389,7 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pExpr_StaticPropertyFetch(PHPParser_Node_Expr_StaticPropertyFetch $node) {
|
||||
return $this->pClassName($node->class) . '::$' . $this->pObjectProperty($node->name);
|
||||
return $this->p($node->class) . '::$' . $this->pObjectProperty($node->name);
|
||||
}
|
||||
|
||||
public function pExpr_ShellExec(PHPParser_Node_Expr_ShellExec $node) {
|
||||
@ -408,7 +408,7 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
|
||||
}
|
||||
|
||||
public function pExpr_New(PHPParser_Node_Expr_New $node) {
|
||||
return 'new ' . $this->pClassName($node->class) . '(' . $this->pCommaSeparated($node->args) . ')';
|
||||
return 'new ' . $this->p($node->class) . '(' . $this->pCommaSeparated($node->args) . ')';
|
||||
}
|
||||
|
||||
public function pExpr_Clone(PHPParser_Node_Expr_Clone $node) {
|
||||
@ -626,14 +626,6 @@ class PHPParser_PrettyPrinter_Zend extends PHPParser_PrettyPrinterAbstract
|
||||
}
|
||||
}
|
||||
|
||||
public function pClassName($node) {
|
||||
if ($node == 'static') {
|
||||
return 'static';
|
||||
} else {
|
||||
return $this->p($node);
|
||||
}
|
||||
}
|
||||
|
||||
public function pModifiers($modifiers) {
|
||||
return ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC ? 'public ' : '')
|
||||
. ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED ? 'protected ' : '')
|
||||
|
Loading…
Reference in New Issue
Block a user