File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
tests/PHPStan/Analyser/data Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ public function specifyTypesInCondition(
249249 $ argType = $ scope ->getType ($ expr ->right ->getArgs ()[0 ]->value );
250250 if ($ argType ->isArray ()->yes ()) {
251251 $ newType = new NonEmptyArrayType ();
252- if ($ argType ->isList ()->yes ()) {
252+ if ($ context -> truthy () && $ argType ->isList ()->yes ()) {
253253 $ newType = AccessoryArrayListType::intersectWith ($ newType );
254254 }
255255
Original file line number Diff line number Diff line change 33namespace Bug10264 ;
44
55use function PHPStan \Testing \assertType ;
6+ use stdClass ;
67
78class A
89{
@@ -15,6 +16,18 @@ function doFoo() {
1516 assert ((count ($ list ) <= 1 ) === true );
1617 assertType ('list<Bug10264\A> ' , $ list );
1718 }
18- }
1919
20+ /** @param list<int> $c */
21+ public function sayHello (array $ c ): void
22+ {
23+ assertType ('list<int> ' , $ c );
24+ if (count ($ c ) > 0 ) {
25+ $ c = array_map (fn () => new stdClass (), $ c );
26+ assertType ('non-empty-list<stdClass> ' , $ c );
27+ } else {
28+ assertType ('array{} ' , $ c );
29+ }
2030
31+ assertType ('list<stdClass> ' , $ c );
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments