Skip to content

Add additional parameter and return type information to stubs #28

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 16 commits into from
Mar 24, 2022
Merged

Add additional parameter and return type information to stubs #28

merged 16 commits into from
Mar 24, 2022

Conversation

johnbillion
Copy link
Contributor

@johnbillion johnbillion commented Mar 23, 2022

This introduces some more functionality to the node visitor which appends PHPStan-specific @phpstan-param and @phpstan-return tags to the docblock for given functions and methods.

This allows for us to increase the specificity of return values and parameters for PHPStan usage specifically.

The functionMap.php file is formatted in a similar manner to the same file in PHPStan itself. Any number of functions and methods can be added in order to override the return type and zero or more of its parameter types.

The resulting changes for the functions and methods I've added so far can be seen in wordpress-stubs.php.

@szepeviktor What do you think?

This relies on php-stubs/generator#13

@szepeviktor
Copy link
Member

What do you think?

I'd like to distance myself from WordPress and web frameworks, web applications - but cannot!
:)

I welcome your contributions.

functionMap.php Outdated
* This array is in the same format as the stubs array in PHPStan:
* This array is in the same format as the function map array in PHPStan:
Copy link
Member

Choose a reason for hiding this comment

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

❤️ This is my kind of commit 😍

@szepeviktor
Copy link
Member

Almost done 🚀

@johnbillion johnbillion marked this pull request as ready for review March 24, 2022 12:44
@szepeviktor szepeviktor merged commit d87bf8e into php-stubs:master Mar 24, 2022
@szepeviktor
Copy link
Member

Thank you John.

@johnbillion johnbillion deleted the additional-parameters branch March 24, 2022 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants