PhpDocNode: Swap array_column() and array_filter()

See phpstan/phpstan-src#948
This commit is contained in:
Jean-Luc Herren 2022-01-29 18:10:47 +01:00 committed by Ondřej Mirtes
parent b63ce3910f
commit 4bf544b199

View File

@ -50,11 +50,11 @@ class PhpDocNode implements Node
*/ */
public function getVarTagValues(string $tagName = '@var'): array public function getVarTagValues(string $tagName = '@var'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof VarTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof VarTagValueNode;
'value' }
); );
} }
@ -64,11 +64,11 @@ class PhpDocNode implements Node
*/ */
public function getParamTagValues(string $tagName = '@param'): array public function getParamTagValues(string $tagName = '@param'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof ParamTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof ParamTagValueNode;
'value' }
); );
} }
@ -78,11 +78,11 @@ class PhpDocNode implements Node
*/ */
public function getTemplateTagValues(string $tagName = '@template'): array public function getTemplateTagValues(string $tagName = '@template'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof TemplateTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof TemplateTagValueNode;
'value' }
); );
} }
@ -92,11 +92,11 @@ class PhpDocNode implements Node
*/ */
public function getExtendsTagValues(string $tagName = '@extends'): array public function getExtendsTagValues(string $tagName = '@extends'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof ExtendsTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof ExtendsTagValueNode;
'value' }
); );
} }
@ -106,11 +106,11 @@ class PhpDocNode implements Node
*/ */
public function getImplementsTagValues(string $tagName = '@implements'): array public function getImplementsTagValues(string $tagName = '@implements'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof ImplementsTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof ImplementsTagValueNode;
'value' }
); );
} }
@ -120,11 +120,11 @@ class PhpDocNode implements Node
*/ */
public function getUsesTagValues(string $tagName = '@use'): array public function getUsesTagValues(string $tagName = '@use'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof UsesTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof UsesTagValueNode;
'value' }
); );
} }
@ -134,11 +134,11 @@ class PhpDocNode implements Node
*/ */
public function getReturnTagValues(string $tagName = '@return'): array public function getReturnTagValues(string $tagName = '@return'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof ReturnTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof ReturnTagValueNode;
'value' }
); );
} }
@ -148,11 +148,11 @@ class PhpDocNode implements Node
*/ */
public function getThrowsTagValues(string $tagName = '@throws'): array public function getThrowsTagValues(string $tagName = '@throws'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof ThrowsTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof ThrowsTagValueNode;
'value' }
); );
} }
@ -162,25 +162,25 @@ class PhpDocNode implements Node
*/ */
public function getMixinTagValues(string $tagName = '@mixin'): array public function getMixinTagValues(string $tagName = '@mixin'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof MixinTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof MixinTagValueNode;
'value' }
); );
} }
/** /**
* @return \PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode[] * @return DeprecatedTagValueNode[]
*/ */
public function getDeprecatedTagValues(): array public function getDeprecatedTagValues(): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName('@deprecated'), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName('@deprecated'), 'value'),
return $tag->value instanceof DeprecatedTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof DeprecatedTagValueNode;
'value' }
); );
} }
@ -190,11 +190,11 @@ class PhpDocNode implements Node
*/ */
public function getPropertyTagValues(string $tagName = '@property'): array public function getPropertyTagValues(string $tagName = '@property'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof PropertyTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof PropertyTagValueNode;
'value' }
); );
} }
@ -204,11 +204,11 @@ class PhpDocNode implements Node
*/ */
public function getPropertyReadTagValues(string $tagName = '@property-read'): array public function getPropertyReadTagValues(string $tagName = '@property-read'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof PropertyTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof PropertyTagValueNode;
'value' }
); );
} }
@ -218,11 +218,11 @@ class PhpDocNode implements Node
*/ */
public function getPropertyWriteTagValues(string $tagName = '@property-write'): array public function getPropertyWriteTagValues(string $tagName = '@property-write'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof PropertyTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof PropertyTagValueNode;
'value' }
); );
} }
@ -232,11 +232,11 @@ class PhpDocNode implements Node
*/ */
public function getMethodTagValues(string $tagName = '@method'): array public function getMethodTagValues(string $tagName = '@method'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof MethodTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof MethodTagValueNode;
'value' }
); );
} }
@ -246,11 +246,11 @@ class PhpDocNode implements Node
*/ */
public function getTypeAliasTagValues(string $tagName = '@phpstan-type'): array public function getTypeAliasTagValues(string $tagName = '@phpstan-type'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof TypeAliasTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof TypeAliasTagValueNode;
'value' }
); );
} }
@ -260,11 +260,11 @@ class PhpDocNode implements Node
*/ */
public function getTypeAliasImportTagValues(string $tagName = '@phpstan-import-type'): array public function getTypeAliasImportTagValues(string $tagName = '@phpstan-import-type'): array
{ {
return array_column( return array_filter(
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool { array_column($this->getTagsByName($tagName), 'value'),
return $tag->value instanceof TypeAliasImportTagValueNode; static function (PhpDocTagValueNode $value): bool {
}), return $value instanceof TypeAliasImportTagValueNode;
'value' }
); );
} }