Problem/Motivation
Coding Standards have adopted a change regarding when the @var, @param and @return tags or their description is required. In short they can be omitted when the variable name itself has that information.
That are now included in the functions section of the standard.
There were several text changes so reading the commit will help.
The coding standards issue: #3376518: Allow omitting @var, @param and @return tags or their descriptions if the variable name and type is enough
Steps to reproduce
Proposed resolution
I will code whatever is necessary if that proposal gets accepted.
Remaining tasks
Fix phpcs errors
add tests
review
User interface changes
API changes
Data model changes
Issue fork coder-3572690
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
quietone commentedAs a member of the Coding Standards Committee, I think the proposal can be considered accepted. It merely needs to be committed. And to be honest, I am holding off because I am concerned about the confusion it may cause.
Comment #3
ghost of drupal pastComment #5
bramdriesenI think there are some tests that still need to be adjusted.
Comment #6
ghost of drupal pastThanks for the speedy reply, I fixed the phpcs problems. (How ironic.)
Comment #7
mstrelan commentedFrom the coding_standards issue:
How strictly are we interpreting "matches the type"? I think we should strip underscores and do a lowercase comparison, so we catch
EntityTypeManagerInterface $entity_type_manager. From what I can tell from the MR we would only catchEntityTypeManagerInterface $entityTypeManager.Comment #8
borisson_In cases where it is the snake_case formatting, the spirit of the new rule means we should be catching those as well, I agree. lowercasing + stripping out underscores sounds like a smart solution, +1.
Comment #9
ghost of drupal pastAdded full camelCase conversion
Comment #10
klausiThanks!
1) Please fill out the issue title and description here, otherwise you make it very hard for Coder maintainers to understand which exact part of the linked issue you are trying to fix
2) Please fix the phpcs test fails
3) please add test cases with positive and negative examples so that we codify the expected behavior in tests
Comment #11
ghost of drupal pastSomeone else will need to do this, for what should be obvious reasons I will try my best to stay away from the Drupal issue queues -- excluding work obligations -- from this point on. I am not sure I can succeed but I will try.
Comment #12
quietone commentedComment #13
quietone commentedComment #15
littlecodingMR has been rebased and PHPCS fixed.
But the pipeline is now failing on the Drupal core regression tests.
Comment #17
klausiI merged a quickfix to exclude that core file from testing.
Please merge from 9.x in your merge request. please add test cases with positive and negative examples so that we codify the expected behavior in tests
Comment #18
littlecodingI've been doing the reading of the referenced issue 3376518, and it looks like commit #185 has a good/complete set of examples to base the new tests on.
@quietone, @klausi, anything to else to identify for tests?
@klausi Thank you for that quick fix for the core regression testing!
Comment #19
littlecodingAs I started to work on the addition of some tests, I determined that the comment can be skipped logic was not working as intended. Class/Interface upper camel case naming was being compared to the lower camel case naming of the variable.
To confirm scope of this issue, here are the tests for the sniffer
Do we feel it is within the scope of this issue to create a `warning` for a type mismatch between the variable and @var tag?
A over arching question I have is whether these committing options are limited to variables that are typed when declared?
Comment #20
borisson_Good question, I don't think so, that should get fixed in higher levels of phpstan coverage, so to me that doesn't have to be in scope for this issue.
I would think this only works when the variable is typed as it is declared.