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

Breadcrumb

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

function TraversablePatch::apply

Forces class to implement Iterator interface.

Parameters

ClassNode $node:

Overrides ClassPatchInterface::apply

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/ClassPatch/TraversablePatch.php, line 64

Class

TraversablePatch
Traversable interface patch. Forces classes that implement interfaces, that extend Traversable to also implement Iterator.

Namespace

Prophecy\Doubler\ClassPatch

Code

public function apply(ClassNode $node) {
    $node->addInterface('Iterator');
    $currentMethod = new MethodNode('current');
    \PHP_VERSION_ID >= 80100 && $currentMethod->setReturnTypeNode(new ReturnTypeNode('mixed'));
    $node->addMethod($currentMethod);
    $keyMethod = new MethodNode('key');
    \PHP_VERSION_ID >= 80100 && $keyMethod->setReturnTypeNode(new ReturnTypeNode('mixed'));
    $node->addMethod($keyMethod);
    $nextMethod = new MethodNode('next');
    \PHP_VERSION_ID >= 80100 && $nextMethod->setReturnTypeNode(new ReturnTypeNode('void'));
    $node->addMethod($nextMethod);
    $rewindMethod = new MethodNode('rewind');
    \PHP_VERSION_ID >= 80100 && $rewindMethod->setReturnTypeNode(new ReturnTypeNode('void'));
    $node->addMethod($rewindMethod);
    $validMethod = new MethodNode('valid');
    \PHP_VERSION_ID >= 80100 && $validMethod->setReturnTypeNode(new ReturnTypeNode('bool'));
    $node->addMethod($validMethod);
}

API Navigation

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