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

Breadcrumb

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

function TraversablePatch::supports

Supports nodetree, that implement Traversable, but not Iterator or IteratorAggregate.

Parameters

ClassNode $node:

Return value

bool

Overrides ClassPatchInterface::supports

File

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

Class

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

Namespace

Prophecy\Doubler\ClassPatch

Code

public function supports(ClassNode $node) {
    if (in_array('Iterator', $node->getInterfaces())) {
        return false;
    }
    if (in_array('IteratorAggregate', $node->getInterfaces())) {
        return false;
    }
    foreach ($node->getInterfaces() as $interface) {
        if ('Traversable' !== $interface && !is_subclass_of($interface, 'Traversable')) {
            continue;
        }
        if ('Iterator' === $interface || is_subclass_of($interface, 'Iterator')) {
            continue;
        }
        if ('IteratorAggregate' === $interface || is_subclass_of($interface, 'IteratorAggregate')) {
            continue;
        }
        return true;
    }
    return false;
}

API Navigation

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