PHP 7.4 supports type hints for class properties. So that declaring types via annotation has become redundant.

CommentFileSizeAuthor
#3 coder-3123282-3.patch1.17 KBkingdutch
#2 coder-3123282-2.patch979 byteskingdutch

Comments

Chi created an issue. See original summary.

kingdutch’s picture

Status: Active » Needs review
StatusFileSize
new979 bytes

The attached patch adds a check in case no @var is found to determine whether the token before the variable for which we're looking at the doc comment is a string. This is the token type for a type annotation. If no type is specified for the property then the previous token would be T_PROTECTED, T_PUBLIC or T_PRIVATE.

kingdutch’s picture

StatusFileSize
new1.17 KB

Updated the patch to do the same. The previous patch was written in a version before some dead code (that I now relied on) was removed. The new implementation is also more robust in how it finds the type if it exists (being more resistant to whitespace changes).

Given the rewrite no interdiff is provided.

claudiu.cristea’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Nice, but needs tests

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

Looking good, thanks! I think we need to wait for #3238192: Allow omitting @var for strictly typed class properties though before this can be merged.

klausi’s picture

Status: Reviewed & tested by the community » Needs work

Thanks, makes sense to me, just left a minor improvement comment on the pull request.

We don't need to wait for official coding standard approval in Coder in non-controversial cases such as this, so once ready we can merge immediately :)

  • klausi authored d1bb7ea on 8.3.x
    feat(VariableComment): Allow omitting @var doc tags on typed class...
klausi’s picture

Status: Needs work » Fixed

Improved the PR and merged it. Thank you all!

solideogloria’s picture

I was just looking for something like this. Thanks all!

romain.sickenberg’s picture

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.