ZF-6142: @ operator should be avoided in Zend_Dom_Query


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);
             case self::DOC_HTML:
             case self::DOC_XHTML:
-                $success = @$domDoc->loadHTML($document);
+                $success = $domDoc->loadHTML($document);

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.


Assigned component.

Assigned to component lead

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.

Updated in trunk and 1.10 release branch.