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

When a call is disallowed due to a parameter rule, display a different message #155

Closed spaze closed 10 months ago

spaze commented 1 year ago

Discussed in https://github.com/spaze/phpstan-disallowed-calls/discussions/154

Originally posted by **eithed** December 19, 2022 I'd like to disallow different methods, with different messages, dependent upon the number of parameters used. For example, if I've got function: ``` function foo($bar = '', $xyz = ''){} ``` I'd like to display: - if `foo()` is used anywhere, display `Don't use foo` - if `foo(*)` is used anywhere, display `Don't use foo with parameter $bar` - if `foo(*,*)` is used anywhere, display `Don't use foo with parameters $bar and $xyz` Is this possible at all?

Maintainer note: I think a param-level message could be added that would override the main message when a call would be disallowed due to disallowed/missing param.