Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SplFileInfoPatch.php

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\ClassPatch

Code

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();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal