Skip to content

Commit 59e103d

Browse files
committed
Extract magic 'isAttribute' string into constant
1 parent 6c8e7db commit 59e103d

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/Rules/AttributesCheck.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
final class AttributesCheck
2525
{
2626

27+
public const IS_ATTRIBUTE = 'isAttribute';
28+
2729
public function __construct(
2830
private ReflectionProvider $reflectionProvider,
2931
private FunctionCallParametersCheck $functionCallParametersCheck,
@@ -146,7 +148,7 @@ public function check(
146148
$attributeClassName = SprintfHelper::escapeFormatString($attributeClass->getDisplayName());
147149

148150
$nodeAttributes = $attribute->getAttributes();
149-
$nodeAttributes['isAttribute'] = true;
151+
$nodeAttributes[self::IS_ATTRIBUTE] = true;
150152

151153
$parameterErrors = $this->functionCallParametersCheck->check(
152154
ParametersAcceptorSelector::selectFromArgs(

‎src/Rules/FunctionCallParametersCheck.php‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ public function check(
272272
];
273273
}
274274

275-
if ($hasNamedArguments && !$scope->getPhpVersion()->supportsNamedArguments()->yes() && !(bool) $funcCall->getAttribute('isAttribute', false)) {
275+
if (
276+
$hasNamedArguments
277+
&& !$scope->getPhpVersion()->supportsNamedArguments()->yes()
278+
&& !(bool) $funcCall->getAttribute(AttributesCheck::IS_ATTRIBUTE, false)
279+
) {
276280
$errors[] = RuleErrorBuilder::message('Named arguments are supported only on PHP 8.0 and later.')
277281
->identifier('argument.namedNotSupported')
278282
->line($funcCallLine)
@@ -920,7 +924,7 @@ private function createPositionalArgumentsFix(
920924
{
921925
if (
922926
// the call was created from an attribute, it is not in the file
923-
(bool) $funcCall->getAttribute('isAttribute', false)
927+
(bool) $funcCall->getAttribute(AttributesCheck::IS_ATTRIBUTE, false)
924928
|| (bool) $funcCall->getAttribute(self::NOT_FIXABLE_CALL_ATTRIBUTE, false)
925929
) {
926930
return false;

0 commit comments

Comments
 (0)