Feature request
Hi,
I found a case where PHPStan does not report any error, but PHP throws a fatal error at runtime.
The following code is accepted by PHPStan without any issues:
<?php declare(strict_types = 1);
final readonly class Obj
{
public function __construct(public string $value) {}
}
$obj = new Obj('val');
$newObj = clone($obj, ['value' => 'newVal']);
PHPStan reports no error.
However, when running this code in PHP, it results in a fatal error:
Fatal error: Uncaught Error: Cannot modify protected(set) readonly property Obj::$value from global scope
https://phpstan.org/r/78bd8f63-aea6-4d1b-8e97-c3a96bb44572
Did PHPStan help you today? Did it make you happy in any way?
No response