Last active
May 12, 2016 05:41
-
-
Save nguyentienlong/8891835d7a1cd5a8522bd71a8b7d83e6 to your computer and use it in GitHub Desktop.
PHP Test private, protected function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Helper function to call protected method | |
* | |
* @param stdObject $obj | |
* @param string $methodName | |
* @param array[] $args | |
* | |
* @return null | |
*/ | |
protected function callMethod($obj, $methodName, array $args) { | |
$class = new \ReflectionClass($obj); | |
$method = $class->getMethod($methodName); | |
$method->setAccessible(true); | |
return $method->invokeArgs($obj, $args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment