Re: [PHP-DEV] Reflection to remove final

2014-08-13 Thread Julien Pauli
On Tue, Aug 12, 2014 at 8:52 PM, Stas Malyshev wrote: > Hi! > >> I've just been looking back at the history of this previous conversation... >> >> http://marc.info/?l=php-internals&m=132673741606531&w=2 >> >> as a mockist tester I'd really REALLY like to see this be possible but I >> can see the p

Re: [PHP-DEV] Reflection to remove final

2014-08-12 Thread Stas Malyshev
Hi! > I've just been looking back at the history of this previous conversation... > > http://marc.info/?l=php-internals&m=132673741606531&w=2 > > as a mockist tester I'd really REALLY like to see this be possible but I > can see the problem with the original patch modifying the actual existing >

Re: [PHP-DEV] Reflection to remove final

2014-08-11 Thread Marco Pivetta
On 11 August 2014 18:44, Chris Wright wrote: > I don't think that it even makes sense to have this as a possibility > for internal classes. > Even leaving everything else outside, I think internal classes should become less magic and more transparent over time. The current "fixing" of internal c

Re: [PHP-DEV] Reflection to remove final

2014-08-11 Thread Chris Wright
On 11 August 2014 17:09, Julien Pauli wrote: > On Mon, Aug 11, 2014 at 12:59 PM, Ferenc Kovacs wrote: >> On Sat, Aug 9, 2014 at 12:35 PM, Tom Oram wrote: >> >>> I've just been looking back at the history of this previous conversation... >>> >>> http://marc.info/?l=php-internals&m=132673741606531

Re: [PHP-DEV] Reflection to remove final

2014-08-11 Thread Julien Pauli
On Mon, Aug 11, 2014 at 12:59 PM, Ferenc Kovacs wrote: > On Sat, Aug 9, 2014 at 12:35 PM, Tom Oram wrote: > >> I've just been looking back at the history of this previous conversation... >> >> http://marc.info/?l=php-internals&m=132673741606531&w=2 >> >> as a mockist tester I'd really REALLY like

Re: [PHP-DEV] Reflection to remove final

2014-08-11 Thread Ferenc Kovacs
On Sat, Aug 9, 2014 at 12:35 PM, Tom Oram wrote: > I've just been looking back at the history of this previous conversation... > > http://marc.info/?l=php-internals&m=132673741606531&w=2 > > as a mockist tester I'd really REALLY like to see this be possible but I > can see the problem with the or

Re: [PHP-DEV] Reflection to remove final

2014-08-11 Thread Chris Wright
On 11 August 2014 11:30, Chris Wright wrote: > Hi Tom > > On 9 August 2014 11:35, Tom Oram wrote: >> I've just been looking back at the history of this previous conversation... >> >> http://marc.info/?l=php-internals&m=132673741606531&w=2 >> >> as a mockist tester I'd really REALLY like to see th

Re: [PHP-DEV] Reflection to remove final

2014-08-11 Thread Marco Pivetta
Hi Tom, On 9 August 2014 12:35, Tom Oram wrote: > Thoughts? > Possible? Probably, yes. I'd actually argue that it may not be a good solution: it seems to me that if you have to resort to this kind of mocking, then someone type-hinted against a concrete implementation, which is a smell. Shouldn

Re: [PHP-DEV] Reflection to remove final

2014-08-11 Thread Chris Wright
Hi Tom On 9 August 2014 11:35, Tom Oram wrote: > I've just been looking back at the history of this previous conversation... > > http://marc.info/?l=php-internals&m=132673741606531&w=2 > > as a mockist tester I'd really REALLY like to see this be possible but I > can see the problem with the orig

Re: [PHP-DEV] Reflection to remove final

2014-08-09 Thread Tom Oram
I've just been looking back at the history of this previous conversation... http://marc.info/?l=php-internals&m=132673741606531&w=2 as a mockist tester I'd really REALLY like to see this be possible but I can see the problem with the original patch modifying the actual existing class. One soluti

Re: [PHP-DEV] Reflection to remove final

2012-01-18 Thread Gustavo Lopes
On Wed, 18 Jan 2012 00:00:09 +0100, Jan Dolecek wrote: This issue seems much more complicated than I thought. We'll need to consider all cases which could cause troubles and have a solution for them. Namely: - rewriting permanent structures for internal classes, which are being kept between r

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Jan Dolecek
This issue seems much more complicated than I thought. We'll need to consider all cases which could cause troubles and have a solution for them. Namely: - rewriting permanent structures for internal classes, which are being kept between requests, must be avoided - races in threading models - re

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Stas Malyshev
Hi! This doesn't seem right. Correct me if I'm wrong: for internal classes, their data structures are allocated permanently, so I'd say the effects of removing the flag would be permanent (i.e., would affect subsequent requests). And for threaded builds this could cause races between the thread

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Gustavo Lopes
On Mon, 16 Jan 2012 19:06:31 +0100, Jan Dolecek wrote: Hi, reflection is a great tool for testing, but it still misses support for mocking classes/methods marked as final. I created a small patch https://gist.github.com/1621839#file_php_finals.patch, examples how to use it https://gist.github.

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Pierre Joye
As it is not that bad for trunk, I think we should wait a bit before commiting this patch, there are still need for discussions and we should give some time to other people to comment the feature (the implementation is trivial as this stage). Sebastian, mind to revert it until we are done with the

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Jan Dolecek
Sebastian, thanks for the commit. But actually as I see the tests, I may have not specified it enough: ReflectionClass::setFinal(false) removes the final from the class, not it's methods. This test case http://svn.php.net/viewvc/php/php-src/trunk/ext/reflection/tests/ReflectionClass_setFinal.phpt

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Jan Dolecek
> Why did you choose to make the argument to setFinal() optional? > setAccessible() doesn't do this. To be honest I didn't check the setAccessible method first. It just seemed natural to me, that $refl->setFinal() makes it final even without true as an argument. Jan Dolecek juzna...@gmail.com --

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Nikita Popov
On Mon, Jan 16, 2012 at 7:06 PM, Jan Dolecek wrote: > Hi, > > reflection is a great tool for testing, but it still misses support > for mocking classes/methods marked as final. I created a small patch > https://gist.github.com/1621839#file_php_finals.patch, examples how to > use it https://gist.gi

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Jan Dolecek
Yes, there always is a reason. But when we test and create mocks, this reasons can go aside. This is the same with ReflectionProperty::setAccessible() etc. They shouldn't be used normally, but in special cases like testing it's necessary. Jan Dolecek juzna...@gmail.com On Tue, Jan 17, 2012 at 2

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Ferenc Kovacs
> > if a class is marked as final, there must be some reason for it to be a > final. > > if you remove the final and extends it, may lead to bad error. > > reflection should always be used with care. -- Ferenc Kovács @Tyr43l - http://tyrael.hu

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Laruence
On Tue, Jan 17, 2012 at 6:22 PM, Sebastian Bergmann wrote: > Am 16.01.2012 19:06, schrieb Jan Dolecek: >> reflection is a great tool for testing, but it still misses support >> for mocking classes/methods marked as final. I created a small patch >> https://gist.github.com/1621839#file_php_finals.p

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Jan Dolecek
setFinal is available for both classes and methods, as shown in example in my gist (https://gist.github.com/1621839#file_final_test.php). This should be enough for all possible mocks, as I discussed it with my friends. It is also possible to remove final, create a mock class and then put it back,

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Sebastian Bergmann
Am 17.01.2012 12:03, schrieb jpauli: > The patch just adds setFinal() to ReflectionClass. > What about ReflectionMethod? From the patch +/* {{{ proto public void ReflectionMethod::setFinal([bool isFinal = true]) + Sets/unsets class as final */ +ZEND_METHOD(reflection_method, setFinal) +/* {{{ p

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Sebastian Bergmann
Am 17.01.2012 12:00, schrieb jpauli: > How didn't we think about that earlier... ? I have had this on a TODO list at the back of my head for a long time; at least since we added setAccessible(). -- Sebastian BergmannCo-Founder and Principal Consultant http://sebastian-bergm

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread jpauli
Just one last word : The patch just adds setFinal() to ReflectionClass. What about ReflectionMethod ? Not very usefull for the mocking purpose, but that would be good for the Reflection API. Julien On Tue, Jan 17, 2012 at 12:00 PM, jpauli wrote: > +1, I like the idea as well. > How didn't we th

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread jpauli
+1, I like the idea as well. How didn't we think about that earlier... ? Julien On Tue, Jan 17, 2012 at 11:54 AM, Sebastian Bergmann wrote: > Am 17.01.2012 11:34, schrieb Pierre Joye: > > Patch looks good, but coding standard. > > If there are no objections, I can fix the CS issue and commit th

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Sebastian Bergmann
Am 17.01.2012 11:34, schrieb Pierre Joye: > Patch looks good, but coding standard. If there are no objections, I can fix the CS issue and commit the patch to trunk. -- Sebastian BergmannCo-Founder and Principal Consultant http://sebastian-bergmann.de/

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Pierre Joye
hi Jan! Patch looks good, but coding standard. Please always use brackets, even for one line condition (if () foo else bar). Cheers, On Mon, Jan 16, 2012 at 7:06 PM, Jan Dolecek wrote: > Hi, > > reflection is a great tool for testing, but it still misses support > for mocking classes/methods m

Re: [PHP-DEV] Reflection to remove final

2012-01-17 Thread Sebastian Bergmann
Am 16.01.2012 19:06, schrieb Jan Dolecek: > reflection is a great tool for testing, but it still misses support > for mocking classes/methods marked as final. I created a small patch > https://gist.github.com/1621839#file_php_finals.patch, examples how to > use it https://gist.github.com/1621839#fi