You are here

public function SplFileInfoPatch::apply in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/SplFileInfoPatch.php \Prophecy\Doubler\ClassPatch\SplFileInfoPatch::apply()

Updated constructor code to call parent one with dummy file argument.

Parameters

ClassNode $node:

Overrides ClassPatchInterface::apply

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/SplFileInfoPatch.php, line 48

Class

SplFileInfoPatch
SplFileInfo patch. Makes SplFileInfo and derivative classes usable with Prophecy.

Namespace

Prophecy\Doubler\ClassPatch

Code

public function apply(ClassNode $node) {
  if ($node
    ->hasMethod('__construct')) {
    $constructor = $node
      ->getMethod('__construct');
  }
  else {
    $constructor = new MethodNode('__construct');
    $node
      ->addMethod($constructor);
  }
  if ($this
    ->nodeIsDirectoryIterator($node)) {
    $constructor
      ->setCode('return parent::__construct("' . __DIR__ . '");');
    return;
  }
  $constructor
    ->useParentCode();
}