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

Bug #18204 FunctionCommentThrowTag picks wrong exception type when throwing function call
Submitted: 2011-01-21 01:15 UTC
From: seikilos Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.0RC2)
PHP Version: 5.3.1 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2011-01-21 01:15 UTC] seikilos (Samuel Nolastname)
Description: ------------ Testscript below, run over it and got Expected "getErrorSchema" but found "mixed" for @throws tag exception Seems not to detect multiple exception exit points? Test script: --------------- /** * Stores settings * * @param mixed $con A database connection * * @throws mixed If the form is not valid * * @return mixed The current saved object */ public function save($con = null) { if ( $this->isValid() === false ) { throw $this->getErrorSchema(); } if ( null === $con ) { $con = $this->getConnection(); } $result = null; try { $con->beginTransaction(); $result = $this->doSave($con); $con->commit(); } catch ( Exception $e ) { $con->rollBack(); throw $e; } return $result; }

Comments

 [2011-01-21 05:56 UTC] squiz (Greg Sherwood)
-Summary: Squiz.Commenting.FunctionCommentThrowTag.WrongType seems to malfunction +Summary: FunctionCommentThrowTag picks wrong exception type when throwing function call -Status: Open +Status: Closed -Assigned To: +Assigned To: squiz
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. The sniff doesn't have problems with multiple end points. It just assumes you are throwing your own exceptions or variables. It does not support throwing the result of function calls. The sniff requires you to explicitly state the different types of exceptions that this method may throw, using a @throws tag for each. But if it sees you are throwing a variable, it doesn't check the type of the exception in the comment. It just makes sure there is at least one tag in there. I've changed the sniff to do the same thing for function calls.