[php-src] Issue #20813: = new without $value creates it twice. Hooked object.
[email protected] (ACEx86)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
Issue: https://github.com/php/php-src/issues/20813
Author: ACEx86
### Description
The following code:
```php
<?php
$B = new B;
$B->A = new A;
Class B
{
Final Object $A{
get => $this->A;
set(Object $value) => new A;
}
}
Class A
{
public function __construct()
{
echo 'A'.PHP_EOL;
}
}
```
Resulted in this output:
```
A
A
```
But I expected this output instead:
```
A
```
In the hooked variable set with = to new A instead of value will call it twice.
If object is not equal to calling value don't do actions.
### PHP Version
```plain
PHP 8.5.1 (cli) (built: Dec 16 2025 18:26:57) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.1, Copyright (c) Zend Technologies
with Zend OPcache v8.5.1, Copyright (c), by Zend Technologies
```
### Operating System
_No response_