public static function Variable::callableToString in Drupal 9
Same name and namespace in other branches
- 10 core/lib/Drupal/Component/Utility/Variable.php \Drupal\Component\Utility\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.
4 calls to Variable::callableToString()
- Datetime::processDatetime in core/
lib/ Drupal/ Core/ Datetime/ Element/ Datetime.php - Expands a datetime element type into date and/or time elements.
- DatetimeElementFormTest::providerUntrusted in core/
tests/ Drupal/ KernelTests/ Core/ Datetime/ DatetimeElementFormTest.php - Data provider for ::testDatetimeElementUntrustedCallbacks().
- Renderer::doRender in core/
lib/ Drupal/ Core/ Render/ Renderer.php - See the docs for ::render().
- VariableTest::testCallableToString in core/
tests/ Drupal/ Tests/ Component/ Utility/ VariableTest.php - Tests generating a human-readable name for a callable.
File
- core/
lib/ Drupal/ Component/ Utility/ Variable.php, line 21
Class
- Variable
- Provides helpers for dealing with variables.
Namespace
Drupal\Component\UtilityCode
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]';
}
}