There are less than seven days left until PHP 7 is released, which drops support for old-style constructors – the ones where a method is a constructor if it shares the same name as the class.
You don’t want to spend too much time scrolling through codebases for that though do you? Better things to do, like watch videos of conference talks you’ve missed and such.
This will run php code sniffer and identify old-style constructors.
$ phpcs --standard=Squiz --extensions=php --sniffs=Generic.NamingConventions.ConstructorName .
It’s a bit long-winded, so wrap it up in a bash alias, say in your .bashrc:
$ alias findoldphpconstructors='phpcs --standard=Squiz --extensions=php --sniffs=Generic.NamingConventions.ConstructorName .'
Want a CSV report of the same? Use this:
alias findoldphpconstructorsToCSV=’phpcs –standard=Squiz –report=csv –extensions=php –sniffs=Generic.NamingConventions.ConstructorName . | cut -f1,2 -d,’
Remember your unit tests.
Naturally when you do anything at all like this you really should write and run unit tests to ensure no side-effects have been caused inadvertently.