Skip to content

Commit 4caa5ec

Browse files
committed
Slevomat.Classes.DisallowMultiPropertyDefinition: Fixed for property hooks
1 parent 3ce4daf commit 4caa5ec

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

SlevomatCodingStandard/Sniffs/Classes/DisallowMultiPropertyDefinitionSniff.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use const T_COMMA;
2020
use const T_CONST;
2121
use const T_FUNCTION;
22+
use const T_OPEN_CURLY_BRACKET;
2223
use const T_OPEN_SHORT_ARRAY;
2324
use const T_SEMICOLON;
2425
use const T_VARIABLE;
@@ -61,6 +62,11 @@ public function process(File $phpcsFile, int $modifierPointer): void
6162
return;
6263
}
6364

65+
$endPointer = TokenHelper::findNext($phpcsFile, [T_SEMICOLON, T_OPEN_CURLY_BRACKET], $propertyPointer + 1);
66+
if ($tokens[$endPointer]['code'] === T_OPEN_CURLY_BRACKET) {
67+
return;
68+
}
69+
6470
$semicolonPointer = TokenHelper::findNext($phpcsFile, T_SEMICOLON, $propertyPointer + 1);
6571
$commaPointers = [];
6672
$nextPointer = $propertyPointer;

tests/Sniffs/Classes/data/disallowMultiPropertyDefinitionNoErrors.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php // lint >= 8.0
1+
<?php // lint >= 8.4
22

33
class Foo
44
{
@@ -17,6 +17,14 @@ class Foo
1717
'c',
1818
];
1919

20+
public private(set) LocalizedString $hook {
21+
get => LocalizedString::fromCzechAndSlovak($this->locativeCs, $this->locativeSk);
22+
set {
23+
$this->locativeCs = $value->getInCzech(required: false);
24+
$this->locativeSk = $value->getInSlovak(required: false);
25+
}
26+
}
27+
2028
public $oldArray = array(
2129
'a',
2230
'b',

0 commit comments

Comments
 (0)