NodeAbstract implements Node, \JsonSerializable interface Node { public function getType() : string; public function getSubNodeNames() : array; public function getLine() : int; public function getStartLine() : int; public function getEndLine() : int; public function getStartTokenPos() : int; public function getEndTokenPos() : int; public function getStartFilePos() : int; public function getEndFilePos() : int; public function getComments() : array; public function getDocComment(); public function setDocComment(Comment\Doc $docComment); public function setAttribute(string $key, $value); public function hasAttribute(string $key) : bool; public function getAttribute(string $key, $default = null); public function getAttributes() : array; public function setAttributes(array $attributes); }
not return a value and can not occur in an expression. For example a class definition is a statement. It doesn't return a value and you can't write something like func(class A {});.”[1] PhpParser\Node\Stmtsは文のノードです。つまり値を返さず式の中に含めら れない言語構造です。例えばクラスの定義は文です。それは値を返さず func(class A {});のように書くことができません。 29 1. https://github.com/nikic/PHP-Parser/blob/4.x/doc/2_Usage_of_basic_components.markdown#node-tree-structure
a value and thus can occur in other expressions. Examples of expressions are $var (PhpParser\Node\Expr\Variable) and func() (PhpParser\Node\Expr\FuncCall)."[1] PhpParser\Node\Exprsは式のノードです。つまり値を返すため式の中に含 められる言語構造です。例えば$varやfunc()は式です。 32 1. https://github.com/nikic/PHP-Parser/blob/4.x/doc/2_Usage_of_basic_components.markdown#node-tree-structure
0 (PhpParser\Node\Scalar\LNumber) or magic constants like __FILE__ (PhpParser\Node\Scalar\MagicConst\File). All PhpParser\Node\Scalars extend PhpParser\Node\Expr, as scalars are expressions, too."[1] PhpParser\Node\Scalarsはスカラ値を表すノードです。例えば’string’, 0や __FILE__のようなマジック定数です。全てのスカラ値は式でもあるため PhpParser\Node\Exprを拡張します。 35 1. https://github.com/nikic/PHP-Parser/blob/4.x/doc/2_Usage_of_basic_components.markdown#node-tree-structure
groups, for example names (PhpParser\Node\Name) and call arguments (PhpParser\Node\Arg)."[1] 以上の3つのどれにも属さないノードがあります。例えばnamesやarguments です。 38 1. https://github.com/nikic/PHP-Parser/blob/4.x/doc/2_Usage_of_basic_components.markdown#node-tree-structure
{} function foo(string $bar) {} foo(...); #[foo] class Bar{} foo(); match ($foo) { 'bar' => 'baz', }; $foo = 'bar'; class Foo { public string $bar; } #[foo(0), foo(1)] class Bar{} 関数の定義等 namespace foo; $foo = 'bar'; new \foo\Bar(); Nullable型等 class Foo {} function foo(?string $bar) {} function foo(Bar|Baz $qux) {} new namespace\Bar();
to return by reference * * @return bool */ public function returnsByRef() : bool; /** * List of parameters * * @return Param[] */ public function getParams() : array; /** * Get the declared return type or null * * @return null|Identifier|Name|ComplexType */ public function getReturnType(); /** * The function body * * @return Stmt[]|null */ public function getStmts(); /** * Get PHP attribute groups. * * @return AttributeGroup[] */ public function getAttrGroups() : array; }
Whether function returns by reference */ public $byRef; /** @var Node\Identifier Name */ public $name; /** @var Node\Param[] Parameters */ public $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ public $returnType; /** @var Node\Stmt[] Statements */ public $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; } ケーススタディ(関数) 76
Whether function returns by reference */ public $byRef; /** @var Node\Identifier Name */ public $name; /** @var Node\Param[] Parameters */ public $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ public $returnType; /** @var Node\Stmt[] Statements */ public $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; } ケーススタディ(関数) 77
Whether function returns by reference */ public $byRef; /** @var Node\Identifier Name */ public $name; /** @var Node\Param[] Parameters */ public $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ public $returnType; /** @var Node\Stmt[] Statements */ public $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; } ケーススタディ(関数) 78 function &f($param) {} function f($param) {}
Whether function returns by reference */ public $byRef; /** @var Node\Identifier Name */ public $name; /** @var Node\Param[] Parameters */ public $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ public $returnType; /** @var Node\Stmt[] Statements */ public $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; } ケーススタディ(関数) 79 function f($param) {}
Whether function returns by reference */ public $byRef; /** @var Node\Identifier Name */ public $name; /** @var Node\Param[] Parameters */ public $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ public $returnType; /** @var Node\Stmt[] Statements */ public $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; } ケーススタディ(関数) 80 function f($param) {}
Whether function returns by reference */ public $byRef; /** @var Node\Identifier Name */ public $name; /** @var Node\Param[] Parameters */ public $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ public $returnType; /** @var Node\Stmt[] Statements */ public $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; } ケーススタディ(関数) 81 function f(): bool {} function f(): SomeType {} function f(): bool|int {}
Whether function returns by reference */ public $byRef; /** @var Node\Identifier Name */ public $name; /** @var Node\Param[] Parameters */ public $params; /** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */ public $returnType; /** @var Node\Stmt[] Statements */ public $stmts; /** @var Node\AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'byRef', 'name', 'params', 'returnType', 'stmts']; } ケーススタディ(関数) 83 #[Attribute] function f() {}
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 85
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 86
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 87 function f(bool $param){} function f(SomeType $param) {} function f(bool|int $param) {}
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 88 function f(&$param) {} function f($param) {}
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 89 function f(...$param) {}
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 90 function f($param) {} function f(param) {}
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 91 function f($param = “di molto”) {}
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 92 ???
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 93 コンストラクタの@paramによると Optional visibility flags
*/ public $type; /** @var bool Whether parameter is passed by reference */ public $byRef; /** @var bool Whether this is a variadic argument */ public $variadic; /** @var Expr\Variable|Expr\Error Parameter variable */ public $var; /** @var null|Expr Default value */ public $default; /** @var int */ public $flags; /** @var AttributeGroup[] PHP attribute groups */ public $attrGroups; (略) public function getSubNodeNames() : array { return ['attrGroups', 'flags', 'type', 'byRef', 'variadic', 'var', 'default']; } ケーススタディ(Param) 94 function f(#[Attribute]$param) {}