Skip to content

Commit 5ee45e2

Browse files
phpstan-botclaude
andcommitted
Cover array_column() property checks with named arguments
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c15084f commit 5ee45e2

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

tests/PHPStan/Rules/Functions/ArrayColumnRuleTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,21 @@ public function testRule(): void
8282
130,
8383
$tipText,
8484
],
85+
[
86+
"Parameter #2 \$column_key of function array_column expects a valid property name, 'missing' given, but ArrayColumnRuleTest\\FinalObject does not have such property.",
87+
140,
88+
$tipText,
89+
],
90+
[
91+
"Parameter #3 \$index_key of function array_column expects a valid property name, 'missing' given, but ArrayColumnRuleTest\\FinalObject does not have such property.",
92+
141,
93+
$tipText,
94+
],
95+
[
96+
"Parameter #3 \$index_key of function array_column expects a valid property name, 'missing' given, but ArrayColumnRuleTest\\FinalObject does not have such property.",
97+
142,
98+
$tipText,
99+
],
85100
]);
86101
}
87102

tests/PHPStan/Rules/Functions/data/array-column.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,13 @@ public function bug9671(array $dates): void
131131
}
132132

133133
}
134+
135+
/**
136+
* @param FinalObject[] $b
137+
*/
138+
function namedArguments(array $b): void
139+
{
140+
array_column($b, column_key: 'missing');
141+
array_column($b, index_key: 'missing', column_key: 'name');
142+
array_column(array: $b, column_key: 'name', index_key: 'missing');
143+
}

0 commit comments

Comments
 (0)