You are here

class ReflectionClassNewInstancePatch in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ReflectionClassNewInstancePatch.php \Prophecy\Doubler\ClassPatch\ReflectionClassNewInstancePatch

ReflectionClass::newInstance patch. Makes first argument of newInstance optional, since it works but signature is misleading

@author Florian Klein <florian.klein@free.fr>

Hierarchy

Expanded class hierarchy of ReflectionClassNewInstancePatch

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/ReflectionClassNewInstancePatch.php, line 22

Namespace

Prophecy\Doubler\ClassPatch
View source
class ReflectionClassNewInstancePatch implements ClassPatchInterface {

  /**
   * Supports ReflectionClass
   *
   * @param ClassNode $node
   *
   * @return bool
   */
  public function supports(ClassNode $node) {
    return 'ReflectionClass' === $node
      ->getParentClass();
  }

  /**
   * Updates newInstance's first argument to make it optional
   *
   * @param ClassNode $node
   */
  public function apply(ClassNode $node) {
    foreach ($node
      ->getMethod('newInstance')
      ->getArguments() as $argument) {
      $argument
        ->setDefault(null);
    }
  }

  /**
   * Returns patch priority, which determines when patch will be applied.
   *
   * @return int Priority number (higher = earlier)
   */
  public function getPriority() {
    return 50;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ReflectionClassNewInstancePatch::apply public function Updates newInstance's first argument to make it optional Overrides ClassPatchInterface::apply
ReflectionClassNewInstancePatch::getPriority public function Returns patch priority, which determines when patch will be applied. Overrides ClassPatchInterface::getPriority
ReflectionClassNewInstancePatch::supports public function Supports ReflectionClass Overrides ClassPatchInterface::supports