Skip to content

Commit 9471631

Browse files
authored
feat: PhpdocVarWithoutNameFixer - support asymmetric visibility (#8704)
1 parent d0c6fc9 commit 9471631

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
final class PhpdocVarWithoutNameFixer extends AbstractFixer
3434
{
35-
private const PROPERTY_MODIFIER_KINDS = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_VAR, FCT::T_READONLY];
35+
private const PROPERTY_MODIFIER_KINDS = [T_PRIVATE, T_PROTECTED, T_PUBLIC, T_VAR, FCT::T_READONLY, FCT::T_PRIVATE_SET, FCT::T_PROTECTED_SET, FCT::T_PUBLIC_SET];
3636

3737
public function getDefinition(): FixerDefinitionInterface
3838
{

tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,4 +653,49 @@ class A
653653
',
654654
];
655655
}
656+
657+
/**
658+
* @dataProvider provideFix84Cases
659+
*
660+
* @requires PHP 8.4
661+
*/
662+
public function testFix84(string $expected, ?string $input = null): void
663+
{
664+
$this->doTest($expected, $input);
665+
}
666+
667+
/**
668+
* @return iterable<string, array{0: string, 1?: string}>
669+
*/
670+
public static function provideFix84Cases(): iterable
671+
{
672+
yield 'asymmetric visibility' => [
673+
<<<'PHP'
674+
<?php class Foo
675+
{
676+
/** @var bool */
677+
public(set) bool $a;
678+
679+
/** @var bool */
680+
protected(set) bool $b;
681+
682+
/** @var bool */
683+
private(set) bool $c;
684+
}
685+
PHP,
686+
<<<'PHP'
687+
<?php class Foo
688+
{
689+
/** @var bool $a */
690+
public(set) bool $a;
691+
692+
/** @var bool $b */
693+
protected(set) bool $b;
694+
695+
/** @var bool $c */
696+
private(set) bool $c;
697+
}
698+
PHP,
699+
];
700+
}
656701
}

0 commit comments

Comments
 (0)