-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Labels
Description
Bug report
An array of class names is not properly detected as class-string
.
Code snippet that reproduces the problem
https://phpstan.org/r/e84c46b3-64d2-4326-aa7a-7881f44b2c25
phpstan reports that a method that expects class-string
is given string
.
Expected output
phpstan should return no error via either of the two following mechanisms:
- the constant is explicitly defined as having values of
class-string<someinterface>
via an annotation, which phpstan ignores (class-string not enforced in constants #2798) - the constant contains values of
class-string
, which phpstan can normally infer, but because it has 10 elements, which exceedsCONSTANT_SCALAR_UNION_THRESHOLD
, phpstan does not make the inference.
While I would prefer this fixed via fixing #2798 (which would fix this general case entirely), if increasing CONSTANT_SCALAR_UNION_THRESHOLD
is the solution you prefer, I should be able to make a PR that adds a configuration option to set it.