8000 [PropertyInfo] Ignore empty doc-block for promoted properties in PhpStanExtractor by BoShurik · Pull Request #46361 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PropertyInfo] Ignore empty doc-block for promoted properties in PhpStanExtractor #46361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra
$constructor = new \ReflectionMethod($class, '__construct');
$rawDocNode = $constructor->getDocComment();
$source = self::MUTATOR;
} elseif (null === $rawDocNode = $reflectionProperty->getDocComment() ?: null) {
} else {
$rawDocNode = $reflectionProperty->getDocComment();
}

if (!$rawDocNode) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
use Symfony\Component\PropertyInfo\Tests\Fixtures\ParentDummy;
use Symfony\Component\PropertyInfo\Tests\Fixtures\Php80Dummy;
use Symfony\Component\PropertyInfo\Tests\Fixtures\Php80PromotedDummy;
use Symfony\Component\PropertyInfo\Tests\Fixtures\RootDummy\RootDummyItem;
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsedInTrait;
use Symfony\Component\PropertyInfo\Tests\Fixtures\TraitUsage\DummyUsingTrait;
Expand Down Expand Up @@ -439,15 +440,16 @@ public function testDummyNamespaceWithProperty()
/**
* @dataProvider php80TypesProvider
*/
public function testExtractPhp80Type($property, array $type = null)
public function testExtractPhp80Type(string $class, $property, array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypes(Php80Dummy::class, $property, []));
$this->assertEquals($type, $this->extractor->getTypes($class, $property, []));
}

public function php80TypesProvider()
{
return [
['promotedAndMutated', [new Type(Type::BUILTIN_TYPE_STRING)]],
[Php80Dummy::class, 'promotedAndMutated', [new Type(Type::BUILTIN_TYPE_STRING)]],
[Php80PromotedDummy::class, 'promoted', null],
];
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyInfo\Tests\Fixtures;

class Php80PromotedDummy
{
public function __construct(private string $promoted)
{
}

public function getPromoted(): string
{
return $this->promoted;
}
}
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
0