diff --git a/src/Fixer/PhpdocPropertySortedFixer.php b/src/Fixer/PhpdocPropertySortedFixer.php index d6089a59..bfe35c37 100644 --- a/src/Fixer/PhpdocPropertySortedFixer.php +++ b/src/Fixer/PhpdocPropertySortedFixer.php @@ -126,7 +126,7 @@ private static function sortPropertiesByName(array &$properties): void private static function extractPropertyName(string $propertyLine): ?string { $matches = []; - Preg::match('/@property\\s+[^\\s]+\\s+\\$(\\w+)/', $propertyLine, $matches); + Preg::match('/@property(?:-read|-write)?\\s+[^\\s]+\\s+\\$(\\w+)/', $propertyLine, $matches); /** @var array $matches */ if (\count($matches) > 1) { return $matches[1]; diff --git a/tests/Fixer/PhpdocPropertySortedFixerTest.php b/tests/Fixer/PhpdocPropertySortedFixerTest.php index 71a3e81f..80bacc42 100644 --- a/tests/Fixer/PhpdocPropertySortedFixerTest.php +++ b/tests/Fixer/PhpdocPropertySortedFixerTest.php @@ -183,6 +183,46 @@ function example($x) {} * @return bool */ function example($x) {} +', + ]; + + yield [ + '