Re: Does ReflectionMethod::setAccessible() do anything?
| From: | David Harkness | Date: | Mon, 20 Dec 2010 22:14:03 +0000 |
| Subject: | Re: Does ReflectionMethod::setAccessible() do anything? | ||
| References: | 1 2 | Groups: | php.general php.general php.general |
| Request: | Send a blank email to php-general+get-310163@lists.php.net to get a copy of this message | ||
On Thu, Dec 16, 2010 at 6:09 PM, Nathan Nobbe <quickshiftin@gmail.com>wrote:
> you just have to invoke the function from the context of the
> ReflectionMethod instance
>
> <?php
> class Foo { protected function bar() { echo "foobar\n"; } }
> $m = new ReflectionMethod('Foo', 'bar');
> $m->setAccessible(true);
> $m->invokeArgs(new Foo(), array());
> ?>
>
Thank you, Nathan. That makes perfect sense and would be a good addition to
the documentation page for setAccessible(). Even better, I may even be able
to make use of it in my testing framework since I only want the method to be
exposed for one call from the test method.
David
--
David Harkness
Senior Software Engineer
High Gear Media