Hello Tim Düsterhus,

> following Rowan’s request from the earlier “let the "new" operator fail
> when the __construct( ) function returns a value” discussion [1], I have
> now created a dedicated RFC to deprecate returning values from
> __construct() and __destruct().
>
> Please find the RFC text at:
> https://wiki.php.net/rfc/deprecate-return-value-from-construct

The RFC should also include "yield". Because "yield" also returns a value.

For example:
https://3v4l.org/Z4dMTF#v8.5.3

```php

class SomeTheoreticalYieldExample
{
    public $value;

    public function __construct()
    {
        $this->value = 'Some value';
        yield 1; // Deprecated: yielding from a constructor is deprecated
    }
}

$it = new SomeTheoreticalYieldExample();
var_dump($it->value); // PHP 8.5 surprise/bug, it is NULL

```

Kind Regards,
Mirco Babin

Reply via email to