ZF-6142: @ operator should be avoided in Zend_Dom_Query
Description
If used the means to debug are next to 0 without editing the code (to remove the @-operator).
--- library/Zend/Dom/Query.php (revision XXX)
+++ library/Zend/Dom/Query.php (working copy)
@@ -176,12 +176,12 @@
$type = $this->getDocumentType();
switch ($type) {
case self::DOC_XML:
- $success = @$domDoc->loadXML($document);
+ $success = $domDoc->loadXML($document);
break;
case self::DOC_HTML:
case self::DOC_XHTML:
default:
- $success = @$domDoc->loadHTML($document);
+ $success = $domDoc->loadHTML($document);
break;
}
It should be left to the developer to catch E_WARNING instead. There's multiple ways, e.g. an error handler to generate an exception or a simple log file, etc..
This should be added to the Coding Standards as well so people avoid this kind of thing in other components.
Comments
Posted by Till Klampaeckel (till) on 2009-03-27T13:09:18.000+0000
Assigned component.
Posted by Benjamin Eberlei (beberlei) on 2009-09-17T15:31:44.000+0000
Assigned to component lead
Posted by Matthew Weier O'Phinney (matthew) on 2010-01-21T09:08:31.000+0000
One problem: this component was designed for use in unit testing. By omitting the '@' operator, PHPUnit tests that would otherwise pass now fail due to a notice or warning being raised. While the underlying cause should likely be corrected, in some instances, developers need to work with bad markup.
I'll review the rationale for using the suppression to see if there may be another route to take.
Posted by Matthew Weier O'Phinney (matthew) on 2010-02-04T11:02:00.000+0000
Updated in trunk and 1.10 release branch.