Skip to content

Commit 0d79c4b

Browse files
committed
Merge branch 'feature/psr2-propertydeclaration-readonly' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents a6bc7e4 + 068635e commit 0d79c4b

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
4141
$find = Tokens::$scopeModifiers;
4242
$find[] = T_VARIABLE;
4343
$find[] = T_VAR;
44+
$find[] = T_READONLY;
4445
$find[] = T_SEMICOLON;
4546
$find[] = T_OPEN_CURLY_BRACKET;
4647

src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,13 @@ class MyClass
7171
public int $var = null;
7272
public static int/*comment*/$var = null;
7373
}
74+
75+
class ReadOnlyProp {
76+
public readonly int $foo,
77+
$bar,
78+
$var = null;
79+
80+
protected readonly ?string $foo;
81+
82+
readonly array $foo;
83+
}

src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.inc.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,13 @@ class MyClass
6868
public int $var = null;
6969
public static int /*comment*/$var = null;
7070
}
71+
72+
class ReadOnlyProp {
73+
public readonly int $foo,
74+
$bar,
75+
$var = null;
76+
77+
protected readonly ?string $foo;
78+
79+
readonly array $foo;
80+
}

src/Standards/PSR2/Tests/Classes/PropertyDeclarationUnitTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function getErrorList()
4646
69 => 1,
4747
71 => 1,
4848
72 => 1,
49+
76 => 1,
50+
80 => 1,
51+
82 => 1,
4952
];
5053

5154
}//end getErrorList()

0 commit comments

Comments
 (0)