Skip to content

[CodeQuality] Skip SimpleXMLElement on IssetOnPropertyObjectToPropertyExistsRector - #8284

Merged
TomasVotruba merged 1 commit into
mainfrom
skip-simple-xml-element-isset
Aug 4, 2026
Merged

[CodeQuality] Skip SimpleXMLElement on IssetOnPropertyObjectToPropertyExistsRector#8284
TomasVotruba merged 1 commit into
mainfrom
skip-simple-xml-element-isset

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

SimpleXMLElement resolves properties from the XML document at runtime, not from the class. property_exists() always returns false for them, so the rewrite breaks working code.

 public function x(SimpleXMLElement $svg) {
     $svgAttributes = $svg->attributes();

-    if (isset($svgAttributes->width) && isset($svgAttributes->height)) {
+    if (property_exists($svgAttributes, 'width') && $svgAttributes->width !== null && (property_exists($svgAttributes, 'height') && $svgAttributes->height !== null)) {
         return true;
     }

-    return isset($svg->viewBox);
+    return property_exists($svg, 'viewBox') && $svg->viewBox !== null;
 }

Now SimpleXMLElement and its children are skipped.

@TomasVotruba
TomasVotruba merged commit 23fb7bb into main Aug 4, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the skip-simple-xml-element-isset branch August 4, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant