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

Breadcrumb

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

function ReflectionCaster::castClosure

1 call to ReflectionCaster::castClosure()
CutStub::__construct in vendor/symfony/var-dumper/Caster/CutStub.php

File

vendor/symfony/var-dumper/Caster/ReflectionCaster.php, line 38

Class

ReflectionCaster
Casts Reflector related classes to array representation.

Namespace

Symfony\Component\VarDumper\Caster

Code

public static function castClosure(\Closure $c, array $a, Stub $stub, bool $isNested, int $filter = 0) : array {
    $prefix = Caster::PREFIX_VIRTUAL;
    $c = new \ReflectionFunction($c);
    $a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter);
    if (!$c->isAnonymous()) {
        $stub->class = isset($a[$prefix . 'class']) ? $a[$prefix . 'class']->value . '::' . $c->name : $c->name;
        unset($a[$prefix . 'class']);
    }
    unset($a[$prefix . 'extra']);
    $stub->class .= self::getSignature($a);
    if ($f = $c->getFileName()) {
        $stub->attr['file'] = $f;
        $stub->attr['line'] = $c->getStartLine();
    }
    unset($a[$prefix . 'parameters']);
    if ($filter & Caster::EXCLUDE_VERBOSE) {
        $stub->cut += ($c->getFileName() ? 2 : 0) + \count($a);
        return [];
    }
    if ($f) {
        $a[$prefix . 'file'] = new LinkStub($f, $c->getStartLine());
        $a[$prefix . 'line'] = $c->getStartLine() . ' to ' . $c->getEndLine();
    }
    return $a;
}

API Navigation

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