spaze / phpstan-disallowed-calls

PHPStan rules to detect disallowed method & function calls, constant, namespace, attribute & superglobal usages
MIT License
255 stars 17 forks source link

Change ConstantScalarType to Type in DisallowedCallParam #159

Closed ruudk closed 1 year ago

ruudk commented 1 year ago

This allows for more types to be matched, like a CallbackType.

In my use case, I wanted to disallow array_filter without specifying a callback.

But because the current DisallowedCallParam interface only works with ConstantScalarType this was not possible.

ruudk commented 1 year ago

@spaze Happy New Year! Please have a look when you have time!

spaze commented 1 year ago

Happy New Year to you too @ruudk! And thanks for the PR, this makes sense 👍 I'll merge and release soon.

spaze commented 1 year ago

Just released in 2.11.3, thanks again!

ruudk commented 1 year ago

With this feature, we now also are able to detect static references like CommandBus::class in arguments. Before, those would be ignored too 😅

spaze commented 1 year ago

Nice! Can you write a test, or more like amend an existing one, for that case? (update: #161)