8000 Merge branch '4.2' · symfony/symfony@c7fe1b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit c7fe1b6

Browse files
Merge branch '4.2'
* 4.2: [VarExporter] fix dumping private properties from abstract classes Fix empty output for debug:autowiring when reflection-docblock is not available [Workflow] Fixed BC break for Workflow metadata [Routing] ignore trailing slash for non-GET requests
2 parents 974b98b + b932300 commit c7fe1b6

File tree

12 files changed

+45
-25
lines changed

12 files changed

+45
-25
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ protected function sortServiceIds(array $serviceIds)
292292
*/
293293
public static function getClassDescription(string $class, string &$resolvedClass = null): string
294294
{
295-
$resolvedClass = null;
295+
$resolvedClass = $class;
296296

297297
if (!interface_exists(DocBlockFactoryInterface::class)) {
298298
return '';

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
547547
}
548548
if ($transition['metadata']) {
549549
$transitionsMetadataDefinition->addMethodCall('attach', array(
550-
$transitionDefinition,
550+
new Reference($transitionId),
551551
$transition['metadata'],
552552
));
553553
}
@@ -569,7 +569,7 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
569569
}
570570
if ($transition['metadata']) {
571571
$transitionsMetadataDefinition->addMethodCall('attach', array(
572-
$transitionDefinition,
572+
new Reference($transitionId),
573573
$transition['metadata'],
574574
));
575575
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,8 @@ public function testWorkflows()
258258
$this->assertSame('attach', $transitionsMetadataCall[0]);
259259
$params = $transitionsMetadataCall[1];
260260
$this->assertCount(2, $params);
261-
A8C6 $this->assertInstanceOf(Definition::class, $params[0]);
262-
$this->assertSame(Workflow\Transition::class, $params[0]->getClass());
263-
$this->assertSame(array('submit', 'start', 'travis'), $params[0]->getArguments());
264-
$this->assertSame(array('title' => 'transition submit title'), $params[1]);
261+
$this->assertInstanceOf(Reference::class, $params[0]);
262+
$this->assertSame('state_machine.pull_request.transition.0', (string) $params[0]);
265263

266264
$serviceMarkingStoreWorkflowDefinition = $container->getDefinition('workflow.service_marking_store_workflow');
267265
/** @var Reference $markingStoreRef */

src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private function doMatch(string $rawPathinfo, array &$allow = array(), array &$a
9090

9191
if ('/' === $pathinfo || $hasTrailingSlash === ('/' === $pathinfo[-1])) {
9292
// no-op
93-
} elseif ($this instanceof RedirectableUrlMatcherInterface) {
93+
} elseif ($this instanceof RedirectableUrlMatcherInterface && (!$requiredMethods || isset($requiredMethods['GET'])) && 'GET' === $canonicalMethod) {
9494
return $allow = $allowSchemes = array();
9595
} else {
9696
continue;
@@ -139,7 +139,7 @@ private function doMatch(string $rawPathinfo, array &$allow = array(), array &$a
139139
}
140140
}
141141
if ($hasTrailingSlash !== ('/' === $pathinfo[-1])) {
142-
if ($this instanceof RedirectableUrlMatcherInterface && (!$requiredMethods || isset($requiredMethods['GET']))) {
142+
if ($this instanceof RedirectableUrlMatcherInterface && (!$requiredMethods || isset($requiredMethods['GET'])) && 'GET' === $canonicalMethod) {
143143
return $allow = $allowSchemes = array();
144144
}
145145
continue;

src/Symfony/Component/Routing/Matcher/UrlMatcher.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ public function addExpressionLanguageProvider(ExpressionFunctionProviderInterfac
130130
*/
131131
protected function matchCollection($pathinfo, RouteCollection $routes)
132132
{
133+
// HEAD and GET are equivalent as per RFC
134+
if ('HEAD' === $method = $this->context->getMethod()) {
135+
$method = 'GET';
136+
}
133137
$supportsTrailingSlash = '/' !== $pathinfo && '' !== $pathinfo && $this instanceof RedirectableUrlMatcherInterface;
134138

135139
foreach ($routes as $name => $route) {
@@ -140,7 +144,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
140144
// check the static prefix of the URL first. Only use the more expensive preg_match when it matches
141145
if ('' === $staticPrefix || 0 === strpos($pathinfo, $staticPrefix)) {
142146
// no-op
143-
} elseif (!$supportsTrailingSlash || ($requiredMethods && !\in_array('GET', $requiredMethods))) {
147+
} elseif (!$supportsTrailingSlash || ($requiredMethods && !\in_array('GET', $requiredMethods)) || 'GET' !== $method) {
144148
continue;
145149
} elseif ('/' === $staticPrefix[-1] && substr($staticPrefix, 0, -1) === $pathinfo) {
146150
return $this->allow = $this->allowSchemes = array();
@@ -170,7 +174,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
170174
}
171175
}
172176
if ($hasTrailingSlash !== ('/' === $pathinfo[-1])) {
173-
if (!$requiredMethods || \in_array('GET', $requiredMethods)) {
177+
if ((!$requiredMethods || \in_array('GET', $requiredMethods)) && 'GET' === $method) {
174178
return $this->allow = $this->allowSchemes = array();
175179
}
176180
continue;
@@ -190,11 +194,6 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
190194

191195
$hasRequiredScheme = !$route->getSchemes() || $route->hasScheme($this->context->getScheme());
192196
if ($requiredMethods) {
193-
// HEAD and GET are equivalent as per RFC
194-
if ('HEAD' === $method = $this->context->getMethod()) {
195-
$method = 'GET';
196-
}
197-
198197
if (!\in_array($method, $requiredMethods)) {
199198
if ($hasRequiredScheme) {
200199
$this->allow = array_merge($this->allow, $requiredMethods);

src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,17 @@ public function testSlashAndVerbPrecedence()
723723
'customerId' => '123',
724724
);
725725
$this->assertEquals($expected, $matcher->match('/api/customers/123/contactpersons'));
726+
727+
$coll = new RouteCollection();
728+
$coll->add('a', new Route('/api/customers/{customerId}/contactpersons/', array(), array(), array(), '', array(), array('get')));
729+
$coll->add('b', new Route('/api/customers/{customerId}/contactpersons', array(), array(), array(), '', array(), array('post')));
730+
731+
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'POST'));
732+
$expected = array(
733+
'_route' => 'b',
734+
'customerId' => '123',
735+
);
736+
$this->assertEquals($expected, $matcher->match('/api/customers/123/contactpersons'));
726737
}
727738

728739
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null)

src/Symfony/Component/VarExporter/Internal/Exporter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount
125125
$c = 'stdClass';
126126
} elseif ('*' === $n[1]) {
127127
$n = substr($n, 3);
128-
if ('Error' === $c = $class) {
128+
$c = $reflector->getProperty($n)->class;
129+
if ('Error' === $c) {
129130
$c = 'TypeError';
130131
} elseif ('Exception' === $c) {
131132
$c = 'ErrorException';

src/Symfony/Component/VarExporter/Internal/Hydrator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\VarExporter\Internal;
1313

14+
use Symfony\Component\VarExporter\Exception\ClassNotFoundException;
15+
1416
/**
1517
* @author Nicolas Grekas <p@tchwork.com>
1618
*
@@ -59,7 +61,10 @@ public static function getHydrator($class)
5961
};
6062
}
6163

62-
$classReflector = Registry::$reflectors[$class] ?? Registry::getClassReflector($class);
64+
if (!\class_exists($class) && !\interface_exists($class, false) && !\trait_exists($class, false)) {
65+
throw new ClassNotFoundException($class);
66+
}
67+
$classReflector = new \ReflectionClass($class);
6368

6469
if (!$classReflector->isInternal()) {
6570
return self::$hydrators[$class] = (self::$hydrators['stdClass'] ?? self::getHydrator('stdClass'))->bindTo(null, $class);

src/Symfony/Component/VarExporter/Tests/Fixtures/abstract-parent.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
],
77
null,
88
[
9-
'Symfony\\Component\\VarExporter\\Tests\\ConcreteClass' => [
9+
'Symfony\\Component\\VarExporter\\Tests\\AbstractClass' => [
1010
'foo' => [
1111
123,
1212
],
13+
'bar' => [
14+
234,
15+
],
1316
],
1417
],
1518
$o[0],

src/Symfony/Component/VarExporter/Tests/Fixtures/final-error.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
]),
77
null,
88
[
9-
'Symfony\\Component\\VarExporter\\Tests\\FinalError' => [
9+
'TypeError' => [
1010
'file' => [
1111
\dirname(__DIR__).\DIRECTORY_SEPARATOR.'VarExporterTest.php',
1212
],

src/Symfony/Component/VarExporter/Tests/Fixtures/private.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@
1010
'Symfony\\Component\\VarExporter\\Tests\\MyPrivateValue' => [
1111
'prot' => [
1212
123,
13+
123,
1314
],
1415
'priv' => [
1516
234,
1617
234,
1718
],
1819
],
19-
'Symfony\\Component\\VarExporter\\Tests\\MyPrivateChildValue' => [
20-
'prot' => [
21-
1 => 123,
22-
],
23-
],
2420
],
2521
[
2622
$o[0],

src/Symfony/Component/VarExporter/Tests/VarExporterTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,19 @@ public function __clone()
326326
abstract class AbstractClass
327327
{
328328
protected $foo;
329+
private $bar;
330+
331+
protected function setBar($bar)
332+
{
333+
$this->bar = $bar;
334+
}
329335
}
330336

331337
class ConcreteClass extends AbstractClass
332338
{
333339
public function __construct()
334340
{
335341
$this->foo = 123;
342+
$this->setBar(234);
336343
}
337344
}

0 commit comments

Comments
 (0)
0