Skip to content

Commit 4bf544b

Browse files
jlherrenondrejmirtes
authored andcommitted
PhpDocNode: Swap array_column() and array_filter()
See phpstan/phpstan-src#948
1 parent b63ce39 commit 4bf544b

File tree

1 file changed

+81
-81
lines changed

1 file changed

+81
-81
lines changed

src/Ast/PhpDoc/PhpDocNode.php

+81-81
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public function getTagsByName(string $tagName): array
5050
*/
5151
public function getVarTagValues(string $tagName = '@var'): array
5252
{
53-
return array_column(
54-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
55-
return $tag->value instanceof VarTagValueNode;
56-
}),
57-
'value'
53+
return array_filter(
54+
array_column($this->getTagsByName($tagName), 'value'),
55+
static function (PhpDocTagValueNode $value): bool {
56+
return $value instanceof VarTagValueNode;
57+
}
5858
);
5959
}
6060

@@ -64,11 +64,11 @@ public function getVarTagValues(string $tagName = '@var'): array
6464
*/
6565
public function getParamTagValues(string $tagName = '@param'): array
6666
{
67-
return array_column(
68-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
69-
return $tag->value instanceof ParamTagValueNode;
70-
}),
71-
'value'
67+
return array_filter(
68+
array_column($this->getTagsByName($tagName), 'value'),
69+
static function (PhpDocTagValueNode $value): bool {
70+
return $value instanceof ParamTagValueNode;
71+
}
7272
);
7373
}
7474

@@ -78,11 +78,11 @@ public function getParamTagValues(string $tagName = '@param'): array
7878
*/
7979
public function getTemplateTagValues(string $tagName = '@template'): array
8080
{
81-
return array_column(
82-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
83-
return $tag->value instanceof TemplateTagValueNode;
84-
}),
85-
'value'
81+
return array_filter(
82+
array_column($this->getTagsByName($tagName), 'value'),
83+
static function (PhpDocTagValueNode $value): bool {
84+
return $value instanceof TemplateTagValueNode;
85+
}
8686
);
8787
}
8888

@@ -92,11 +92,11 @@ public function getTemplateTagValues(string $tagName = '@template'): array
9292
*/
9393
public function getExtendsTagValues(string $tagName = '@extends'): array
9494
{
95-
return array_column(
96-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
97-
return $tag->value instanceof ExtendsTagValueNode;
98-
}),
99-
'value'
95+
return array_filter(
96+
array_column($this->getTagsByName($tagName), 'value'),
97+
static function (PhpDocTagValueNode $value): bool {
98+
return $value instanceof ExtendsTagValueNode;
99+
}
100100
);
101101
}
102102

@@ -106,11 +106,11 @@ public function getExtendsTagValues(string $tagName = '@extends'): array
106106
*/
107107
public function getImplementsTagValues(string $tagName = '@implements'): array
108108
{
109-
return array_column(
110-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
111-
return $tag->value instanceof ImplementsTagValueNode;
112-
}),
113-
'value'
109+
return array_filter(
110+
array_column($this->getTagsByName($tagName), 'value'),
111+
static function (PhpDocTagValueNode $value): bool {
112+
return $value instanceof ImplementsTagValueNode;
113+
}
114114
);
115115
}
116116

@@ -120,11 +120,11 @@ public function getImplementsTagValues(string $tagName = '@implements'): array
120120
*/
121121
public function getUsesTagValues(string $tagName = '@use'): array
122122
{
123-
return array_column(
124-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
125-
return $tag->value instanceof UsesTagValueNode;
126-
}),
127-
'value'
123+
return array_filter(
124+
array_column($this->getTagsByName($tagName), 'value'),
125+
static function (PhpDocTagValueNode $value): bool {
126+
return $value instanceof UsesTagValueNode;
127+
}
128128
);
129129
}
130130

@@ -134,11 +134,11 @@ public function getUsesTagValues(string $tagName = '@use'): array
134134
*/
135135
public function getReturnTagValues(string $tagName = '@return'): array
136136
{
137-
return array_column(
138-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
139-
return $tag->value instanceof ReturnTagValueNode;
140-
}),
141-
'value'
137+
return array_filter(
138+
array_column($this->getTagsByName($tagName), 'value'),
139+
static function (PhpDocTagValueNode $value): bool {
140+
return $value instanceof ReturnTagValueNode;
141+
}
142142
);
143143
}
144144

@@ -148,11 +148,11 @@ public function getReturnTagValues(string $tagName = '@return'): array
148148
*/
149149
public function getThrowsTagValues(string $tagName = '@throws'): array
150150
{
151-
return array_column(
152-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
153-
return $tag->value instanceof ThrowsTagValueNode;
154-
}),
155-
'value'
151+
return array_filter(
152+
array_column($this->getTagsByName($tagName), 'value'),
153+
static function (PhpDocTagValueNode $value): bool {
154+
return $value instanceof ThrowsTagValueNode;
155+
}
156156
);
157157
}
158158

@@ -162,25 +162,25 @@ public function getThrowsTagValues(string $tagName = '@throws'): array
162162
*/
163163
public function getMixinTagValues(string $tagName = '@mixin'): array
164164
{
165-
return array_column(
166-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
167-
return $tag->value instanceof MixinTagValueNode;
168-
}),
169-
'value'
165+
return array_filter(
166+
array_column($this->getTagsByName($tagName), 'value'),
167+
static function (PhpDocTagValueNode $value): bool {
168+
return $value instanceof MixinTagValueNode;
169+
}
170170
);
171171
}
172172

173173

174174
/**
175-
* @return \PHPStan\PhpDocParser\Ast\PhpDoc\DeprecatedTagValueNode[]
175+
* @return DeprecatedTagValueNode[]
176176
*/
177177
public function getDeprecatedTagValues(): array
178178
{
179-
return array_column(
180-
array_filter($this->getTagsByName('@deprecated'), static function (PhpDocTagNode $tag): bool {
181-
return $tag->value instanceof DeprecatedTagValueNode;
182-
}),
183-
'value'
179+
return array_filter(
180+
array_column($this->getTagsByName('@deprecated'), 'value'),
181+
static function (PhpDocTagValueNode $value): bool {
182+
return $value instanceof DeprecatedTagValueNode;
183+
}
184184
);
185185
}
186186

@@ -190,11 +190,11 @@ public function getDeprecatedTagValues(): array
190190
*/
191191
public function getPropertyTagValues(string $tagName = '@property'): array
192192
{
193-
return array_column(
194-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
195-
return $tag->value instanceof PropertyTagValueNode;
196-
}),
197-
'value'
193+
return array_filter(
194+
array_column($this->getTagsByName($tagName), 'value'),
195+
static function (PhpDocTagValueNode $value): bool {
196+
return $value instanceof PropertyTagValueNode;
197+
}
198198
);
199199
}
200200

@@ -204,11 +204,11 @@ public function getPropertyTagValues(string $tagName = '@property'): array
204204
*/
205205
public function getPropertyReadTagValues(string $tagName = '@property-read'): array
206206
{
207-
return array_column(
208-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
209-
return $tag->value instanceof PropertyTagValueNode;
210-
}),
211-
'value'
207+
return array_filter(
208+
array_column($this->getTagsByName($tagName), 'value'),
209+
static function (PhpDocTagValueNode $value): bool {
210+
return $value instanceof PropertyTagValueNode;
211+
}
212212
);
213213
}
214214

@@ -218,11 +218,11 @@ public function getPropertyReadTagValues(string $tagName = '@property-read'): ar
218218
*/
219219
public function getPropertyWriteTagValues(string $tagName = '@property-write'): array
220220
{
221-
return array_column(
222-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
223-
return $tag->value instanceof PropertyTagValueNode;
224-
}),
225-
'value'
221+
return array_filter(
222+
array_column($this->getTagsByName($tagName), 'value'),
223+
static function (PhpDocTagValueNode $value): bool {
224+
return $value instanceof PropertyTagValueNode;
225+
}
226226
);
227227
}
228228

@@ -232,11 +232,11 @@ public function getPropertyWriteTagValues(string $tagName = '@property-write'):
232232
*/
233233
public function getMethodTagValues(string $tagName = '@method'): array
234234
{
235-
return array_column(
236-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
237-
return $tag->value instanceof MethodTagValueNode;
238-
}),
239-
'value'
235+
return array_filter(
236+
array_column($this->getTagsByName($tagName), 'value'),
237+
static function (PhpDocTagValueNode $value): bool {
238+
return $value instanceof MethodTagValueNode;
239+
}
240240
);
241241
}
242242

@@ -246,11 +246,11 @@ public function getMethodTagValues(string $tagName = '@method'): array
246246
*/
247247
public function getTypeAliasTagValues(string $tagName = '@phpstan-type'): array
248248
{
249-
return array_column(
250-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
251-
return $tag->value instanceof TypeAliasTagValueNode;
252-
}),
253-
'value'
249+
return array_filter(
250+
array_column($this->getTagsByName($tagName), 'value'),
251+
static function (PhpDocTagValueNode $value): bool {
252+
return $value instanceof TypeAliasTagValueNode;
253+
}
254254
);
255255
}
256256

@@ -260,11 +260,11 @@ public function getTypeAliasTagValues(string $tagName = '@phpstan-type'): array
260260
*/
261261
public function getTypeAliasImportTagValues(string $tagName = '@phpstan-import-type'): array
262262
{
263-
return array_column(
264-
array_filter($this->getTagsByName($tagName), static function (PhpDocTagNode $tag): bool {
265-
return $tag->value instanceof TypeAliasImportTagValueNode;
266-
}),
267-
'value'
263+
return array_filter(
264+
array_column($this->getTagsByName($tagName), 'value'),
265+
static function (PhpDocTagValueNode $value): bool {
266+
return $value instanceof TypeAliasImportTagValueNode;
267+
}
268268
);
269269
}
270270

0 commit comments

Comments
 (0)