Bug Report
| Q |
A |
| Version |
3.3.3 |
| Previous Version if the bug is a regression |
2.5.7 |
Summary
After upgrading 2.5.7 → 3.3.3 as a dependency of the Doctrine ODM we are seeing crashes:
Cannot assign null to property RH\OrganisationBundle\Model\Organisation::$type of type string
The catch here is that the $type property is static. But it has been like this for years and years in our codebase and worked OK.
This happens when running the UnitOfWork->merge() method. I have tracked this down to the RuntimeReflectionProperty behaving differently from the native ReflectionProperty for static properties:
<?php
require 'vendor/autoload.php';
class Foo
{
public static $staticProp = 'staticPropValue';
}
$fooInstance = new Foo();
$propNative = new ReflectionProperty(Foo::class, 'staticProp');
$propDoctrine = new \Doctrine\Persistence\Reflection\RuntimeReflectionProperty(Foo::class, 'staticProp');
var_dump(
$propNative->getValue(),
$propNative->getValue($fooInstance),
$propDoctrine->getValue(),
$propDoctrine->getValue($fooInstance)
);
/*
* string(15) "staticPropValue"
* string(15) "staticPropValue"
* string(15) "staticPropValue"
* NULL
*/
I believe this has been introduced in 45c484f.
Current behavior
RuntimeReflectionProperty returns null for static properties.
Expected behavior
RuntimeReflectionProperty should return actual values for static properties.
How to reproduce
See linked PR.
Bug Report
Summary
After upgrading 2.5.7 → 3.3.3 as a dependency of the Doctrine ODM we are seeing crashes:
The catch here is that the
$typeproperty isstatic. But it has been like this for years and years in our codebase and worked OK.This happens when running the
UnitOfWork->merge()method. I have tracked this down to theRuntimeReflectionPropertybehaving differently from the nativeReflectionPropertyfor static properties:I believe this has been introduced in 45c484f.
Current behavior
RuntimeReflectionPropertyreturnsnullfor static properties.Expected behavior
RuntimeReflectionPropertyshould return actual values for static properties.How to reproduce
See linked PR.