Skip to content

Commit 9fafd82

Browse files
bug #46361 [PropertyInfo] Ignore empty doc-block for promoted properties in PhpStanExtractor (BoShurik)
This PR was merged into the 6.1 branch. Discussion ---------- [PropertyInfo] Ignore empty doc-block for promoted properties in PhpStanExtractor | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | - <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Fix processing empty doc-block for promoted properties (introduced in #46056) <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against the latest branch. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Commits ------- 410d7f2 [PropertyInfo] Ignore empty doc-block for promoted properties in PhpStanExtractor
2 parents d0d665c + 410d7f2 commit 9fafd82

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