New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change ConstantScalarType to Type in DisallowedCallParam #159
Conversation
b3db2af
to
4b654d4
Compare
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.
4b654d4
to
84946da
Compare
@spaze Happy New Year! Please have a look when you have time! |
Happy New Year to you too @ruudk! And thanks for the PR, this makes sense 👍 I'll merge and release soon. |
Just released in 2.11.3, thanks again! |
With this feature, we now also are able to detect static references like |
Nice! Can you write a test, or more like amend an existing one, for that case? (update: #161) |
This is an extra commit because things got a little complicated here. Due to changes spaze/phpstan-disallowed-calls 2.11.3 and particularly spaze/phpstan-disallowed-calls#159, more params can be detected and PHPStan started throwing errors in spaze/sri-macros/src/Config.php:126 saying "Calling hash_file() is forbidden". The type that got passed to hash_file() was `StringType`, not `ConstantStringType` and even though the values were the ones allowed, the param was rejected. I had to change sri-macros to pass a union of `ConstantStringType`s and phpstan-disallowed-calls to support union types.
This is an extra commit because things got a little complicated here. Due to changes spaze/phpstan-disallowed-calls 2.11.3 and particularly spaze/phpstan-disallowed-calls#159, more params can be detected and PHPStan started throwing errors in spaze/sri-macros/src/Config.php:126 saying "Calling hash_file() is forbidden". The type that got passed to hash_file() was `StringType`, not `ConstantStringType` and even though the values were the ones allowed, the param was rejected. I had to change sri-macros to pass a union of `ConstantStringType`s and phpstan-disallowed-calls to support union types. - spaze/phpstan-disallowed-calls updated from v2.11.2 to v2.11.3 patch See changes: spaze/phpstan-disallowed-calls@v2.11.2...v2.11.3 Release notes: https://github.com/spaze/phpstan-disallowed-calls/releases/tag/v2.11.3 - spaze/sri-macros updated from v2.0.0 to v2.0.1 patch See changes: spaze/sri-macros@v2.0.0...v2.0.1 Release notes: https://github.com/spaze/sri-macros/releases/tag/v2.0.1
This is an extra commit because things got a little complicated here. Due to changes spaze/phpstan-disallowed-calls 2.11.3 and particularly spaze/phpstan-disallowed-calls#159, more params can be detected and PHPStan started throwing errors in spaze/sri-macros/src/Config.php:126 saying "Calling hash_file() is forbidden". The type that got passed to hash_file() was `StringType`, not `ConstantStringType` and even though the values were the ones allowed, the param was rejected. I had to change sri-macros to pass a union of `ConstantStringType`s and phpstan-disallowed-calls to support union types. - spaze/phpstan-disallowed-calls updated from v2.11.3 to v2.11.4 patch See changes: spaze/phpstan-disallowed-calls@v2.11.3...v2.11.4 Release notes: https://github.com/spaze/phpstan-disallowed-calls/releases/tag/v2.11.4 - spaze/sri-macros updated from v2.0.0 to v2.0.1 patch See changes: spaze/sri-macros@v2.0.0...v2.0.1 Release notes: https://github.com/spaze/sri-macros/releases/tag/v2.0.1
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 withConstantScalarType
this was not possible.