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

Introduce `disallowIn` as inverse of `allowIn` #95

Closed ruudk closed 1 year ago

ruudk commented 2 years ago

It would be great if I could enforce some rules that only apply in some directories.

Currently, the only way to get that working is to construct a list of all options using wildcards, and then exclude the target from it. Not very ideal / scalable.

What do you think, would this be worth adding? Of course I can work on a PR to address it.

spaze commented 2 years ago

I'm solving similar situation with different PHPStan config file with different rules. For example

https://github.com/spaze/michalspacek.cz/blob/5f1606dc130823f0b717b14eea846a3e70452a65/site/composer.json#L80 and https://github.com/spaze/michalspacek.cz/blob/master/site/phpstan-vendor.neon

It might make sense as there's already something similar for params (allowExceptParams et al.). If the extra config doesn't help, then it might be worthwhile but maybe it should follow the "allowExcept" naming pattern.

spaze commented 1 year ago

I've just released this in 2.9.0, hope it's still useful (realized today it is useful for me too 😊)

ruudk commented 1 year ago

I'm sorry but I can't remember why I wanted to use this back in 2021... But thanks for fixing it. Maybe I'll use it in the future 😊