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

Breadcrumb

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

function LazyDouble::addInterface

Tells doubler to implement specific interface with double.

@template U of object @phpstan-param class-string<U>|ReflectionClass<U> $interface @phpstan-this-out static<T&U>

Parameters

class-string|ReflectionClass<object> $interface:

Return value

void

Throws

InterfaceNotFoundException

DoubleException

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/LazyDouble.php, line 99

Class

LazyDouble
Lazy double. Gives simple interface to describe double before creating it.

Namespace

Prophecy\Doubler

Code

public function addInterface($interface) {
    if (null !== $this->double) {
        throw new DoubleException('Can not implement interface with already instantiated double.');
    }
    if (!$interface instanceof ReflectionClass) {
        if (!interface_exists($interface)) {
            throw new InterfaceNotFoundException(sprintf('Interface %s not found.', $interface), $interface);
        }
        $interface = new ReflectionClass($interface);
    }
    $this->interfaces[] = $interface;
}

API Navigation

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