Page MenuHomePhabricator

Codesniffer should warn if output functions like print are used
Open, Needs TriagePublic

Description

print is used by a lot people for debugging. It might be nice to have a phpcs rule to warn if print is used. Most of code should be forbidden to use it.

For example, this change has a print hidden in the changed code.

Event Timeline

Not sure if there are too many places where it needs to be print/printf

Could search for var_export without a second argument as well.

https://codesearch.wmcloud.org/search/?q=%5Cbprintf%3F%5Cb%5Cs*%5C(%3F&i=nope&files=%5C.php&excludeFiles=&repos=

Daimona subscribed.

While I agree that leftover debug code is dangerous, doing this right is not easy. I should also note that phan has a RemoveDebugStatementPlugin sniff which does exactly this.