Skip to content

Commit c4179b0

Browse files
Merge branch '4.1'
* 4.1: [Form] Hardened test suite for empty data Bump phpunit XSD version to 5.2 [Fwb][EventDispatcher][HttpKernel] Fix getClosureScopeClass usage to describe callables Add required key attribute
2 parents 31b792f + d7eaae6 commit c4179b0

File tree

10 files changed

+30
-18
lines changed

10 files changed

+30
-18
lines changed

Console/Descriptor/JsonDescriptor.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,9 @@ private function getCallableData($callable, array $options = array()): array
350350
}
351351
$data['name'] = $r->name;
352352

353-
$class = ($class = $r->getClosureThis()) ? \get_class($class) : null;
354-
if ($scopeClass = $r->getClosureScopeClass() ?: $class) {
355-
$data['class'] = $scopeClass;
356-
if (!$class) {
353+
if ($class = $r->getClosureScopeClass()) {
354+
$data['class'] = $class->name;
355+
if (!$r->getClosureThis()) {
357356
$data['static'] = true;
358357
}
359358
}

Console/Descriptor/MarkdownDescriptor.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,9 @@ protected function describeCallable($callable, array $options = array())
359359
}
360360
$string .= "\n".sprintf('- Name: `%s`', $r->name);
361361

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) {
362+
if ($class = $r->getClosureScopeClass()) {
363+
$string .= "\n".sprintf('- Class: `%s`', $class->name);
364+
if (!$r->getClosureThis()) {
366365
$string .= "\n- Static: yes";
367366
}
368367
}

Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,7 @@ private function formatCallable($callable): string
464464
return 'Closure()';
465465
}
466466
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);
467+
return sprintf('%s::%s()', $class->name, $r->name);
471468
}
472469

473470
return $r->name.'()';

Console/Descriptor/XmlDescriptor.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,9 @@ private function getCallableDocument($callable): \DOMDocument
530530
}
531531
$callableXML->setAttribute('name', $r->name);
532532

533-
$class = ($class = $r->getClosureThis()) ? \get_class($class) : null;
534-
if ($scopeClass = $r->getClosureScopeClass() ?: $class) {
535-
$callableXML->setAttribute('class', $class);
536-
if (!$class) {
533+
if ($class = $r->getClosureScopeClass()) {
534+
$callableXML->setAttribute('class', $class->name);
535+
if (!$r->getClosureThis()) {
537536
$callableXML->setAttribute('static', 'true');
538537
}
539538
}

Tests/Console/Descriptor/ObjectsProvider.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static function getEventDispatchers()
163163

164164
public static function getCallables()
165165
{
166-
return array(
166+
$callables = array(
167167
'callable_1' => 'array_key_exists',
168168
'callable_2' => array('Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass', 'staticMethod'),
169169
'callable_3' => array(new CallableClass(), 'method'),
@@ -172,6 +172,12 @@ public static function getCallables()
172172
'callable_6' => function () { return 'Closure'; },
173173
'callable_7' => new CallableClass(),
174174
);
175+
176+
if (\PHP_VERSION_ID >= 70100) {
177+
$callables['callable_from_callable'] = \Closure::fromCallable(new CallableClass());
178+
}
179+
180+
return $callables;
175181
}
176182
}
177183

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"type": "closure",
3+
"name": "__invoke",
4+
"class": "Symfony\\Bundle\\FrameworkBundle\\Tests\\Console\\Descriptor\\CallableClass"
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
- Type: `closure`
3+
- Name: `__invoke`
4+
- Class: `Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<callable type="closure" name="__invoke" class="Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass"/>

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
55
backupGlobals="false"
66
colors="true"
77
bootstrap="vendor/autoload.php"

0 commit comments

Comments
 (0)