Skip to content
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

add phpstan typechecked phpdocs #111

Closed
wants to merge 10 commits into from
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/ClassConstStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function meetsCriteria(Node $node): bool
/**
* @param Node&ClassConstFetch $node
* @return array<string>
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array
Copy link
Author

Choose a reason for hiding this comment

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

I am wondering whether these methods should read $class->toCodeString() as it seems toString will not always return a proper FQCN, per phpdocs in

https://github.com/nikic/PHP-Parser/blob/1d1bc8a36459d67acef508b952dad097960b110e/lib/PhpParser/Node/Name.php#L87-L105

Copy link
Member

Choose a reason for hiding this comment

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

Hm but as it states toCodeString just used toString
Question is: Is this overridden in some specific types?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, it is changed depending on Relative or FullyQualified nodes.
That would prepend \\ or namespace\. Which I don't know if it's good.

But it could be a possibility for resolving the problem @OskarStark and @localheinz faced in #100 where
"Relative" classes were not recognized correctly.

{
Expand Down
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/ExtendsParseStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function meetsCriteria(Node $node): bool
/**
* @param Node&Class_ $node
* @return array<string>
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array
{
Expand Down
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/ImplementsParseStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function meetsCriteria(Node $node): bool
/**
* @param Node&Class_ $node
* @return array<string>
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array
{
Expand Down
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/InstanceofStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function meetsCriteria(Node $node): bool
/**
* @param Node&Node\Expr\Instanceof_ $node
* @return array<string>
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array
{
Expand Down
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/NewParseStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function meetsCriteria(Node $node): bool
/**
* @param Node&New_$node
* @return array<string>
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array
{
Expand Down
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/ParseStrategyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function meetsCriteria(Node $node): bool;
/**
* @param Node $node
* @return string[]
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array;
}
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/PhpExtensionStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function meetsCriteria(Node $node): bool

/**
* @return array<string>
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array
{
Expand Down
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/StaticParseStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function meetsCriteria(Node $node): bool
/**
* @param Node&StaticCall $node
* @return array<string>
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array
{
Expand Down
1 change: 1 addition & 0 deletions src/Parser/PHP/Strategy/UseParseStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function meetsCriteria(Node $node): bool
/**
* @param Node $node
* @return array<string>
* @phpstan-return array<class-string>
*/
public function extractNamespaces(Node $node): array
{
Expand Down