I have to work with a very large codebase that has been in continuous development for the last 11 years, with varying maintenance levels.
Older code is slightly messy, as one would expect. And there are tons of PHP4 constructors lying around:
class Foo {
private $thing;
public function Foo($thing) {
$this->thing = $thing;
}
}
Plus, more than a few files with more than one class declared on each. And of course, files with only procedural code in them (many with definitions, and some with actual work happening in them).
I'd like to use phpcs
to run a report on only these things:
And ignore everything else.
Are there some standard sniffs I could use to do this? Or a way to declare a custom ruleset to check for this?
One additional bonus point: detecting those files where a class is defined, and there is code sitting outside of the class.
Finally found here that I could look for old-style constructors using this:
phpcs --standard=Squiz --extensions=php --sniffs=Generic.NamingConventions.ConstructorName .
Also, I found a standard generator for PhpCS here.