Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-26 Thread Ferenc Kovacs
On Thu, Aug 25, 2011 at 11:46 AM, Sebastian Bergmann sebast...@php.net 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

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-26 Thread Sebastian Bergmann
Am 26.08.2011 09:51, schrieb Ferenc Kovacs: would this method give the same result as unserialize(O:8:\stdClass\:0:{}) for example? That is the whole point of it, yes. -- Sebastian BergmannCo-Founder and Principal Consultant http://sebastian-bergmann.de/

[PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Sebastian Bergmann
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

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Pierre Joye
hi, On Thu, Aug 25, 2011 at 11:46 AM, Sebastian Bergmann sebast...@php.net 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

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Gustavo Lopes
On Thu, 25 Aug 2011 10:46:21 +0100, Sebastian Bergmann sebast...@php.net 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

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Patrick ALLAERT
2011/8/25 Sebastian Bergmann sebast...@php.net:  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

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Richard Quadling
On 25 August 2011 10:46, Sebastian Bergmann sebast...@php.net 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

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Sebastian Bergmann
On 08/25/2011 02:26 PM, Richard Quadling wrote: Wouldn't ReflectionClass::newMockInstance() be a better name? It is not specific to stubbing/mocking. What other use cases exists? ORM and stubbing/mocking should be enough. -- Sebastian BergmannCo-Founder and Principal

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Etienne Kneuss
Hi, On Thu, Aug 25, 2011 at 11:46, Sebastian Bergmann sebast...@php.net 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. To me this feature

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Sebastian Bergmann
On 08/25/2011 01:46 PM, Gustavo Lopes wrote: What about userland classes that extend internal classes? Good point. How would I implement such a check? -- Sebastian BergmannCo-Founder and Principal Consultant http://sebastian-bergmann.de/

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Sebastian Bergmann
On 08/25/2011 02:39 PM, Etienne Kneuss wrote: To me this feature makes no sense. But if people find use for it and it remains in Reflection, I won't object to it, so +0. It should only be used for meta programming, of course ;-) If an internal class can't behave well without a constructor

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Kalle Sommer Nielsen
Hi 2011/8/25 Sebastian Bergmann sebast...@php.net:  Good point. How would I implement such a check? Speaking of which, wouldn't it be easier to check all our internal classes for such failures and fix them accordingly with this addition (Fix the dont-crash-without-calling-constructor)? We

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Sebastian Bergmann
On 08/25/2011 02:47 PM, Kalle Sommer Nielsen wrote: Speaking of which, wouldn't it be easier to check all our internal classes for such failures and fix them accordingly with this addition (Fix the dont-crash-without-calling-constructor)? We could do like that of above and cast an exception

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Etienne Kneuss
Hi, On Thu, Aug 25, 2011 at 14:43, Sebastian Bergmann sebast...@php.net wrote: On 08/25/2011 02:39 PM, Etienne Kneuss wrote: To me this feature makes no sense. But if people find use for it and it remains in Reflection, I won't object to it, so +0.  It should only be used for meta

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Pierre Joye
On Thu, Aug 25, 2011 at 2:41 PM, Sebastian Bergmann sebast...@php.net wrote: On 08/25/2011 01:46 PM, Gustavo Lopes wrote: What about userland classes that extend internal classes?  Good point. How would I implement such a check? Checking the same thing than what instanceof does Cheers, --

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Etienne Kneuss
Hi, On Thu, Aug 25, 2011 at 14:49, Sebastian Bergmann sebast...@php.net wrote: On 08/25/2011 02:47 PM, Kalle Sommer Nielsen wrote: Speaking of which, wouldn't it be easier to check all our internal classes for such failures and fix them accordingly with this addition (Fix the

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Etienne Kneuss
On Thu, Aug 25, 2011 at 14:54, Etienne Kneuss col...@php.net wrote: Hi, On Thu, Aug 25, 2011 at 14:49, Sebastian Bergmann sebast...@php.net wrote: On 08/25/2011 02:47 PM, Kalle Sommer Nielsen wrote: Speaking of which, wouldn't it be easier to check all our internal classes for such failures

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Gustavo Lopes
On Thu, 25 Aug 2011 13:41:27 +0100, Sebastian Bergmann sebast...@php.net wrote: On 08/25/2011 01:46 PM, Gustavo Lopes wrote: What about userland classes that extend internal classes? Good point. How would I implement such a check? You could fetch the parent and do the same check, and

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Sebastian Bergmann
On 08/25/2011 02:54 PM, Gustavo Lopes wrote: You could fetch the parent and do the same check, and so on. I think you might be able to just check whether ce.create_object is not NULL, because if the internal class doesn't replace create_object, there's no chance of that class of crashes

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Benjamin Eberlei
Thanks for working on this Sebastian, its really appreciated! +1 from me! On Thu, Aug 25, 2011 at 3:27 PM, Sebastian Bergmann sebast...@php.netwrote: On 08/25/2011 02:54 PM, Gustavo Lopes wrote: You could fetch the parent and do the same check, and so on. I think you might be able to just

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread guilhermebla...@gmail.com
Sebastian, This is a hidden gem for us! =D Thanks a lot for putting your effort into this. Cheers, On Thu, Aug 25, 2011 at 11:03 AM, Benjamin Eberlei kont...@beberlei.de wrote: Thanks for working on this Sebastian, its really appreciated! +1 from me! On Thu, Aug 25, 2011 at 3:27 PM,

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Patrick ALLAERT
2011/8/25 Gustavo Lopes glo...@nebm.ist.utl.pt: You could fetch the parent and do the same check, and so on. Checking only the topmost should be enough if traversing the whole inheritance could be avoided. I think you might be able to just check whether ce.create_object is not NULL, because

Re: [PHP-DEV] ReflectionClass::newInstanceWithoutConstructor()

2011-08-25 Thread Patrick ALLAERT
2011/8/25 Patrick ALLAERT patrickalla...@php.net: 2011/8/25 Gustavo Lopes glo...@nebm.ist.utl.pt: You could fetch the parent and do the same check, and so on. Checking only the topmost should be enough if traversing the whole inheritance could be avoided. Well, of course I highly second the