Skip to content

Commit

Permalink
PSR2/PropertyDeclaration: allow for readonly keyword
Browse files Browse the repository at this point in the history
Includes tests.
  • Loading branch information
jrfnl committed Dec 18, 2021
1 parent 6296b27 commit 068635e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
$find = Tokens::$scopeModifiers;
$find[] = T_VARIABLE;
$find[] = T_VAR;
$find[] = T_READONLY;
$find[] = T_SEMICOLON;
$find[] = T_OPEN_CURLY_BRACKET;

Expand Down
10 changes: 10 additions & 0 deletions src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,13 @@ class MyClass
public int $var = null;
public static int/*comment*/$var = null;
}

class ReadOnlyProp {
public readonly int $foo,
$bar,
$var = null;

protected readonly ?string $foo;

readonly array $foo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,13 @@ class MyClass
public int $var = null;
public static int /*comment*/$var = null;
}

class ReadOnlyProp {
public readonly int $foo,
$bar,
$var = null;

protected readonly ?string $foo;

readonly array $foo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function getErrorList()
69 => 1,
71 => 1,
72 => 1,
76 => 1,
80 => 1,
82 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 068635e

Please sign in to comment.