Skip to content

Commit 1674f92

Browse files
bug symfony#22422 [FrameworkBundle][Console][EventDispatcher] Fixed debug:event command (lyrixx)
This PR was merged into the 3.3-dev branch. Discussion ---------- [FrameworkBundle][Console][EventDispatcher] Fixed debug:event command | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - --- before: ![screenshot5](https://cloud.githubusercontent.com/assets/408368/25013888/bcd561ba-2075-11e7-8538-b977420640d2.png) after: ![screenshot6](https://cloud.githubusercontent.com/assets/408368/25013894/c2bc9332-2075-11e7-97f6-ebfcca70b23b.png) Commits ------- 9960b7e [FrameworkBundle][Console][EventDispatcher] Fixed debug:event command
2 parents b72c11f + 9960b7e commit 1674f92

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,15 @@ protected function sortServiceIds(array $serviceIds)
311311

312312
return $serviceIds;
313313
}
314+
315+
protected function formatClosure(\Closure $closure)
316+
{
317+
$r = new \ReflectionFunction($closure);
318+
319+
if (preg_match('#^/\*\* @closure-proxy ([^: ]++)::([^: ]++) \*/$#', $r->getDocComment(), $m)) {
320+
return sprintf('%s::%s', $m[1], $m[2]);
321+
}
322+
323+
return 'closure';
324+
}
314325
}

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private function getCallableData($callable, array $options = array())
363363
}
364364

365365
if ($callable instanceof \Closure) {
366-
$data['type'] = 'closure';
366+
$data['type'] = $this->formatClosure($callable);
367367

368368
return $data;
369369
}

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ protected function describeCallable($callable, array $options = array())
343343
}
344344

345345
if ($callable instanceof \Closure) {
346-
$string .= "\n- Type: `closure`";
346+
$formatted = $this->formatClosure($callable);
347+
$string .= "\n- Type: `$formatted`";
347348

348349
return $this->write($string."\n");
349350
}

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,13 @@ private function formatCallable($callable)
466466
}
467467

468468
if ($callable instanceof \Closure) {
469-
return '\Closure()';
469+
$formatted = $this->formatClosure($callable);
470+
471+
if ('closure' === $formatted) {
472+
return '\Closure()';
473+
}
474+
475+
return $formatted.'()';
470476
}
471477

472478
if (method_exists($callable, '__invoke')) {

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ private function getCallableDocument($callable)
593593
}
594594

595595
if ($callable instanceof \Closure) {
596-
$callableXML->setAttribute('type', 'closure');
596+
$callableXML->setAttribute('type', $this->formatClosure($callable));
597597

598598
return $dom;
599599
}

0 commit comments

Comments
 (0)