Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Request #17798 PEAR CS: Add an exception for PHPUnit
Submitted: 2010-08-23 03:41 UTC
From: doconnor Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version SVN)
PHP Version: 5.3.3 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2010-08-23 03:41 UTC] doconnor (Daniel O'Connor)
Description: ------------ PHPUnit relies on a constant, named "PHPUnit_MAIN_METHOD". The PEAR CS asks for all constants to be uppercase. What happens is people do the right thing, and fix their code; only to have PHPUnit running their tests twice. if (PHPUNIT_MAIN_METHOD == 'PHP_Shell_AllTests::main') { PHP_Shell_AllTests::main(); } vs: if (PHPUnit_MAIN_METHOD == 'PHP_Shell_AllTests::main') { PHP_Shell_AllTests::main(); } Consider adding an exception for this to the relevant sniff.

Comments

 [2010-08-23 07:50 UTC] jeff_dickey (Jeff Dickey)
Agreed this should be an exception. While the dogmatic approach would be to ask Sebastian to change his constant name, the sheer number of user tests that would almost certainly break were he to do so argue convincingly for a legacy-code exception to the rule. (Perhaps a duplicate, all-caps constant could be added, documented and encouraged, with the mixed-case one marked as legacy code that will break in a future non-BC release of PHPUnit?)
 [2010-08-23 09:53 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
I don't see any reason not to include the exception.
 [2010-08-23 09:53 UTC] squiz (Greg Sherwood)
And forgot to mention that this is now working in SVN.
 [2010-08-25 20:34 UTC] sebastian (Sebastian Bergmann)
PHPUnit no longer relies on this constant (at least since PHPUnit 3.4).