Skip to content
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 @@ -287,11 +287,11 @@ public function getLongDescription(string $class, string $property, array $conte
}

/**
* A docblock is splitted into a template marker, a short description, an optional long description and a tags section.
* A docblock is split into a template marker, a short description, an optional long description and a tags section.
*
* - The template marker is either empty, or #@+ or #@-.
* - The template marker is either empty, #@+ or #@-.
* - The short description is started from a non-tag character, and until one or multiple newlines.
* - The long description (optional), is started from a non-tag character, and until a new line is encountered followed by a tag.
* - The long description (optional) is started from a non-tag character, and until a new line is encountered followed by a tag.
* - Tags, and the remaining characters
*
* This method returns the short and the long descriptions.
Expand Down Expand Up @@ -374,7 +374,7 @@ private function getDescriptionsFromDocNode(PhpDocNode $docNode): array
];
}

private function getDocBlockFromConstructor(string $class, string $property): ?ParamTagValueNode
private function getDocBlockFromConstructor(string &$class, string $property): ?ParamTagValueNode
{
try {
$reflectionClass = new \ReflectionClass($class);
Expand All @@ -389,6 +389,7 @@ private function getDocBlockFromConstructor(string $class, string $property): ?P
if (!$rawDocNode = $reflectionConstructor->getDocComment()) {
return null;
}
$class = $reflectionConstructor->class;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code to simplify the implementation and remove repeated code.


$phpDocNode = $this->getPhpDocNode($rawDocNode);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,11 @@ public static function descriptionsProvider(): iterable
yield ['bal', 'A short description ignoring template.', "A long description...\n\n...over several lines."];
yield ['foo2', null, null];
}

public function testGetTypeFromConstructorOfParentClass()
{
$this->assertEquals(Type::nullable(Type::object(RootDummyItem::class)), $this->extractor->getTypeFromConstructor(Dummy::class, 'rootDummyItem'));
}
}

class PhpStanOmittedParamTagTypeDocBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ class ParentDummy
*/
public $rootDummyItem;

/**
* @param RootDummyItem|null $rootDummyItem
*/
public function __construct(?RootDummyItem $rootDummyItem = null)
{
$this->rootDummyItem = $rootDummyItem;
}

/**
* @return bool|null
*/
Expand Down
Loading