Re: ReflectionClass::newInstanceWithoutConstructor()

From: Date: Fri, 26 Aug 2011 07:51:05 +0000
Subject: Re: ReflectionClass::newInstanceWithoutConstructor()
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Thu, Aug 25, 2011 at 11:46 AM, Sebastian Bergmann <[email protected]> wrote:
>  I have attached a patch to https://bugs.php.net/bug.php?id=55490 that
>  implements ReflectionClass::newInstanceWithoutConstructor() to create an
>  object a class without invoking the constructor.
>
>  As there are certain internal classes that would "crash" when their
>  constructor is not invoked, this new method of the Reflection API only
>  works for userland-defined classes.
>
>  Unless there are objections, I will commit this change to PHP_5_4 and
>  trunk on Monday. I will add the method to the documentation as well, of
>  course.
>
> --
> Sebastian Bergmann                    Co-Founder and Principal Consultant
> http://sebastian-bergmann.de/              
>             http://thePHP.cc/
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

hi Sebastian,

would this method give the same result as
unserialize("O:8:\"stdClass\":0:{}")  for example?
I used this trick in the past when I needed to instantiate a class
without calling it's constructor.
of course having a dedicated method for this is much more convenient

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu


Thread (23 messages)

« previous php.internals (#54968) next »