[FrameworkBundle][Console][EventDispatcher] Fixed debug:event command

This commit is contained in:
Grégoire Pineau 2017-04-13 18:04:25 +02:00
parent 4f0daa740a
commit 9960b7e1d4
5 changed files with 22 additions and 4 deletions

View File

@ -311,4 +311,15 @@ abstract class Descriptor implements DescriptorInterface
return $serviceIds;
}
protected function formatClosure(\Closure $closure)
{
$r = new \ReflectionFunction($closure);
if (preg_match('#^/\*\* @closure-proxy ([^: ]++)::([^: ]++) \*/$#', $r->getDocComment(), $m)) {
return sprintf('%s::%s', $m[1], $m[2]);
}
return 'closure';
}
}

View File

@ -363,7 +363,7 @@ class JsonDescriptor extends Descriptor
}
if ($callable instanceof \Closure) {
$data['type'] = 'closure';
$data['type'] = $this->formatClosure($callable);
return $data;
}

View File

@ -343,7 +343,8 @@ class MarkdownDescriptor extends Descriptor
}
if ($callable instanceof \Closure) {
$string .= "\n- Type: `closure`";
$formatted = $this->formatClosure($callable);
$string .= "\n- Type: `$formatted`";
return $this->write($string."\n");
}

View File

@ -466,7 +466,13 @@ class TextDescriptor extends Descriptor
}
if ($callable instanceof \Closure) {
return '\Closure()';
$formatted = $this->formatClosure($callable);
if ('closure' === $formatted) {
return '\Closure()';
}
return $formatted.'()';
}
if (method_exists($callable, '__invoke')) {

View File

@ -593,7 +593,7 @@ class XmlDescriptor extends Descriptor
}
if ($callable instanceof \Closure) {
$callableXML->setAttribute('type', 'closure');
$callableXML->setAttribute('type', $this->formatClosure($callable));
return $dom;
}