Skip to content

Commit 9445f33

Browse files
phpstan-botclaude
andcommitted
Add tests for all affected functions in bug-14550 regression test
Cover first-class callable syntax for count, sizeof, strlen, mb_strlen, preg_match, gettype, get_class, get_debug_type, get_parent_class, trim, ltrim, rtrim, and array_keys. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 275d81e commit 9445f33

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

tests/PHPStan/Analyser/nsrt/bug-14550.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,81 @@ function crashArraySearch(array $list, string $s): void
4141
$fn = array_search(...);
4242
assertType('Closure(mixed, array, bool=): (int|string|false)', $fn);
4343
}
44+
45+
function crashCount(): void
46+
{
47+
$fn = count(...);
48+
assertType('Closure(array|Countable, 0|1=): int<0, max>', $fn);
49+
}
50+
51+
function crashSizeof(): void
52+
{
53+
$fn = sizeof(...);
54+
assertType('Closure(array|Countable, int=): int', $fn);
55+
}
56+
57+
function crashStrlen(): void
58+
{
59+
$fn = strlen(...);
60+
assertType('Closure(string): int<0, max>', $fn);
61+
}
62+
63+
function crashMbStrlen(): void
64+
{
65+
$fn = mb_strlen(...);
66+
assertType('Closure(string, string|null=): int<0, max>', $fn);
67+
}
68+
69+
function crashPregMatch(): void
70+
{
71+
$fn = preg_match(...);
72+
assertType('Closure(string, string, array<string>|null=, TFlags=, int=): (0|1|false)', $fn);
73+
}
74+
75+
function crashGettype(): void
76+
{
77+
$fn = gettype(...);
78+
assertType('Closure(mixed): string', $fn);
79+
}
80+
81+
function crashGetClass(): void
82+
{
83+
$fn = get_class(...);
84+
assertType('Closure(object=): class-string', $fn);
85+
}
86+
87+
function crashGetDebugType(): void
88+
{
89+
$fn = get_debug_type(...);
90+
assertType('Closure(mixed): string', $fn);
91+
}
92+
93+
function crashGetParentClass(): void
94+
{
95+
$fn = get_parent_class(...);
96+
assertType('Closure(object|string=): (class-string|false)', $fn);
97+
}
98+
99+
function crashTrim(): void
100+
{
101+
$fn = trim(...);
102+
assertType('Closure(string, string=): string', $fn);
103+
}
104+
105+
function crashLtrim(): void
106+
{
107+
$fn = ltrim(...);
108+
assertType('Closure(string, string=): string', $fn);
109+
}
110+
111+
function crashRtrim(): void
112+
{
113+
$fn = rtrim(...);
114+
assertType('Closure(string, string=): string', $fn);
115+
}
116+
117+
function crashArrayKeys(): void
118+
{
119+
$fn = array_keys(...);
120+
assertType('Closure(array, mixed=, bool=): list<int|string>', $fn);
121+
}

0 commit comments

Comments
 (0)