Skip to content

Commit f4693be

Browse files
committed
bug #21370 [FrameworkBundle] Execute the PhpDocExtractor earlier (GuilhemN)
This PR was submitted for the master branch but it was merged into the 2.8 branch instead (closes #21370). Discussion ---------- [FrameworkBundle] Execute the PhpDocExtractor earlier | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes, but safer to apply on master | New feature? | no | BC breaks? | is changing a priority a bc break? | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21367 | License | MIT | Doc PR | Fixes #21367. > I wonder if this is logical to execute the PhpDocExtractor after the ReflectionExtractor: when you use phpdocs it's because they are more precise than php type hints. This causes an issue in NelmioApiDocBundle, for example you can't use int[] with a setter as the type mixed[] will be returned instead of int[]. > > ~~Would you accept bumping its priority to -999?~~ This PR changes the priority of the `ReflectionExtractor` to `-1002` to make sure it is executed after the `PhpDocExtractor`. Commits ------- 0425e05 [FrameworkBundle] Execute the PhpDocExtractor earlier
2 parents 5bc83c4 + 0425e05 commit f4693be

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<!-- Extractor -->
1616
<service id="property_info.reflection_extractor" class="Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor" public="false">
1717
<tag name="property_info.list_extractor" priority="-1000" />
18-
<tag name="property_info.type_extractor" priority="-1000" />
18+
<tag name="property_info.type_extractor" priority="-1002" />
1919
<tag name="property_info.access_extractor" priority="-1000" />
2020
</service>
2121
</services>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
13+
14+
use Symfony\Component\PropertyInfo\Type;
15+
16+
class PropertyInfoTest extends WebTestCase
17+
{
18+
public function testPhpDocPriority()
19+
{
20+
static::bootKernel(array('test_case' => 'Serializer'));
21+
$container = static::$kernel->getContainer();
22+
23+
$this->assertEquals(array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_INT))), $container->get('property_info')->getTypes(Dummy::class, 'codes'));
24+
}
25+
}
26+
27+
class Dummy
28+
{
29+
/**
30+
* @param int[] $codes
31+
*/
32+
public function setCodes(array $codes)
33+
{
34+
}
35+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy