diff --git a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc index f13253d301..1e3d9bbcdc 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc +++ b/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.1.inc @@ -140,11 +140,11 @@ function moreParamSecond(LogicException $bar, Exception $foo) { // phpcs:set Generic.CodeAnalysis.UnusedFunctionParameter ignoreTypeHints[] class ConstructorPropertyPromotionNoContentInMethod { - public function __construct(protected int $id) {} + public function __construct(protected int $id, private(set) $foo) {} } class ConstructorPropertyPromotionWithContentInMethod { - public function __construct(protected int $id, $toggle = true) { + public function __construct(protected int $id, private(set) $foo, $toggle = true) { if ($toggle === true) { doSomething(); } diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc index fb5b1fd5a8..7474310537 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc @@ -75,7 +75,7 @@ class TypedProperties } class ConstructorPropertyPromotionWithTypes { - public function __construct(protected Float|Int $x, public ?STRING &$y = 'test', private mixed $z) {} + public function __construct(protected Float|Int $x, public(set) ?STRING &$y = 'test', private mixed $z) {} } class ConstructorPropertyPromotionAndNormalParams { diff --git a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed index 10be06b0bb..4814ea8596 100644 --- a/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed @@ -75,7 +75,7 @@ class TypedProperties } class ConstructorPropertyPromotionWithTypes { - public function __construct(protected float|int $x, public ?string &$y = 'test', private mixed $z) {} + public function __construct(protected float|int $x, public(set) ?string &$y = 'test', private mixed $z) {} } class ConstructorPropertyPromotionAndNormalParams { diff --git a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc index 7d81893c66..4d0ca8ff57 100644 --- a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc +++ b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc @@ -105,3 +105,11 @@ class SkipOverPHP84FinalProperties { final MyType|false $propA; private static final null|MyClass $propB; } + +// PHP 8.4 asymmetric visibility +class WithAsym { + private(set) null|true $asym1 = TRUE; + public private(set) ?bool $asym2 = false; + protected(set) false|string|null $asym3 = null; + public protected(set) Type|null|bool $asym4 = true; +} diff --git a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc.fixed b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc.fixed index 26e20f290e..831f1161de 100644 --- a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc.fixed @@ -105,3 +105,11 @@ class SkipOverPHP84FinalProperties { final MyType|false $propA; private static final null|MyClass $propB; } + +// PHP 8.4 asymmetric visibility +class WithAsym { + private(set) null|true $asym1 = TRUE; + public private(set) ?bool $asym2 = FALSE; + protected(set) false|string|null $asym3 = NULL; + public protected(set) Type|null|bool $asym4 = TRUE; +} diff --git a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php index 481c4ab1c7..7738b94d79 100644 --- a/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.php @@ -31,27 +31,30 @@ final class UpperCaseConstantUnitTest extends AbstractSniffUnitTest public function getErrorList() { return [ - 7 => 1, - 10 => 1, - 15 => 1, - 16 => 1, - 23 => 1, - 26 => 1, - 31 => 1, - 32 => 1, - 39 => 1, - 42 => 1, - 47 => 1, - 48 => 1, - 70 => 1, - 71 => 1, - 85 => 1, - 87 => 1, - 88 => 1, - 90 => 2, - 92 => 2, - 93 => 1, - 98 => 2, + 7 => 1, + 10 => 1, + 15 => 1, + 16 => 1, + 23 => 1, + 26 => 1, + 31 => 1, + 32 => 1, + 39 => 1, + 42 => 1, + 47 => 1, + 48 => 1, + 70 => 1, + 71 => 1, + 85 => 1, + 87 => 1, + 88 => 1, + 90 => 2, + 92 => 2, + 93 => 1, + 98 => 2, + 112 => 1, + 113 => 1, + 114 => 1, ]; }//end getErrorList() diff --git a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.1.inc b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.1.inc index 2503f599d2..f134c16e01 100644 --- a/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.1.inc +++ b/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.1.inc @@ -109,7 +109,7 @@ class OnlyConstructorPropertyPromotion { class ConstructorPropertyPromotionMixedWithNormalParams { public function __construct( - public string $name = '', + public(set) string $name = '', ?int $optionalParam = 0, mixed $requiredParam, ) {} diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc index 87c3bdf2e7..361cc91bf3 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc @@ -155,3 +155,17 @@ enum SomeEnum $bar_foo = 3; } } + +class AsymVisibility { + // The read scope is public, but not specified. Enforce the naming conventions anyway. + private(set) $asymPublicImplied = 'hello'; + private(set) $_asymPublicImplied = 'hello'; + + // The read scope is private, so these properties should be handled as private properties. + private private(set) $asymPrivate = 'hello'; + private(set) private $_asymPrivate = 'hello'; + + // The read scope is public/protected, so these properties should be handled as public properties. + public private(set) $asymPublicPrivate = 'hello'; + private(set) protected $_asymPrivateProtected = 'hello'; +} diff --git a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php index d8d8695c6e..96ae98a0ab 100644 --- a/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -68,6 +68,9 @@ public function getErrorList() 146 => 1, 152 => 1, 155 => 1, + 162 => 1, + 165 => 1, + 170 => 1, ]; return $errors; diff --git a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc index 3325e1152d..f3ea469de4 100644 --- a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc +++ b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.inc @@ -129,3 +129,17 @@ enum SomeEnum $bar_foo = 3; } } + +class AsymVisibility { + // The read scope is public, but not specified. Enforce the naming conventions anyway. + private(set) $asymPublicImplied = 'hello'; + private(set) $_asymPublicImplied = 'hello'; + + // The read scope is private, so these properties should be handled as private properties. + private private(set) $asymPrivate = 'hello'; + private(set) private $_asymPrivate = 'hello'; + + // The read scope is public/protected, so these properties should be handled as public properties. + protected private(set) $asymProtectedPrivate = 'hello'; + private(set) public $_asymPrivatePublic = 'hello'; +} diff --git a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php index c66a2a42c8..7e6202715b 100644 --- a/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/src/Standards/Zend/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -61,6 +61,10 @@ public function getErrorList() 121 => 1, 126 => 1, 129 => 1, + 136 => 1, + 139 => 1, + 143 => 1, + 144 => 1, ]; }//end getErrorList()