/usr/share/php/Mockery/Generator/StringManipulation/Pass/RemoveBuiltinMethodsThatAreFinalPass.php is in php-mockery 0.9.4-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <?php
namespace Mockery\Generator\StringManipulation\Pass;
use Mockery\Generator\MockConfiguration;
/**
* The standard Mockery\Mock class includes some methods to ease mocking, such
* as __wakeup, however if the target has a final __wakeup method, it can't be
* mocked. This pass removes the builtin methods where they are final on the
* target
*/
class RemoveBuiltinMethodsThatAreFinalPass
{
protected $methods = array(
'__wakeup' => '/public function __wakeup\(\)\s+\{.*?\}/sm',
);
public function apply($code, MockConfiguration $config)
{
$target = $config->getTargetClass();
if (!$target) {
return $code;
}
foreach ($target->getMethods() as $method) {
if ($method->isFinal() && isset($this->methods[$method->getName()])) {
$code = preg_replace($this->methods[$method->getName()], '', $code);
}
}
return $code;
}
}
|