8000 Ignore empty doc-block for promoted properties in PhpStanExtractor · symfony/symfony@9307ff2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9307ff2

Browse files
committed
Ignore empty doc-block for promoted properties in PhpStanExtractor
1 parent d0d665c commit 9307ff2

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ 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+
if (null === ($rawDocNode ?: null)) {
231234
return null;
232235
}
233236

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: 15 additions & 0 deletions
< 8000 div class="border position-relative rounded-bottom-2">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
4+
5+
class Php80PromotedDummy
6+
{
7+
public function __construct(private string $promoted)
8+
{
9+
}
10+
11+
public function getPromoted(): string
12+
{
13+
return $this->promoted;
14+
}
15+
}

0 commit comments

Comments
 (0)
0