You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nullable modifier is lost in promoted constructor properties. For example, this code will result fatal error:
class Test {
publicfunction__construct(
protected ?int$value
) {
}
}
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory();
$proxy = $factory->createProxy(
Test::class,
function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {
$wrappedObject = newTest(null);
}
);
PHP Fatal error: Type of ProxyManagerGeneratedProxy\__PM__\Test\Generated1c12fa522c43907846cdf9382a0d356f::$value must be ?int (as in class Test) in .../vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php(54) : eval()'d code on line 3
And indeed, property is no longer nullable in generated proxy:
namespaceProxyManagerGeneratedProxy\__PM__\Test;
class Generated7ef5eb7812f288337a0d82be0b42baa6 extends \Test implements \ProxyManager\Proxy\VirtualProxyInterface
{
...
publicfunction__construct(protectedint$value) // <---------------- nullable modificator is lost
{
static$reflection;
if (! $this->valueHoldere9785) {
$reflection = $reflection ?? new \ReflectionClass('Test');
$this->valueHoldere9785 = $reflection->newInstanceWithoutConstructor();
unset($this->value);
}
$this->valueHoldere9785->__construct($value);
}
...
The text was updated successfully, but these errors were encountered:
Issue does not occur with laminas-code 4.4 (specified in the composer.lock), since it does not supports constructior property promotion at all. But it laminas-code 4.7 does support that, and then this issue arises.
Nullable modifier is lost in promoted constructor properties. For example, this code will result fatal error:
And indeed, property is no longer nullable in generated proxy:
The text was updated successfully, but these errors were encountered: