PHP Static Analysis Tool (https://github.com/phpstan/phpstan) is pretty good at surfacing that kind of thing.
Other potentially useful tools:
- PHP_CodeSniffer (https://github.com/squizlabs/PHP_CodeSniffer)
- GrumPHP (https://github.com/phpro/grumphp)
- PHP Mess Detector (https://phpmd.org/)