Skip to content

Commit b043ae4

Browse files
committed
Squiz/VariableComment: allow for readonly keyword
Includes tests.
1 parent 6296b27 commit b043ae4

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
3535
T_PROTECTED => T_PROTECTED,
3636
T_VAR => T_VAR,
3737
T_STATIC => T_STATIC,
38+
T_READONLY => T_READONLY,
3839
T_WHITESPACE => T_WHITESPACE,
3940
T_STRING => T_STRING,
4041
T_NS_SEPARATOR => T_NS_SEPARATOR,

src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,22 @@ class HasAttributes
383383
#[ORM\Column(ORM\Column::T_INTEGER)]
384384
protected $height;
385385
}
386+
387+
class ReadOnlyProps
388+
{
389+
/**
390+
* Short description of the member variable.
391+
*
392+
* @var array
393+
*/
394+
public readonly array $variableName = array();
395+
396+
/**
397+
* Short description of the member variable.
398+
*
399+
* @var
400+
*/
401+
readonly protected ?int $variableName = 10;
402+
403+
private readonly string $variable;
404+
}

src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,3 +383,22 @@ class HasAttributes
383383
#[ORM\Column(ORM\Column::T_INTEGER)]
384384
protected $height;
385385
}
386+
387+
class ReadOnlyProps
388+
{
389+
/**
390+
* Short description of the member variable.
391+
*
392+
* @var array
393+
*/
394+
public readonly array $variableName = array();
395+
396+
/**
397+
* Short description of the member variable.
398+
*
399+
* @var
400+
*/
401+
readonly protected ?int $variableName = 10;
402+
403+
private readonly string $variable;
404+
}

src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public function getErrorList()
5858
336 => 1,
5959
361 => 1,
6060
364 => 1,
61+
399 => 1,
62+
403 => 1,
6163
];
6264

6365
}//end getErrorList()

0 commit comments

Comments
 (0)