Skip to content

Commit

Permalink
Remove superfluous phpdoc tags
Browse files Browse the repository at this point in the history
These just specify a type that is already specified as a real PHP
type.
  • Loading branch information
nikic committed Sep 17, 2023
1 parent 1873020 commit ab51e9d
Show file tree
Hide file tree
Showing 40 changed files with 10 additions and 156 deletions.
4 changes: 4 additions & 0 deletions .php-cs-fixer.dist.php
Expand Up @@ -27,6 +27,10 @@
'operators' => ['=' => null],
],
'phpdoc_align' => ['align' => 'left'],
'phpdoc_trim' => true,
'no_empty_phpdoc' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_extra_blank_lines' => true,
])
->setFinder($finder)
;
1 change: 0 additions & 1 deletion lib/PhpParser/Builder/ClassConst.php
Expand Up @@ -13,7 +13,6 @@
use PhpParser\Node\Stmt;

class ClassConst implements PhpParser\Builder {
/** @var int */
protected int $flags = 0;
/** @var array<string, mixed> */
protected array $attributes = [];
Expand Down
5 changes: 0 additions & 5 deletions lib/PhpParser/Builder/Class_.php
Expand Up @@ -10,16 +10,11 @@
use PhpParser\Node\Stmt;

class Class_ extends Declaration {
/** @var string */
protected string $name;

/** @var Name|null */
protected ?Name $extends = null;
/** @var list<Name> */
protected array $implements = [];
/** @var int */
protected int $flags = 0;

/** @var list<Stmt\TraitUse> */
protected array $uses = [];
/** @var list<Stmt\ClassConst> */
Expand Down
2 changes: 0 additions & 2 deletions lib/PhpParser/Builder/Enum_.php
Expand Up @@ -10,9 +10,7 @@
use PhpParser\Node\Stmt;

class Enum_ extends Declaration {
/** @var string */
protected string $name;
/** @var Identifier|null */
protected ?Identifier $scalarType = null;
/** @var list<Name> */
protected array $implements = [];
Expand Down
1 change: 0 additions & 1 deletion lib/PhpParser/Builder/FunctionLike.php
Expand Up @@ -6,7 +6,6 @@
use PhpParser\Node;

abstract class FunctionLike extends Declaration {
/** @var bool */
protected bool $returnByRef = false;
/** @var Node\Param[] */
protected array $params = [];
Expand Down
1 change: 0 additions & 1 deletion lib/PhpParser/Builder/Function_.php
Expand Up @@ -8,7 +8,6 @@
use PhpParser\Node\Stmt;

class Function_ extends FunctionLike {
/** @var string */
protected string $name;
/** @var list<Stmt> */
protected array $stmts = [];
Expand Down
1 change: 0 additions & 1 deletion lib/PhpParser/Builder/Interface_.php
Expand Up @@ -9,7 +9,6 @@
use PhpParser\Node\Stmt;

class Interface_ extends Declaration {
/** @var string */
protected string $name;
/** @var list<Name> */
protected array $extends = [];
Expand Down
3 changes: 1 addition & 2 deletions lib/PhpParser/Builder/Method.php
Expand Up @@ -9,9 +9,8 @@
use PhpParser\Node\Stmt;

class Method extends FunctionLike {
/** @var string */
protected string $name;
/** @var int */

protected int $flags = 0;

/** @var list<Stmt>|null */
Expand Down
1 change: 0 additions & 1 deletion lib/PhpParser/Builder/Namespace_.php
Expand Up @@ -8,7 +8,6 @@
use PhpParser\Node\Stmt;

class Namespace_ extends Declaration {
/** @var Node\Name|null */
private ?Node\Name $name;
/** @var Stmt[] */
private array $stmts = [];
Expand Down
5 changes: 0 additions & 5 deletions lib/PhpParser/Builder/Param.php
Expand Up @@ -8,17 +8,12 @@
use PhpParser\Node;

class Param implements PhpParser\Builder {
/** @var string */
protected string $name;
/** @var Node\Expr|null */
protected ?Node\Expr $default = null;
/** @var Node\Identifier|Node\Name|Node\ComplexType|null */
protected ?Node $type = null;
/** @var bool */
protected bool $byRef = false;
/** @var int */
protected int $flags = 0;
/** @var bool */
protected bool $variadic = false;
/** @var list<Node\AttributeGroup> */
protected array $attributeGroups = [];
Expand Down
5 changes: 2 additions & 3 deletions lib/PhpParser/Builder/Property.php
Expand Up @@ -12,11 +12,10 @@
use PhpParser\Node\ComplexType;

class Property implements PhpParser\Builder {
/** @var string */
protected string $name;
/** @var int */

protected int $flags = 0;
/** @var Node\Expr|null */

protected ?Node\Expr $default = null;
/** @var array<string, mixed> */
protected array $attributes = [];
Expand Down
5 changes: 0 additions & 5 deletions lib/PhpParser/Builder/TraitUseAdaptation.php
Expand Up @@ -13,15 +13,10 @@ class TraitUseAdaptation implements Builder {
private const TYPE_ALIAS = 1;
private const TYPE_PRECEDENCE = 2;

/** @var int Type of building adaptation */
protected int $type;
/** @var Node\Name|null */
protected ?Node\Name $trait;
/** @var Node\Identifier */
protected Node\Identifier $method;
/** @var int|null */
protected ?int $modifier = null;
/** @var Node\Identifier|null */
protected ?Node\Identifier $alias = null;
/** @var Node\Name[] */
protected array $insteadof = [];
Expand Down
1 change: 0 additions & 1 deletion lib/PhpParser/Builder/Trait_.php
Expand Up @@ -8,7 +8,6 @@
use PhpParser\Node\Stmt;

class Trait_ extends Declaration {
/** @var string */
protected string $name;
/** @var list<Stmt\TraitUse> */
protected array $uses = [];
Expand Down
2 changes: 0 additions & 2 deletions lib/PhpParser/Builder/Use_.php
Expand Up @@ -8,11 +8,9 @@
use PhpParser\Node\Stmt;

class Use_ implements Builder {
/** @var Node\Name */
protected Node\Name $name;
/** @var Stmt\Use_::TYPE_* */
protected int $type;
/** @var string|null */
protected ?string $alias = null;

/**
Expand Down
23 changes: 0 additions & 23 deletions lib/PhpParser/BuilderFactory.php
Expand Up @@ -16,8 +16,6 @@ class BuilderFactory {
*
* @param string|Name $name Name of the attribute
* @param array $args Attribute named arguments
*
* @return Node\Attribute
*/
public function attribute($name, array $args = []): Node\Attribute {
return new Node\Attribute(
Expand Down Expand Up @@ -213,8 +211,6 @@ public function enumCase($name): Builder\EnumCase {
* Creates node a for a literal value.
*
* @param Expr|bool|null|int|float|string|array $value $value
*
* @return Expr
*/
public function val($value): Expr {
return BuilderHelpers::normalizeValue($value);
Expand All @@ -224,8 +220,6 @@ public function val($value): Expr {
* Creates variable node.
*
* @param string|Expr $name Name
*
* @return Expr\Variable
*/
public function var($name): Expr\Variable {
if (!\is_string($name) && !$name instanceof Expr) {
Expand Down Expand Up @@ -263,8 +257,6 @@ public function args(array $args): array {
*
* @param string|Name|Expr $name Function name
* @param array $args Function arguments
*
* @return Expr\FuncCall
*/
public function funcCall($name, array $args = []): Expr\FuncCall {
return new Expr\FuncCall(
Expand All @@ -279,8 +271,6 @@ public function funcCall($name, array $args = []): Expr\FuncCall {
* @param Expr $var Variable the method is called on
* @param string|Identifier|Expr $name Method name
* @param array $args Method arguments
*
* @return Expr\MethodCall
*/
public function methodCall(Expr $var, $name, array $args = []): Expr\MethodCall {
return new Expr\MethodCall(
Expand All @@ -296,8 +286,6 @@ public function methodCall(Expr $var, $name, array $args = []): Expr\MethodCall
* @param string|Name|Expr $class Class name
* @param string|Identifier|Expr $name Method name
* @param array $args Method arguments
*
* @return Expr\StaticCall
*/
public function staticCall($class, $name, array $args = []): Expr\StaticCall {
return new Expr\StaticCall(
Expand All @@ -312,8 +300,6 @@ public function staticCall($class, $name, array $args = []): Expr\StaticCall {
*
* @param string|Name|Expr $class Class name
* @param array $args Constructor arguments
*
* @return Expr\New_
*/
public function new($class, array $args = []): Expr\New_ {
return new Expr\New_(
Expand All @@ -326,8 +312,6 @@ public function new($class, array $args = []): Expr\New_ {
* Creates a constant fetch node.
*
* @param string|Name $name Constant name
*
* @return Expr\ConstFetch
*/
public function constFetch($name): Expr\ConstFetch {
return new Expr\ConstFetch(BuilderHelpers::normalizeName($name));
Expand All @@ -338,8 +322,6 @@ public function constFetch($name): Expr\ConstFetch {
*
* @param Expr $var Variable holding object
* @param string|Identifier|Expr $name Property name
*
* @return Expr\PropertyFetch
*/
public function propertyFetch(Expr $var, $name): Expr\PropertyFetch {
return new Expr\PropertyFetch($var, BuilderHelpers::normalizeIdentifierOrExpr($name));
Expand All @@ -350,8 +332,6 @@ public function propertyFetch(Expr $var, $name): Expr\PropertyFetch {
*
* @param string|Name|Expr $class Class name
* @param string|Identifier|Expr $name Constant name
*
* @return Expr\ClassConstFetch
*/
public function classConstFetch($class, $name): Expr\ClassConstFetch {
return new Expr\ClassConstFetch(
Expand All @@ -364,8 +344,6 @@ public function classConstFetch($class, $name): Expr\ClassConstFetch {
* Creates nested Concat nodes from a list of expressions.
*
* @param Expr|string ...$exprs Expressions or literal strings
*
* @return Concat
*/
public function concat(...$exprs): Concat {
$numExprs = count($exprs);
Expand All @@ -382,7 +360,6 @@ public function concat(...$exprs): Concat {

/**
* @param string|Expr $expr
* @return Expr
*/
private function normalizeStringExpr($expr): Expr {
if ($expr instanceof Expr) {
Expand Down
12 changes: 1 addition & 11 deletions lib/PhpParser/Comment.php
Expand Up @@ -3,19 +3,12 @@
namespace PhpParser;

class Comment implements \JsonSerializable {
/** @var string string */
protected string $text;
/** @var int */
protected int $startLine;
/** @var int */
protected int $startFilePos;
/** @var int */
protected int $startTokenPos;
/** @var int */
protected int $endLine;
/** @var int */
protected int $endFilePos;
/** @var int */
protected int $endTokenPos;

/**
Expand Down Expand Up @@ -121,8 +114,6 @@ public function __toString(): string {
* on all subsequent lines.
*
* Additionally, this normalizes CRLF newlines to LF newlines.
*
* @return string
*/
public function getReformattedText(): string {
$text = str_replace("\r\n", "\n", $this->text);
Expand Down Expand Up @@ -196,8 +187,7 @@ private function getShortestWhitespacePrefixLen(string $str): int {
}

/**
* @return array
* @psalm-return array{nodeType:string, text:mixed, line:mixed, filePos:mixed}
* @return array{nodeType:string, text:mixed, line:mixed, filePos:mixed}
*/
public function jsonSerialize(): array {
// Technically not a node, but we make it look like one anyway
Expand Down
5 changes: 0 additions & 5 deletions lib/PhpParser/Error.php
Expand Up @@ -3,7 +3,6 @@
namespace PhpParser;

class Error extends \RuntimeException {
/** @var string */
protected string $rawMessage;
/** @var array<string, mixed> */
protected array $attributes;
Expand Down Expand Up @@ -90,8 +89,6 @@ public function setStartLine(int $line): void {
* Returns whether the error has start and end column information.
*
* For column information enable the startFilePos and endFilePos in the lexer options.
*
* @return bool
*/
public function hasColumnInfo(): bool {
return isset($this->attributes['startFilePos'], $this->attributes['endFilePos']);
Expand All @@ -101,7 +98,6 @@ public function hasColumnInfo(): bool {
* Gets the start column (1-based) into the line where the error started.
*
* @param string $code Source code of the file
* @return int
*/
public function getStartColumn(string $code): int {
if (!$this->hasColumnInfo()) {
Expand All @@ -115,7 +111,6 @@ public function getStartColumn(string $code): int {
* Gets the end column (1-based) into the line where the error ended.
*
* @param string $code Source code of the file
* @return int
*/
public function getEndColumn(string $code): int {
if (!$this->hasColumnInfo()) {
Expand Down
2 changes: 0 additions & 2 deletions lib/PhpParser/ErrorHandler/Collecting.php
Expand Up @@ -29,8 +29,6 @@ public function getErrors(): array {

/**
* Check whether there are any errors.
*
* @return bool
*/
public function hasErrors(): bool {
return !empty($this->errors);
Expand Down
2 changes: 0 additions & 2 deletions lib/PhpParser/Internal/Differ.php
Expand Up @@ -91,8 +91,6 @@ private function calculateTrace(array $old, array $new): array {

/**
* @param array<int, array<int, int>> $trace
* @param int $x
* @param int $y
* @param T[] $old
* @param T[] $new
* @return DiffElem[]
Expand Down
4 changes: 0 additions & 4 deletions lib/PhpParser/Internal/TokenStream.php
Expand Up @@ -30,8 +30,6 @@ public function __construct(array $tokens) {
*
* @param int $startPos Start position
* @param int $endPos End position
*
* @return bool
*/
public function haveParens(int $startPos, int $endPos): bool {
return $this->haveTokenImmediatelyBefore($startPos, '(')
Expand All @@ -43,8 +41,6 @@ public function haveParens(int $startPos, int $endPos): bool {
*
* @param int $startPos Start position
* @param int $endPos End position
*
* @return bool
*/
public function haveBraces(int $startPos, int $endPos): bool {
return ($this->haveTokenImmediatelyBefore($startPos, '{')
Expand Down
3 changes: 1 addition & 2 deletions lib/PhpParser/Lexer/Emulative.php
Expand Up @@ -28,9 +28,8 @@ class Emulative extends Lexer {
/** @var list<TokenEmulator> */
private array $emulators = [];

/** @var PhpVersion */
private PhpVersion $targetPhpVersion;
/** @var PhpVersion */

private PhpVersion $hostPhpVersion;

/**
Expand Down

0 comments on commit ab51e9d

Please sign in to comment.