[php-src] Issue #10547: Private properties on readonly classes shows additional characters
| From: | SantosPaulo | Date: | Wed, 08 Feb 2023 16:53:47 +0000 |
| Subject: | [php-src] Issue #10547: Private properties on readonly classes shows additional characters | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243694@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10547
Author: SantosPaulo
### Description
The following code:
```php
<?php
final readonly class Example
{
/**
* @var int
*/
private int $prop1;
/**
* @var string
*/
public string $prop2;
public function __construct(int $prop1, string $prop2)
{
$this->prop1 = $prop1;
$this->prop2 = $prop2;
}
public function toArray(): array
{
return (array) $this;
}
}
$example = new Example(1, 'Some name');
print_r( $example->toArray() );
```
Resulted in this output:
```
Array
(
[�Example�prop1] => 1
[prop2] => Some name
)
```
But I expected this output instead:
```
Array
(
[prop1] => 1
[prop2] => Some name
)
```
### PHP Version
PHP 8.2
### Operating System
_No response_