Skip to content

Commit d057bd5

Browse files
Merge branch '3.4' into 4.1
* 3.4: [VarDumper] fix dump of closures created from callables [DI] fix dumping inlined services Add framework asset changes to upgrade 3.0 guide [Travis] Bump ext-mongodb to 1.5.2 on Travis [DI] dont track classes/interfaces used to compute autowiring error messages [DI] fix GraphvizDumper ignoring inline definitions bumped Symfony version to 3.4.19 updated VERSION for 3.4.18 updated CHANGELOG for 3.4.18 bumped Symfony version to 2.8.48 updated VERSION for 2.8.47 update CONTRIBUTORS for 2.8.47 updated CHANGELOG for 2.8.47 Fix ini_get() for boolean values
2 parents 5f05a52 + 01cb93f commit d057bd5

File tree

8 files changed

+60
-12
lines changed

8 files changed

+60
-12
lines changed

Command/AboutCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
8585
array('Architecture', (PHP_INT_SIZE * 8).' bits'),
8686
array('Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'),
8787
array('Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'),
88-
array('OPcache', \extension_loaded('Zend OPcache') && ini_get('opcache.enable') ? 'true' : 'false'),
89-
array('APCu', \extension_loaded('apcu') && ini_get('apc.enabled') ? 'true' : 'false'),
88+
array('OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
89+
array('APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
9090
array('Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'),
9191
);
9292

Console/Descriptor/JsonDescriptor.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,20 @@ private function getCallableData($callable, array $options = array()): array
340340
if ($callable instanceof \Closure) {
341341
$data['type'] = 'closure';
342342

343+
$r = new \ReflectionFunction($callable);
344+
if (false !== strpos($r->name, '{closure}')) {
345+
return $data;
346+
}
347+
$data['name'] = $r->name;
348+
349+
$class = ($class = $r->getClosureThis()) ? \get_class($class) : null;
350+
if ($scopeClass = $r->getClosureScopeClass() ?: $class) {
351+
$data['class'] = $scopeClass;
352+
if (!$class) {
353+
$data['static'] = true;
354+
}
355+
}
356+
343357
return $data;
344358
}
345359

Console/Descriptor/MarkdownDescriptor.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,20 @@ protected function describeCallable($callable, array $options = array())
347347
if ($callable instanceof \Closure) {
348348
$string .= "\n- Type: `closure`";
349349

350+
$r = new \ReflectionFunction($callable);
351+
if (false !== strpos($r->name, '{closure}')) {
352+
return $this->write($string."\n");
353+
}
354+
$string .= "\n".sprintf('- Name: `%s`', $r->name);
355+
356+
$class = ($class = $r->getClosureThis()) ? \get_class($class) : null;
357+
if ($scopeClass = $r->getClosureScopeClass() ?: $class) {
358+
$string .= "\n".sprintf('- Class: `%s`', $class);
359+
if (!$class) {
360+
$string .= "\n- Static: yes";
361+
}
362+
}
363+
350364
return $this->write($string."\n");
351365
}
352366

Console/Descriptor/TextDescriptor.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
5656

5757
if ($showControllers) {
5858
$controller = $route->getDefault('_controller');
59-
if ($controller instanceof \Closure) {
60-
$controller = 'Closure';
61-
} elseif (\is_object($controller)) {
62-
$controller = \get_class($controller);
63-
}
64-
$row[] = $controller;
59+
$row[] = $this->formatCallable($controller);
6560
}
6661

6762
$tableRows[] = $row;
@@ -453,7 +448,18 @@ private function formatCallable($callable): string
453448
}
454449

455450
if ($callable instanceof \Closure) {
456-
return '\Closure()';
451+
$r = new \ReflectionFunction($callable);
452+
if (false !== strpos($r->name, '{closure}')) {
453+
return 'Closure()';
454+
}
455+
if ($class = $r->getClosureScopeClass()) {
456+
return sprintf('%s::%s()', $class, $r->name);
457+
}
458+
if ($class = $r->getClosureThis()) {
459+
return sprintf('%s::%s()', \get_class($class), $r->name);
460+
}
461+
462+
return $r->name.'()';
457463
}
458464

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

Console/Descriptor/XmlDescriptor.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,20 @@ private function getCallableDocument($callable): \DOMDocument
518518
if ($callable instanceof \Closure) {
519519
$callableXML->setAttribute('type', 'closure');
520520

521+
$r = new \ReflectionFunction($callable);
522+
if (false !== strpos($r->name, '{closure}')) {
523+
return $dom;
524+
}
525+
$callableXML->setAttribute('name', $r->name);
526+
527+
$class = ($class = $r->getClosureThis()) ? \get_class($class) : null;
528+
if ($scopeClass = $r->getClosureScopeClass() ?: $class) {
529+
$callableXML->setAttribute('class', $class);
530+
if (!$class) {
531+
$callableXML->setAttribute('static', 'true');
532+
}
533+
}
534+
521535
return $dom;
522536
}
523537

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
\Closure()
1+
Closure()

Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
 Order   Callable   Priority 
77
------- ------------------- ----------
88
#1 global_function() 255
9-
#2 \Closure() -1
9+
#2 Closure() -1
1010
------- ------------------- ----------
1111

Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
 Order   Callable   Priority 
1010
------- ------------------- ----------
1111
#1 global_function() 255
12-
#2 \Closure() -1
12+
#2 Closure() -1
1313
------- ------------------- ----------
1414

1515
"event2" event

0 commit comments

Comments
 (0)