From bf50512f6f128d5046bb203810b485adeb812c9a Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Tue, 18 Jan 2022 09:18:44 +0100 Subject: [PATCH] Do not run `ChangeReadOnlyPropertyWithDefaultValueToConstantRector` on properties with attributes --- .../Fixture/skip_attribute.php.inc | 9 +++++++++ ...adOnlyPropertyWithDefaultValueToConstantRector.php | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 rules-tests/Privatization/Rector/Property/ChangeReadOnlyPropertyWithDefaultValueToConstantRector/Fixture/skip_attribute.php.inc diff --git a/rules-tests/Privatization/Rector/Property/ChangeReadOnlyPropertyWithDefaultValueToConstantRector/Fixture/skip_attribute.php.inc b/rules-tests/Privatization/Rector/Property/ChangeReadOnlyPropertyWithDefaultValueToConstantRector/Fixture/skip_attribute.php.inc new file mode 100644 index 00000000000..1a5211275b8 --- /dev/null +++ b/rules-tests/Privatization/Rector/Property/ChangeReadOnlyPropertyWithDefaultValueToConstantRector/Fixture/skip_attribute.php.inc @@ -0,0 +1,9 @@ +isObjectType($classLike, new ObjectType('PHP_CodeSniffer\Sniffs\Sniff')); + if ($property->attrGroups !== []) { + return true; + } + + if ($this->isObjectType($classLike, new ObjectType('PHP_CodeSniffer\Sniffs\Sniff'))) { + return true; + } + + return false; } }