Skip to content

Commit 4926e92

Browse files
Merge branch '4.1'
* 4.1: [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 4.1.8 updated VERSION for 4.1.7 updated CHANGELOG for 4.1.7 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 14850d9 + d057bd5 commit 4926e92

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
@@ -83,8 +83,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
8383
array('Architecture', (PHP_INT_SIZE * 8).' bits'),
8484
array('Intl locale', class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'),
8585
array('Timezone', date_default_timezone_get().' (<comment>'.(new \DateTime())->format(\DateTime::W3C).'</>)'),
86-
array('OPcache', \extension_loaded('Zend OPcache') && ini_get('opcache.enable') ? 'true' : 'false'),
87-
array('APCu', \extension_loaded('apcu') && ini_get('apc.enabled') ? 'true' : 'false'),
86+
array('OPcache', \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
87+
array('APCu', \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'true' : 'false'),
8888
array('Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'),
8989
);
9090

Console/Descriptor/JsonDescriptor.php

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

347+
$r = new \ReflectionFunction($callable);
348+
if (false !== strpos($r->name, '{closure}')) {
349+
return $data;
350+
}
351+
$data['name'] = $r->name;
352+
353+
$class = ($class = $r->getClosureThis()) ? \get_class($class) : null;
354+
if ($scopeClass = $r->getClosureScopeClass() ?: $class) {
355+
$data['class'] = $scopeClass;
356+
if (!$class) {
357+
$data['static'] = true;
358+
}
359+
}
360+
347361
return $data;
348362
}
349363

Console/Descriptor/MarkdownDescriptor.php

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

356+
$r = new \ReflectionFunction($callable);
357+
if (false !== strpos($r->name, '{closure}')) {
358+
return $this->write($string."\n");
359+
}
360+
$string .= "\n".sprintf('- Name: `%s`', $r->name);
361+
362+
$class = ($class = $r->getClosureThis()) ? \get_class($class) : null;
363+
if ($scopeClass = $r->getClosureScopeClass() ?: $class) {
364+
$string .= "\n".sprintf('- Class: `%s`', $class);
365+
if (!$class) {
366+
$string .= "\n- Static: yes";
367+
}
368+
}
369+
356370
return $this->write($string."\n");
357371
}
358372

Console/Descriptor/TextDescriptor.php

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

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

6863
$tableRows[] = $row;
@@ -464,7 +459,18 @@ private function formatCallable($callable): string
464459
}
465460

466461
if ($callable instanceof \Closure) {
467-
return '\Closure()';
462+
$r = new \ReflectionFunction($callable);
463+
if (false !== strpos($r->name, '{closure}')) {
464+
return 'Closure()';
465+
}
466+
if ($class = $r->getClosureScopeClass()) {
467+
return sprintf('%s::%s()', $class, $r->name);
468+
}
469+
if ($class = $r->getClosureThis()) {
470+
return sprintf('%s::%s()', \get_class($class), $r->name);
471+
}
472+
473+
return $r->name.'()';
468474
}
469475

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

Console/Descriptor/XmlDescriptor.php

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

527+
$r = new \ReflectionFunction($callable);
528+
if (false !== strpos($r->name, '{closure}')) {
529+
return $dom;
530+
}
531+
$callableXML->setAttribute('name', $r->name);
532+
533+
$class = ($class = $r->getClosureThis()) ? \get_class($class) : null;
534+
if ($scopeClass = $r->getClosureScopeClass() ?: $class) {
535+
$callableXML->setAttribute('class', $class);
536+
if (!$class) {
537+
$callableXML->setAttribute('static', 'true');
538+
}
539+
}
540+
527541
return $dom;
528542
}
529543

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)