Aggiornato Composer

This commit is contained in:
Paolo A
2024-05-17 12:24:19 +00:00
parent 4ac62108b5
commit ec201d75b2
2238 changed files with 38684 additions and 59785 deletions

View File

@@ -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;
@@ -20,7 +20,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
*
* @return int Start line (or -1 if not available)
*/
public function getLine() : int {
public function getLine(): int {
return $this->attributes['startLine'] ?? -1;
}
@@ -31,7 +31,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
*
* @return int Start line (or -1 if not available)
*/
public function getStartLine() : int {
public function getStartLine(): int {
return $this->attributes['startLine'] ?? -1;
}
@@ -42,7 +42,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
*
* @return int End line (or -1 if not available)
*/
public function getEndLine() : int {
public function getEndLine(): int {
return $this->attributes['endLine'] ?? -1;
}
@@ -55,7 +55,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 +68,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 +79,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 +90,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 +101,7 @@ abstract class NodeAbstract implements Node, \JsonSerializable
*
* @return Comment[]
*/
public function getComments() : array {
public function getComments(): array {
return $this->attributes['comments'] ?? [];
}
@@ -110,7 +110,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 +129,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 +145,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 +161,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);
}
}