switch
on gettype($var), then case
ing on result, doesn't appear to take result into account
#6901
Labels
switch
on gettype($var), then case
ing on result, doesn't appear to take result into account
#6901
Bug report
1. Did a quick search for
gettype switch
in issues - nothing stood out as similar (#1330 came close, but that was from 2018, and doesn't appear to be this 'use' case)2. I'm aware that what I'm doing here is possibly a gross abuse of
gettype()
, and should probably be doing (and in fact probably will do) something saner here. Nevertheless - reporting this in case I'm not misunderstanding something more fundamentalI'm using a
switch gettype($var)
andcase
ing on the return values; the behavior changing depending on what was passed in.At the point where
gettype()
has determined (in this example)integer
and in thatcase
clause, I'd presume the same behaviour after - say - branching on anis_int()
on the same variable. However it seems the result ofgettype()
here isn't 'remembered,' or at least considered.Code snippet that reproduces the problem
https://phpstan.org/r/545f326d-f332-4bd1-a5c4-a635edc47575
Output
Expected output
No error
The text was updated successfully, but these errors were encountered: