Skip to content

Commit

Permalink
Don't align phpdoc tags
Browse files Browse the repository at this point in the history
I did this to start with, but then alignment kept being broken
during refactorings, and at some point I switched to not aligning,
and now we have a big mess.

Add a php-cs-fixer rule to consistently not align phpdoc tags.
  • Loading branch information
nikic committed Sep 17, 2023
1 parent 3c52ea9 commit 2d3dd4e
Show file tree
Hide file tree
Showing 98 changed files with 227 additions and 226 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Expand Up @@ -26,6 +26,7 @@
// Work around https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7303.
'operators' => ['=' => null],
],
'phpdoc_align' => ['align' => 'left'],
])
->setFinder($finder)
;
4 changes: 2 additions & 2 deletions lib/PhpParser/Builder/ClassConst.php
Expand Up @@ -28,7 +28,7 @@ class ClassConst implements PhpParser\Builder {
/**
* Creates a class constant builder
*
* @param string|Identifier $name Name
* @param string|Identifier $name Name
* @param Node\Expr|bool|null|int|float|string|array $value Value
*/
public function __construct($name, $value) {
Expand All @@ -38,7 +38,7 @@ public function __construct($name, $value) {
/**
* Add another constant to const group
*
* @param string|Identifier $name Name
* @param string|Identifier $name Name
* @param Node\Expr|bool|null|int|float|string|array $value Value
*
* @return $this The builder instance (for fluid interface)
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Builder/EnumCase.php
Expand Up @@ -24,7 +24,7 @@ class EnumCase implements PhpParser\Builder {
/**
* Creates an enum case builder.
*
* @param string|Identifier $name Name
* @param string|Identifier $name Name
*/
public function __construct($name) {
$this->name = $name;
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Builder/TraitUseAdaptation.php
Expand Up @@ -29,7 +29,7 @@ class TraitUseAdaptation implements Builder {
/**
* Creates a trait use adaptation builder.
*
* @param Node\Name|string|null $trait Name of adapted trait
* @param Node\Name|string|null $trait Name of adapted trait
* @param Node\Identifier|string $method Name of adapted method
*/
public function __construct($trait, $method) {
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Builder/Use_.php
Expand Up @@ -18,7 +18,7 @@ class Use_ implements Builder {
/**
* Creates a name use (alias) builder.
*
* @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias
* @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias
* @param Stmt\Use_::TYPE_* $type One of the Stmt\Use_::TYPE_* constants
*/
public function __construct($name, int $type) {
Expand Down
26 changes: 13 additions & 13 deletions lib/PhpParser/BuilderFactory.php
Expand Up @@ -15,7 +15,7 @@ class BuilderFactory {
* Creates an attribute node.
*
* @param string|Name $name Name of the attribute
* @param array $args Attribute named arguments
* @param array $args Attribute named arguments
*
* @return Node\Attribute
*/
Expand Down Expand Up @@ -95,7 +95,7 @@ public function useTrait(...$traits): Builder\TraitUse {
/**
* Creates a trait use adaptation builder.
*
* @param Node\Name|string|null $trait Trait name
* @param Node\Name|string|null $trait Trait name
* @param Node\Identifier|string $method Method name
*
* @return Builder\TraitUseAdaptation The created trait use adaptation builder
Expand Down Expand Up @@ -189,7 +189,7 @@ public function useConst($name): Builder\Use_ {
/**
* Creates a class constant builder.
*
* @param string|Identifier $name Name
* @param string|Identifier $name Name
* @param Node\Expr|bool|null|int|float|string|array $value Value
*
* @return Builder\ClassConst The created use const builder
Expand All @@ -201,7 +201,7 @@ public function classConst($name, $value): Builder\ClassConst {
/**
* Creates an enum case builder.
*
* @param string|Identifier $name Name
* @param string|Identifier $name Name
*
* @return Builder\EnumCase The created use const builder
*/
Expand Down Expand Up @@ -262,7 +262,7 @@ public function args(array $args): array {
* Creates a function call node.
*
* @param string|Name|Expr $name Function name
* @param array $args Function arguments
* @param array $args Function arguments
*
* @return Expr\FuncCall
*/
Expand All @@ -276,9 +276,9 @@ public function funcCall($name, array $args = []): Expr\FuncCall {
/**
* Creates a method call node.
*
* @param Expr $var Variable the method is called on
* @param Expr $var Variable the method is called on
* @param string|Identifier|Expr $name Method name
* @param array $args Method arguments
* @param array $args Method arguments
*
* @return Expr\MethodCall
*/
Expand All @@ -293,9 +293,9 @@ public function methodCall(Expr $var, $name, array $args = []): Expr\MethodCall
/**
* Creates a static method call node.
*
* @param string|Name|Expr $class Class name
* @param string|Identifier|Expr $name Method name
* @param array $args Method arguments
* @param string|Name|Expr $class Class name
* @param string|Identifier|Expr $name Method name
* @param array $args Method arguments
*
* @return Expr\StaticCall
*/
Expand All @@ -311,7 +311,7 @@ public function staticCall($class, $name, array $args = []): Expr\StaticCall {
* Creates an object creation node.
*
* @param string|Name|Expr $class Class name
* @param array $args Constructor arguments
* @param array $args Constructor arguments
*
* @return Expr\New_
*/
Expand All @@ -336,7 +336,7 @@ public function constFetch($name): Expr\ConstFetch {
/**
* Creates a property fetch node.
*
* @param Expr $var Variable holding object
* @param Expr $var Variable holding object
* @param string|Identifier|Expr $name Property name
*
* @return Expr\PropertyFetch
Expand All @@ -349,7 +349,7 @@ public function propertyFetch(Expr $var, $name): Expr\PropertyFetch {
* Creates a class constant fetch node.
*
* @param string|Name|Expr $class Class name
* @param string|Identifier|Expr $name Constant name
* @param string|Identifier|Expr $name Constant name
*
* @return Expr\ClassConstFetch
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/BuilderHelpers.php
Expand Up @@ -313,7 +313,7 @@ public static function normalizeAttribute($attribute): Node\AttributeGroup {
* Adds a modifier and returns new modifier bitmask.
*
* @param int $modifiers Existing modifiers
* @param int $modifier Modifier to set
* @param int $modifier Modifier to set
*
* @return int New modifiers
*/
Expand Down
10 changes: 5 additions & 5 deletions lib/PhpParser/Comment.php
Expand Up @@ -21,10 +21,10 @@ class Comment implements \JsonSerializable {
/**
* Constructs a comment node.
*
* @param string $text Comment text (including comment delimiters like /*)
* @param int $startLine Line number the comment started on
* @param int $startFilePos File offset the comment started on
* @param int $startTokenPos Token offset the comment started on
* @param string $text Comment text (including comment delimiters like /*)
* @param int $startLine Line number the comment started on
* @param int $startFilePos File offset the comment started on
* @param int $startTokenPos Token offset the comment started on
*/
public function __construct(
string $text,
Expand Down Expand Up @@ -229,7 +229,7 @@ private function getShortestWhitespacePrefixLen(string $str): int {
}

/**
* @return array
* @return array
* @psalm-return array{nodeType:string, text:mixed, line:mixed, filePos:mixed}
*/
public function jsonSerialize(): array {
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Error.php
Expand Up @@ -144,7 +144,7 @@ public function getMessageWithColumnInfo(string $code): string {
* Converts a file offset into a column.
*
* @param string $code Source code that $pos indexes into
* @param int $pos 0-based position in $code
* @param int $pos 0-based position in $code
*
* @return int 1-based column (relative to start of line)
*/
Expand Down
12 changes: 6 additions & 6 deletions lib/PhpParser/Internal/TokenStream.php
Expand Up @@ -29,7 +29,7 @@ public function __construct(array $tokens) {
* Whether the given position is immediately surrounded by parenthesis.
*
* @param int $startPos Start position
* @param int $endPos End position
* @param int $endPos End position
*
* @return bool
*/
Expand All @@ -42,7 +42,7 @@ public function haveParens(int $startPos, int $endPos): bool {
* Whether the given position is immediately surrounded by braces.
*
* @param int $startPos Start position
* @param int $endPos End position
* @param int $endPos End position
*
* @return bool
*/
Expand All @@ -57,7 +57,7 @@ public function haveBraces(int $startPos, int $endPos): bool {
*
* During this check whitespace and comments are skipped.
*
* @param int $pos Position before which the token should occur
* @param int $pos Position before which the token should occur
* @param int|string $expectedTokenType Token to check for
*
* @return bool Whether the expected token was found
Expand All @@ -82,7 +82,7 @@ public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType): bool {
*
* During this check whitespace and comments are skipped.
*
* @param int $pos Position after which the token should occur
* @param int $pos Position after which the token should occur
* @param int|string $expectedTokenType Token to check for
*
* @return bool Whether the expected token was found
Expand Down Expand Up @@ -224,8 +224,8 @@ public function getIndentationBefore(int $pos): int {
/**
* Get the code corresponding to a token offset range, optionally adjusted for indentation.
*
* @param int $from Token start position (inclusive)
* @param int $to Token end position (exclusive)
* @param int $from Token start position (inclusive)
* @param int $to Token end position (exclusive)
* @param int $indent By how much the code should be indented (can be negative as well)
*
* @return string Code corresponding to token range, adjusted for indentation
Expand Down
16 changes: 8 additions & 8 deletions lib/PhpParser/NameContext.php
Expand Up @@ -47,9 +47,9 @@ public function startNamespace(?Name $namespace = null): void {
/**
* Add an alias / import.
*
* @param Name $name Original name
* @param string $aliasName Aliased name
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
* @param Name $name Original name
* @param string $aliasName Aliased name
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
* @param array<string, mixed> $errorAttrs Attributes to use to report an error
*/
public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []): void {
Expand Down Expand Up @@ -93,8 +93,8 @@ public function getNamespace(): ?Name {
/**
* Get resolved name.
*
* @param Name $name Name to resolve
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT}
* @param Name $name Name to resolve
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_{FUNCTION|CONSTANT}
*
* @return null|Name Resolved name, or null if static resolution is not possible
*/
Expand Down Expand Up @@ -148,8 +148,8 @@ public function getResolvedClassName(Name $name): Name {
/**
* Get possible ways of writing a fully qualified name (e.g., by making use of aliases).
*
* @param string $name Fully-qualified name (without leading namespace separator)
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
* @param string $name Fully-qualified name (without leading namespace separator)
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
*
* @return Name[] Possible representations of the name
*/
Expand Down Expand Up @@ -204,7 +204,7 @@ public function getPossibleNames(string $name, int $type): array {
/**
* Get shortest representation of this fully-qualified name.
*
* @param string $name Fully-qualified name (without leading namespace separator)
* @param string $name Fully-qualified name (without leading namespace separator)
* @param Stmt\Use_::TYPE_* $type One of Stmt\Use_::TYPE_*
*
* @return Name Shortest representation
Expand Down
4 changes: 2 additions & 2 deletions lib/PhpParser/Node.php
Expand Up @@ -111,7 +111,7 @@ public function setDocComment(Comment\Doc $docComment): void;
* Sets an attribute on a node.
*
* @param string $key
* @param mixed $value
* @param mixed $value
*/
public function setAttribute(string $key, $value): void;

Expand All @@ -128,7 +128,7 @@ public function hasAttribute(string $key): bool;
* Returns the value of an attribute.
*
* @param string $key
* @param mixed $default
* @param mixed $default
*
* @return mixed
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/PhpParser/Node/Arg.php
Expand Up @@ -17,9 +17,9 @@ class Arg extends NodeAbstract {
/**
* Constructs a function call argument node.
*
* @param Expr $value Value to pass
* @param bool $byRef Whether to pass by ref
* @param bool $unpack Whether to unpack the argument
* @param Expr $value Value to pass
* @param bool $byRef Whether to pass by ref
* @param bool $unpack Whether to unpack the argument
* @param array<string, mixed> $attributes Additional attributes
* @param Identifier|null $name Parameter name (for named parameters)
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/PhpParser/Node/ArrayItem.php
Expand Up @@ -17,9 +17,9 @@ class ArrayItem extends NodeAbstract {
/**
* Constructs an array item node.
*
* @param Expr $value Value
* @param null|Expr $key Key
* @param bool $byRef Whether to assign by reference
* @param Expr $value Value
* @param null|Expr $key Key
* @param bool $byRef Whether to assign by reference
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $value, ?Expr $key = null, bool $byRef = false, array $attributes = [], bool $unpack = false) {
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Node/Attribute.php
Expand Up @@ -13,7 +13,7 @@ class Attribute extends NodeAbstract {
public array $args;

/**
* @param Node\Name $name Attribute name
* @param Node\Name $name Attribute name
* @param list<Arg> $args Attribute arguments
* @param array<string, mixed> $attributes Additional node attributes
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/PhpParser/Node/ClosureUse.php
Expand Up @@ -13,8 +13,8 @@ class ClosureUse extends NodeAbstract {
/**
* Constructs a closure use node.
*
* @param Expr\Variable $var Variable to use
* @param bool $byRef Whether to use by reference
* @param Expr\Variable $var Variable to use
* @param bool $byRef Whether to use by reference
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr\Variable $var, bool $byRef = false, array $attributes = []) {
Expand Down
4 changes: 2 additions & 2 deletions lib/PhpParser/Node/Const_.php
Expand Up @@ -16,8 +16,8 @@ class Const_ extends NodeAbstract {
/**
* Constructs a const node for use in class const and const statements.
*
* @param string|Identifier $name Name
* @param Expr $value Value
* @param string|Identifier $name Name
* @param Expr $value Value
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct($name, Expr $value, array $attributes = []) {
Expand Down
4 changes: 2 additions & 2 deletions lib/PhpParser/Node/DeclareItem.php
Expand Up @@ -14,8 +14,8 @@ class DeclareItem extends NodeAbstract {
/**
* Constructs a declare key=>value pair node.
*
* @param string|Node\Identifier $key Key
* @param Node\Expr $value Value
* @param string|Node\Identifier $key Key
* @param Node\Expr $value Value
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct($key, Node\Expr $value, array $attributes = []) {
Expand Down
4 changes: 2 additions & 2 deletions lib/PhpParser/Node/Expr/ArrayDimFetch.php
Expand Up @@ -13,8 +13,8 @@ class ArrayDimFetch extends Expr {
/**
* Constructs an array index fetch node.
*
* @param Expr $var Variable
* @param null|Expr $dim Array index / dim
* @param Expr $var Variable
* @param null|Expr $dim Array index / dim
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, ?Expr $dim = null, array $attributes = []) {
Expand Down
2 changes: 1 addition & 1 deletion lib/PhpParser/Node/Expr/Array_.php
Expand Up @@ -16,7 +16,7 @@ class Array_ extends Expr {
/**
* Constructs an array node.
*
* @param ArrayItem[] $items Items of the array
* @param ArrayItem[] $items Items of the array
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(array $items = [], array $attributes = []) {
Expand Down
4 changes: 2 additions & 2 deletions lib/PhpParser/Node/Expr/Assign.php
Expand Up @@ -13,8 +13,8 @@ class Assign extends Expr {
/**
* Constructs an assignment node.
*
* @param Expr $var Variable
* @param Expr $expr Expression
* @param Expr $var Variable
* @param Expr $expr Expression
* @param array<string, mixed> $attributes Additional attributes
*/
public function __construct(Expr $var, Expr $expr, array $attributes = []) {
Expand Down

0 comments on commit 2d3dd4e

Please sign in to comment.