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

Breadcrumb

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

function Variable::callableToString

Generates a human-readable name for a callable.

Parameters

callable $callable: A callable.

Return value

string A human-readable name for the callable.

3 calls to Variable::callableToString()
Datelist::processDatelist in core/lib/Drupal/Core/Datetime/Element/Datelist.php
Expands a date element into an array of individual elements.
Datetime::processDatetime in core/lib/Drupal/Core/Datetime/Element/Datetime.php
Expands a datetime element type into date and/or time elements.
Renderer::doRender in core/lib/Drupal/Core/Render/Renderer.php
See the docs for ::render().

File

core/lib/Drupal/Component/Utility/Variable.php, line 21

Class

Variable
Provides helpers for dealing with variables.

Namespace

Drupal\Component\Utility

Code

public static function callableToString($callable) : string {
    if ($callable instanceof \Closure) {
        return '[closure]';
    }
    elseif (is_array($callable) && $callable) {
        if (is_object($callable[0])) {
            $callable[0] = get_class($callable[0]);
        }
        return implode('::', $callable);
    }
    elseif (is_string($callable)) {
        return $callable;
    }
    else {
        return '[unknown]';
    }
}

API Navigation

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