Technically, you can use private and protected methods using the reflection API. However, 99% of the time is a really bad idea. If you can change the class, then the right solution will probably just make this method publicly available. In the end, if you need to access it outside the class, this will cause its mark to be protected.
Here is an example of a quick reflection, if this is one of the very few situations when it is really necessary:
<?php class foo { protected function bar($param){ echo $param; } } $r = new ReflectionMethod('foo', 'bar'); $r->setAccessible(true); $r->invoke(new foo(), "Hello World");
source share