function ExpectDeprecationTrait::getCallableName

Returns a callable as a string suitable for inclusion in a message.

Parameters

callable $callable: The callable.

Return value

string The string suitable for inclusion in a message.

See also

https://stackoverflow.com/questions/34324576/print-name-or-definition-o…

1 call to ExpectDeprecationTrait::getCallableName()
ExpectDeprecationTrait::tearDownErrorHandler in core/tests/Drupal/TestTools/Extension/DeprecationBridge/ExpectDeprecationTrait.php
Tears down the test error handler.

File

core/tests/Drupal/TestTools/Extension/DeprecationBridge/ExpectDeprecationTrait.php, line 111

Class

ExpectDeprecationTrait
A trait to include in Drupal tests to manage expected deprecations.

Namespace

Drupal\TestTools\Extension\DeprecationBridge

Code

private static function getCallableName(callable $callable) : string {
    switch (TRUE) {
        case is_string($callable) && strpos($callable, '::'):
            return '[static] ' . $callable;
        case is_string($callable):
            return '[function] ' . $callable;
        case is_array($callable) && is_object($callable[0]):
            return '[method] ' . get_class($callable[0]) . '->' . $callable[1];
        case is_array($callable):
            return '[static] ' . $callable[0] . '::' . $callable[1];
        case $callable instanceof \Closure:
            return '[closure]';
        case is_object($callable):
            return '[invokable] ' . get_class($callable);
        default:
            return '[unknown]';
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.