mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Improve doc comments
This commit is contained in:
parent
9f5ec5a69a
commit
329e90c239
@ -166,7 +166,7 @@ class Lexer
|
||||
$nextFilePos = strpos($this->code, $tokenValue, $filePos);
|
||||
$this->handleInvalidCharacterRange(
|
||||
$filePos, $nextFilePos, $line, $errorHandler);
|
||||
$filePos = $nextFilePos;
|
||||
$filePos = (int)$nextFilePos;
|
||||
}
|
||||
|
||||
$filePos += $tokenLen;
|
||||
|
@ -15,8 +15,8 @@ class Name extends NodeAbstract
|
||||
/**
|
||||
* Constructs a name node.
|
||||
*
|
||||
* @param string|array|self $name Name as string, part array or Name instance (copy ctor)
|
||||
* @param array $attributes Additional attributes
|
||||
* @param string|string[]|self $name Name as string, part array or Name instance (copy ctor)
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct($name, array $attributes = array()) {
|
||||
parent::__construct($attributes);
|
||||
@ -153,9 +153,9 @@ class Name extends NodeAbstract
|
||||
* Name::concat($namespace, $shortName)
|
||||
* where $namespace is a Name node or null will work as expected.
|
||||
*
|
||||
* @param string|array|self|null $name1 The first name
|
||||
* @param string|array|self|null $name2 The second name
|
||||
* @param array $attributes Attributes to assign to concatenated name
|
||||
* @param string|string[]|self|null $name1 The first name
|
||||
* @param string|string[]|self|null $name2 The second name
|
||||
* @param array $attributes Attributes to assign to concatenated name
|
||||
*
|
||||
* @return static|null Concatenated name
|
||||
*/
|
||||
@ -177,9 +177,9 @@ class Name extends NodeAbstract
|
||||
* Prepares a (string, array or Name node) name for use in name changing methods by converting
|
||||
* it to an array.
|
||||
*
|
||||
* @param string|array|self $name Name to prepare
|
||||
* @param string|string[]|self $name Name to prepare
|
||||
*
|
||||
* @return array Prepared name
|
||||
* @return string[] Prepared name
|
||||
*/
|
||||
private static function prepareName($name) {
|
||||
if (\is_string($name)) {
|
||||
|
@ -13,8 +13,8 @@ class Encapsed extends Scalar
|
||||
/**
|
||||
* Constructs an encapsed string node.
|
||||
*
|
||||
* @param array $parts Encaps list
|
||||
* @param array $attributes Additional attributes
|
||||
* @param Expr[] $parts Encaps list
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $parts, array $attributes = array()) {
|
||||
parent::__construct($attributes);
|
||||
|
@ -19,7 +19,7 @@ class TryCatch extends Node\Stmt
|
||||
* @param Node\Stmt[] $stmts Statements
|
||||
* @param Catch_[] $catches Catches
|
||||
* @param null|Finally_ $finally Optionaly finally node
|
||||
* @param array|null $attributes Additional attributes
|
||||
* @param array $attributes Additional attributes
|
||||
*/
|
||||
public function __construct(array $stmts, array $catches, Finally_ $finally = null, array $attributes = array()) {
|
||||
parent::__construct($attributes);
|
||||
|
@ -32,6 +32,8 @@ class FindingVisitor extends NodeVisitorAbstract {
|
||||
|
||||
public function beforeTraverse(array $nodes) {
|
||||
$this->foundNodes = [];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function enterNode(Node $node) {
|
||||
@ -39,5 +41,7 @@ class FindingVisitor extends NodeVisitorAbstract {
|
||||
if ($filterCallback($node)) {
|
||||
$this->foundNodes[] = $node;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -33,6 +33,8 @@ class FirstFindingVisitor extends NodeVisitorAbstract {
|
||||
|
||||
public function beforeTraverse(array $nodes) {
|
||||
$this->foundNode = null;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function enterNode(Node $node) {
|
||||
|
@ -17,7 +17,7 @@ class NameResolver extends NodeVisitorAbstract
|
||||
protected $namespace;
|
||||
|
||||
/** @var array Map of format [aliasType => [aliasName => originalName]] */
|
||||
protected $aliases;
|
||||
protected $aliases = [];
|
||||
|
||||
/** @var ErrorHandler Error handler */
|
||||
protected $errorHandler;
|
||||
|
@ -581,6 +581,20 @@ abstract class ParserAbstract implements Parser
|
||||
return $style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix up parsing of static property calls in PHP 5.
|
||||
*
|
||||
* In PHP 5 A::$b[c][d] and A::$b[c][d]() have very different interpretation. The former is
|
||||
* interpreted as (A::$b)[c][d], while the latter is the same as A::{$b[c][d]}(). We parse the
|
||||
* latter as the former initially and this method fixes the AST into the correct form when we
|
||||
* encounter the "()".
|
||||
*
|
||||
* @param Node\Expr\StaticPropertyFetch|Node\Expr\ArrayDimFetch $prop
|
||||
* @param Node\Arg[] $args
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return Expr\StaticCall
|
||||
*/
|
||||
protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) {
|
||||
if ($prop instanceof Node\Expr\StaticPropertyFetch) {
|
||||
// Preserve attributes if possible
|
||||
@ -631,9 +645,6 @@ abstract class ParserAbstract implements Parser
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function handleBuiltinTypes(Name $name) {
|
||||
$scalarTypes = [
|
||||
'bool' => true,
|
||||
|
Loading…
Reference in New Issue
Block a user