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

fix error when phpdoc param has no type #403

Merged
merged 1 commit into from
Dec 17, 2024
Merged

Conversation

LordSimal
Copy link
Contributor

@LordSimal LordSimal commented Dec 17, 2024

Fixes #402

This adds a new warning if a param type has no type hint instead of just bailing out due to an error

@LordSimal LordSimal added this to the 5.x milestone Dec 17, 2024
@LordSimal LordSimal marked this pull request as draft December 17, 2024 21:41
@LordSimal LordSimal force-pushed the 5.x-fix-error-with-no-type branch from 86bf119 to cd67ba6 Compare December 17, 2024 21:49
@LordSimal LordSimal marked this pull request as ready for review December 17, 2024 21:49
@dereuromark dereuromark merged commit 9686722 into 5.x Dec 17, 2024
5 checks passed
@dereuromark dereuromark deleted the 5.x-fix-error-with-no-type branch December 17, 2024 21:53
@dereuromark
Copy link
Member

Side note
You can also use TypelessParamTagValueNode check to bail early here

            if ($valueNode instanceof InvalidTagValueNode || $valueNode instanceof TypelessParamTagValueNode) {
                if (!isset($valueNode->type)) {
                    $phpcsFile->addWarning('%s type hint is missing', $tag, 'MissingParamType', [$tokens[$tag]['content']]);
                }
                continue;
            }

Note the %s, since it can be others than param as well.

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.

Error when phpdoc param has no type
2 participants