Skip to content

Commit 410d7f2

Browse files
BoShuriknicolas-grekas
authored andcommitted
[PropertyInfo] Ignore empty doc-block for promoted properties in PhpStanExtractor
1 parent d0d665c commit 410d7f2

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,11 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra
227227
$constructor = new \ReflectionMethod($class, '__construct');
228228
$rawDocNode = $constructor->getDocComment();
229229
$source = self::MUTATOR;
230-
} elseif (null === $rawDocNode = $reflectionProperty->getDocComment() ?: null) {
230+
} else {
231+
$rawDocNode = $reflectionProperty->getDocComment();
232+
}
233+
234+
if (!$rawDocNode) {
231235
return null;
232236
}
233237

src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpStanExtractorTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
1919
use Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy;
2020
use Symfony\Component\PropertyInfo\Tests\Fixtures\Php80Dummy;
21+
use Symfony\Component\PropertyInfo\Tests\Fixtures\Php80PromotedDummy;
2122
use Symfony\Component\PropertyInfo\Tests\Fixtures\RootDummy\RootDummyItem;
2223
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsedInTrait;
2324
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsingTrait;
@@ -439,15 +440,16 @@ public function testDummyNamespaceWithProperty()
439440
/**
440441
* @dataProvider php80TypesProvider
441442
*/
442-
public function testExtractPhp80Type($property, array $type = null)
443+
public function testExtractPhp80Type(string $class, $property, array $type = null)
443444
{
444-
$this->assertEquals($type, $this->extractor->getTypes(Php80Dummy::class, $property, []));
445+
$this->assertEquals($type, $this->extractor->getTypes($class, $property, []));
445446
}
446447

447448
public function php80TypesProvider()
448449
{
449450
return [
450-
['promotedAndMutated', [new Type(Type::BUILTIN_TYPE_STRING)]],
451+
[Php80Dummy::class, 'promotedAndMutated', [new Type(Type::BUILTIN_TYPE_STRING)]],
452+
[Php80PromotedDummy::class, 'promoted', null],
451453
];
452454
}
453455
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\Component\PropertyInfo\Tests\Fixtures;
13+
14+
class Php80PromotedDummy
15+
{
16+
public function __construct(private string $promoted)
17+
{
18+
}
19+
20+
public function getPromoted(): string
21+
{
22+
return $this->promoted;
23+
}
24+
}

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