I just figured out neither #phpstan nor #phpcodesniffer reported that a class was differrent from the file it is in. I bet it's a setting somewhere that my quick search didn't find...

BTW #PHPStorm with the defaults didn't report it either... (again may be there's a checkbox somewhere in the settings)...

coding-standard/doc/files.md at master · slevomat/coding-standard

Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs - slevomat/coding-standard

GitHub

@djumaka I use Swiss Knife for this kind of (very) annoying issue. It's made by RectorPHP's team, and can do a bunch of other things.

More specifically: I use composer dump to check if there are any issues, and then I use Swiss Knife to fix them.

Here's an extract of my Makefile showing how it's used in one of my project: https://gist.github.com/gnugat/b5bb7ba803569d61feb5d2366dd1b41d

Checking FQCN against filename: composer dump (check) + swiss knife (fix)

Checking FQCN against filename: composer dump (check) + swiss knife (fix) - Makefile

Gist
@djumaka I forgot to mention, but composer dump needs the --strict-psr --strict-ambiguous flags to check for that. And you can also use --dry-run if you prefer
@djumaka This should do it in PHPStorm (I'd have thought this would be enabled by default, but it's many many moons since I've had a vanilla config.)

@djumaka That's in the:

Editor->Inspections->PHP->Code Style section of the settings (these are often a PITA to find.. so hope this helps narrow that down 🙂 )