4 * This file is part of the Prophecy.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6 * Marcello Duarte <marcello.duarte@gmail.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Prophecy\Doubler\ClassPatch;
14 use Prophecy\Doubler\Generator\Node\ClassNode;
17 * ReflectionClass::newInstance patch.
18 * Makes first argument of newInstance optional, since it works but signature is misleading
20 * @author Florian Klein <florian.klein@free.fr>
22 class ReflectionClassNewInstancePatch implements ClassPatchInterface
25 * Supports ReflectionClass
27 * @param ClassNode $node
31 public function supports(ClassNode $node)
33 return 'ReflectionClass' === $node->getParentClass();
37 * Updates newInstance's first argument to make it optional
39 * @param ClassNode $node
41 public function apply(ClassNode $node)
43 foreach ($node->getMethod('newInstance')->getArguments() as $argument) {
44 $argument->setDefault(null);
49 * Returns patch priority, which determines when patch will be applied.
51 * @return int Priority number (higher = earlier)
53 public function getPriority()