[php-src] Issue #21583: SimpleXML: empty child element without attributes casts to true instead of false

[email protected] (Chi-teck)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/21583
Author: Chi-teck

### Description

The following code:

```php
<?php

$cases = [
  '<foo><bar>content</bar></foo>',
  '<foo><bar/></foo>',
  '<foo/>',
];
foreach ($cases as $case) {
  \printf("%-30s: %s\n", $case, new \SimpleXMLElement($case)->bar ? '✅' : '❌');
}
```

Resulted in this output:
```
<foo><bar>content</bar></foo>  : ✅
<foo><bar/></foo>              : ✅
<foo/>                         : ❌
```

But I expected this output instead:
```
<foo><bar>content</bar></foo>  : ✅
<foo><bar/></foo>              : ❌
<foo/>                         : ❌
```

The documentation explicitly lists empty SimpleXML elements without attributes as falsy.
https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting

<img width="1214" height="732" alt="Image" src="https://github.com/user-attachments/assets/e383dd74-5607-44e4-bbbe-17c49cf183f3" />

### PHP Version

```plain
any
```

### Operating System

Debian 13
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.