[php-src] PR #22042: Fix GH-21583: Make empty SimpleXML elements cast to false

From: Date: Thu, 14 May 2026 02:08:58 +0000
Subject: [php-src] PR #22042: Fix GH-21583: Make empty SimpleXML elements cast to false
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-36123@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/22042 Author: prateekbhujel Fixes GH-21583. SimpleXML boolean casts currently return true as soon as a node exists. That skips the existing emptiness check, so an empty element like <bar/> casts to true even though the documented boolean-cast behavior says empty SimpleXML elements without attributes are false. Use the same emptiness check for boolean casts that SimpleXML already uses elsewhere. Elements with text, attributes, or children still cast to true; empty elements without attributes now cast to false. Tests run: ``` sapi/cli/php run-tests.php -q ext/simplexml/tests/gh21583.phpt sapi/cli/php run-tests.php -q ext/simplexml/tests git diff --check ```

« previous php.git-pulls (#36123) next »