Bug #19348 [Opn->Fbk]: Missing function parameters in AbstractSniffUnitTest

From: Date: Sun, 25 Mar 2012 23:45:28 +0000
Subject: Bug #19348 [Opn->Fbk]: Missing function parameters in AbstractSniffUnitTest
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-8440@lists.php.net to get a copy of this message
Edit report at https://pear.php.net/bugs/bug.php?id=19348&edit=1 ID: 19348 Updated by: gsherwood@squiz.net Reported By: jnrbsn at gmail dot com Summary: Missing function parameters in AbstractSniffUnitTest -Status: Open +Status: Feedback Type: Bug Package: PHP_CodeSniffer Operating System: Mac OS 10.7.3 "Lion" Package Version: 1.3.3 PHP Version: 5.3.8 -Assigned To: +Assigned To: squiz Roadmap Versions: New Comment: -Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz While I see the issue, I don't get any errors (and never have). I have tested on 5.2, 5.3 and 5.4. I'm currently running 5.3.8 on Lion, just like you. Out of interest, how are you running the tests? Previous Comments: ------------------------------------------------------------------------ [2012-03-25 23:50:45] jnrbsn Description: ------------ The following abstract methods get a single parameter passed to them during the unit tests (the basename of the test file): AbstractSniffUnitTest::getErrorList() AbstractSniffUnitTest::getWarningList() However, the declarations of those methods in AbstractSniffUnitTest.php do NOT contain any parameters. So if I want to use the parameters in my own tests, I have to use func_get_args(), because if I put the parameter in the declaration of my method, I get a "Declaration of ... must be compatible with that of ..." error. This kind of sucks actually, because even if you did "fix" this, it would break everyone's existing unit tests for the same reason. Is that why it's like that? Test script: --------------- <?php class MyStandard_Tests_Files_LineEndingsUnitTest extends AbstractSniffUnitTest { public function getErrorList($testFile) { switch ($testFile) { case 'LineEndingsUnitTest.CRLF.inc': $errors = array(1 => 1); break; // More stuff here... } return $errors; } public function getWarningList($testFile) { return array(); } } Expected result: ---------------- The tests should run, allowing different error lists for different test files. To get it to work, you have to remove $testFile from the method declaration and use func_get_args() to get the name of the test file. Actual result: -------------- PHP Fatal error: Declaration of MyStandard_Tests_Files_LineEndingsUnitTest::getErrorList() must be compatible with that of AbstractSniffUnitTest::getErrorList() in /path/to/file/LineEndingsUnitTest.php on line XXX ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=19348&edit=1

« previous php.pear.bugs (#8440) next »