[php-src] Issue #9511: php empty function corner case?
| From: | 8ctopus | Date: | Thu, 08 Sep 2022 13:51:44 +0000 |
| Subject: | [php-src] Issue #9511: php empty function corner case? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242386@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9511
Author: 8ctopus
### Description
The following code:
```php
<?php
class myClass
{
private string $myString;
public function __construct()
{
$this->myString = 'hello';
}
public function __get(string $property) : mixed
{
if (property_exists($this, $property)) {
return $this->{$property};
}
throw new Exception("unknown property {$property}");
}
}
$myClass = new myClass();
echo (empty($myClass->myString) ? 'property is empty' : 'property not empty')
. PHP_EOL;
echo 'strlen: ' . strlen($myClass->myString);
```
Resulted in this output:
```
property is empty
strlen: 5
```
But I expected this output instead:
```
property not empty
strlen: 5
```
https://onlinephp.io/c/fb939
### PHP Version
8.2.0beta3 and 8.1.10
### Operating System
/