Problem/Motivation
readonly class member variables generate `Missing member variable doc comment` errors, regardless of whether they actually have a doc comment.
Steps to reproduce
Here's code that causes the sniff error:
<?php
namespace MyNamespace;
/**
* Test class with a test member variable.
*/
class Test {
/**
* Test.
*
* @var float
*/
public readonly float $test;
}
Proposed resolution
readonly member variables with doc comments shouldn't show errors like that.
This can be fixed by adding T_READONLY to the ignore list in processMemberVar() in VariableCommentSniff.php
Comments
Comment #2
solideogloria commentedWorks for me.
Comment #3
klausiThanks, can you file a pull request against https://github.com/pfrenssen/coder so that we see the test cases run?
Please also add a test case so that we cover this.
Comment #4
solideogloria commentedAdded a test and created a pull request. For completion, here is the patch.
https://github.com/pfrenssen/coder/pull/168
Comment #5
solideogloria commentedComment #8
klausiThanks, merged! I also bumped our PHPCs dependency to 3.7.1 to make sure PHP 8.1 language support is there.