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/

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

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

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

2011-08-25 Thread Patrick ALLAERT
2011/8/25 Patrick ALLAERT : > 2011/8/25 Gustavo Lopes : >> 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 opinion that not making distinction and

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

2011-08-25 Thread Patrick ALLAERT
2011/8/25 Gustavo Lopes : > 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 if > the internal cla

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 wrote: > Thanks for working on this Sebastian, its really appreciated! +1 from me! > > On Thu, Aug 25, 2011 at 3:27 PM, Sebastian Bergmann wrote

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 wrote: > 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

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 occurring

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

2011-08-25 Thread Gustavo Lopes
On Thu, 25 Aug 2011 13:41:27 +0100, Sebastian Bergmann 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 so on. I think you

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

2011-08-25 Thread Etienne Kneuss
On Thu, Aug 25, 2011 at 14:54, Etienne Kneuss wrote: > Hi, > > On Thu, Aug 25, 2011 at 14:49, Sebastian Bergmann 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 acco

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

2011-08-25 Thread Etienne Kneuss
Hi, On Thu, Aug 25, 2011 at 14:49, Sebastian Bergmann 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 dont-crash-without-calli

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

2011-08-25 Thread Pierre Joye
On Thu, Aug 25, 2011 at 2:41 PM, Sebastian Bergmann 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, -- Pierre @p

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

2011-08-25 Thread Etienne Kneuss
Hi, On Thu, Aug 25, 2011 at 14:43, Sebastian Bergmann 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 programming, of co

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 inst

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

2011-08-25 Thread Kalle Sommer Nielsen
Hi 2011/8/25 Sebastian Bergmann : >  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 could do like that of

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 ca

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/ http://th

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

2011-08-25 Thread Etienne Kneuss
Hi, On Thu, Aug 25, 2011 at 11:46, Sebastian Bergmann 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 makes no sense.

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 Richard Quadling
On 25 August 2011 10:46, Sebastian Bergmann 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 tha

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

2011-08-25 Thread Patrick ALLAERT
2011/8/25 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

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

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

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

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

[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