| 1 | <?php |
||
| 11 | final class AnyMatcher extends AbstractMatcher |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var array |
||
| 15 | */ |
||
| 16 | private static $builtinMethods = []; |
||
| 17 | |||
| 18 | 30 | public function __construct() |
|
| 19 | { |
||
| 20 | 30 | if (self::$builtinMethods === []) { |
|
| 21 | 1 | $this->setBuildInMethods(); |
|
| 22 | 1 | } |
|
| 23 | 30 | } |
|
| 24 | |||
| 25 | 1 | private function setBuildInMethods() |
|
| 26 | { |
||
| 27 | 1 | $methods = (new \ReflectionClass('\ArrayObject'))->getMethods(); |
|
| 28 | 1 | foreach ($methods as $method) { |
|
| 29 | 1 | self::$builtinMethods[] = $method->getName(); |
|
| 30 | 1 | } |
|
| 31 | 1 | } |
|
| 32 | |||
| 33 | /** |
||
| 34 | * {@inheritdoc} |
||
| 35 | */ |
||
| 36 | 26 | public function matchesClass(\ReflectionClass $class, array $arguments) |
|
| 40 | |||
| 41 | /** |
||
| 42 | * {@inheritdoc} |
||
| 43 | */ |
||
| 44 | 5 | public function matchesMethod(\ReflectionMethod $method, array $arguments) |
|
| 45 | { |
||
| 46 | 5 | unset($arguments); |
|
| 47 | |||
| 48 | 5 | return ! ($this->isMagicMethod($method->name) || $this->isBuiltinMethod($method->name)); |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param string $name |
||
| 53 | * |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | 5 | private function isMagicMethod($name) |
|
| 60 | |||
| 61 | /** |
||
| 62 | * @param string $name |
||
| 63 | * |
||
| 64 | * @return bool |
||
| 65 | */ |
||
| 66 | 5 | private function isBuiltinMethod($name) |
|
| 72 | } |
||
| 73 |