Last active
January 31, 2019 15:28
-
-
Save SparK-Cruz/237e6f01b37a5ce2d3cff7f39272fe55 to your computer and use it in GitHub Desktop.
PHP Trait to be used for testing when invoking private methods is necessary
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
<?php | |
namespace Test; | |
trait Trespasser | |
{ | |
protected function forceCall($subject, $methodName, ...$parameters) | |
{ | |
$reflection = new \ReflectionMethod($subject, $methodName); | |
$reflection->setAccessible(true); | |
return $reflection->invokeArgs($subject, $parameters); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment