Does anyone know how this works?
This works by unserializing objects. Unserializing in PHP does prevent the constructor to be called as the serialized object has been already constructed.
$className = 'stdClass'; # set classname here
$serialized = sprintf('O:%d:"%s":0:{}', strlen($className), $className);
$object = unserialize($serialized);
For more details please see this article: Doctrine 2: Give me my constructor back
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With