You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
input:24: PhanTypeMismatchArgument Argument 1 ($a) is $xx of type non-empty-list<array{a:1,b:'2'}> but \b() takes list<array<string,int>>|list<array<string,string>> defined at input:12
That's an incorrect error from the first foreach, but the second foreach and the literal pass.
Variable detected as
non-empty-list<…>
fails some array shape checks thatlist<…>
passes.Example:
Output:
That's an incorrect error from the first
foreach
, but the secondforeach
and the literal pass.Demo: https://phan.github.io/demo/?code=%3C%3F%0A%2F**%0A+*+%40param+array%3Cstring%2Cint|string%3E+%24a%0A+*%2F%0Afunction+a(%24a)%3A+void+{%0A++++var_dump(%24a)%3B%0A}%0A%0A%2F**%0A+*+%40param+list%3Carray%3Cstring%2Cint|string%3E%3E+%24a%0A+*%2F%0Afunction+b(%24a)%3A+void+{%0A++++var_dump(%24a)%3B%0A}%0A%0A%0A%24x+%3D+[+'a'+%3D%3E+1%2C+'b'+%3D%3E+'2'+]%3B%0Aa(%24x)%3B%0A%0A%24xx+%3D+[]%3B%0Aforeach+(+[1%2C2%2C3]+as+%24u+)+{%0A++++%24xx[]+%3D+%24x%3B%0A}%0Ab(%24xx)%3B%0A%0A%24zz+%3D+[]%3B%0Aforeach+(+range(1%2C3)+as+%24u+)+{%0A++++%24zz[]+%3D+%24x%3B%0A}%0Ab(%24zz)%3B%0A%0A%24yy+%3D+[+%24x%2C+%24x%2C+%24x+]%3B%0Ab(%24yy)%3B
Compare to PHPStan: https://phpstan.org/r/1c5904e5-ccde-47c2-ab40-6431fc5d494a
The text was updated successfully, but these errors were encountered: