File "RemoveBuiltinMethodsThatAreFinalPass.php"
Full Path: /home/fundopuh/trader.fxex.org/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/RemoveBuiltinMethodsThatAreFinalPass.php
File size: 1.31 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/**
* Mockery (https://docs.mockery.io/)
*
* @copyright https://github.com/mockery/mockery/blob/HEAD/COPYRIGHT.md
* @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License
* @link https://github.com/mockery/mockery for the canonical source repository
*/
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',
'__toString' => '/public function __toString\(\)\s+(:\s+string)?\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;
}
}