mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
N°7176 - Update nikic/php-parser to 5.0.0 (#735)
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
{
|
||||
protected $attributes;
|
||||
abstract class NodeAbstract implements Node, \JsonSerializable {
|
||||
/** @var array<string, mixed> Attributes */
|
||||
protected array $attributes;
|
||||
|
||||
/**
|
||||
* Creates a Node.
|
||||
*
|
||||
* @param array $attributes Array of attributes
|
||||
* @param array<string, mixed> $attributes Array of attributes
|
||||
*/
|
||||
public function __construct(array $attributes = []) {
|
||||
$this->attributes = $attributes;
|
||||
@@ -19,8 +19,9 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
* Gets line the node started in (alias of getStartLine).
|
||||
*
|
||||
* @return int Start line (or -1 if not available)
|
||||
* @phpstan-return -1|positive-int
|
||||
*/
|
||||
public function getLine() : int {
|
||||
public function getLine(): int {
|
||||
return $this->attributes['startLine'] ?? -1;
|
||||
}
|
||||
|
||||
@@ -30,8 +31,9 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
* Requires the 'startLine' attribute to be enabled in the lexer (enabled by default).
|
||||
*
|
||||
* @return int Start line (or -1 if not available)
|
||||
* @phpstan-return -1|positive-int
|
||||
*/
|
||||
public function getStartLine() : int {
|
||||
public function getStartLine(): int {
|
||||
return $this->attributes['startLine'] ?? -1;
|
||||
}
|
||||
|
||||
@@ -41,8 +43,9 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
* Requires the 'endLine' attribute to be enabled in the lexer (enabled by default).
|
||||
*
|
||||
* @return int End line (or -1 if not available)
|
||||
* @phpstan-return -1|positive-int
|
||||
*/
|
||||
public function getEndLine() : int {
|
||||
public function getEndLine(): int {
|
||||
return $this->attributes['endLine'] ?? -1;
|
||||
}
|
||||
|
||||
@@ -55,7 +58,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
*
|
||||
* @return int Token start position (or -1 if not available)
|
||||
*/
|
||||
public function getStartTokenPos() : int {
|
||||
public function getStartTokenPos(): int {
|
||||
return $this->attributes['startTokenPos'] ?? -1;
|
||||
}
|
||||
|
||||
@@ -68,7 +71,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
*
|
||||
* @return int Token end position (or -1 if not available)
|
||||
*/
|
||||
public function getEndTokenPos() : int {
|
||||
public function getEndTokenPos(): int {
|
||||
return $this->attributes['endTokenPos'] ?? -1;
|
||||
}
|
||||
|
||||
@@ -79,7 +82,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
*
|
||||
* @return int File start position (or -1 if not available)
|
||||
*/
|
||||
public function getStartFilePos() : int {
|
||||
public function getStartFilePos(): int {
|
||||
return $this->attributes['startFilePos'] ?? -1;
|
||||
}
|
||||
|
||||
@@ -90,7 +93,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
*
|
||||
* @return int File end position (or -1 if not available)
|
||||
*/
|
||||
public function getEndFilePos() : int {
|
||||
public function getEndFilePos(): int {
|
||||
return $this->attributes['endFilePos'] ?? -1;
|
||||
}
|
||||
|
||||
@@ -101,7 +104,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
*
|
||||
* @return Comment[]
|
||||
*/
|
||||
public function getComments() : array {
|
||||
public function getComments(): array {
|
||||
return $this->attributes['comments'] ?? [];
|
||||
}
|
||||
|
||||
@@ -110,7 +113,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
*
|
||||
* @return null|Comment\Doc Doc comment object or null
|
||||
*/
|
||||
public function getDocComment() {
|
||||
public function getDocComment(): ?Comment\Doc {
|
||||
$comments = $this->getComments();
|
||||
for ($i = count($comments) - 1; $i >= 0; $i--) {
|
||||
$comment = $comments[$i];
|
||||
@@ -129,7 +132,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
*
|
||||
* @param Comment\Doc $docComment Doc comment to set
|
||||
*/
|
||||
public function setDocComment(Comment\Doc $docComment) {
|
||||
public function setDocComment(Comment\Doc $docComment): void {
|
||||
$comments = $this->getComments();
|
||||
for ($i = count($comments) - 1; $i >= 0; $i--) {
|
||||
if ($comments[$i] instanceof Comment\Doc) {
|
||||
@@ -145,11 +148,11 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
$this->setAttribute('comments', $comments);
|
||||
}
|
||||
|
||||
public function setAttribute(string $key, $value) {
|
||||
public function setAttribute(string $key, $value): void {
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
|
||||
public function hasAttribute(string $key) : bool {
|
||||
public function hasAttribute(string $key): bool {
|
||||
return array_key_exists($key, $this->attributes);
|
||||
}
|
||||
|
||||
@@ -161,18 +164,18 @@ abstract class NodeAbstract implements Node, \JsonSerializable
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function getAttributes() : array {
|
||||
public function getAttributes(): array {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
public function setAttributes(array $attributes) {
|
||||
public function setAttributes(array $attributes): void {
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function jsonSerialize() : array {
|
||||
public function jsonSerialize(): array {
|
||||
return ['nodeType' => $this->getType()] + get_object_vars($this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user