function 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 44
Class
- SplFileInfoPatch
- SplFileInfo patch. Makes SplFileInfo and derivative classes usable with Prophecy.
Namespace
Prophecy\Doubler\ClassPatchCode
public function apply(ClassNode $node) {
if ($node->hasMethod('__construct')) {
$constructor = $node->getMethod('__construct');
\assert($constructor !== null);
}
else {
$constructor = new MethodNode('__construct');
$node->addMethod($constructor);
}
if ($this->nodeIsDirectoryIterator($node)) {
$constructor->setCode('return parent::__construct("' . __DIR__ . '");');
return;
}
if ($this->nodeIsSplFileObject($node)) {
$filePath = str_replace('\\', '\\\\', __FILE__);
$constructor->setCode('return parent::__construct("' . $filePath . '");');
return;
}
if ($this->nodeIsSymfonySplFileInfo($node)) {
$filePath = str_replace('\\', '\\\\', __FILE__);
$constructor->setCode('return parent::__construct("' . $filePath . '", "", "");');
return;
}
$constructor->useParentCode();
}