diff --git a/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php b/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php index e78d6399c63..b22529f91cb 100644 --- a/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php +++ b/rules/Arguments/Rector/MethodCall/RemoveMethodCallParamRector.php @@ -68,6 +68,10 @@ public function refactor(Node $node): ?Node { $hasChanged = false; + if ($node->isFirstClassCallable()) { + return null; + } + foreach ($this->removeMethodCallParams as $removeMethodCallParam) { if (! $this->isName($node->name, $removeMethodCallParam->getMethodName())) { continue; diff --git a/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php b/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php index 1d11986c90e..a31ba483e28 100644 --- a/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php +++ b/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php @@ -132,6 +132,10 @@ private function refactorThrow(Throw_ $throw, Variable $catchedThrowableVariable return null; } + if ($new->isFirstClassCallable()) { + return null; + } + // exception is bundled if (isset($new->getArgs()[$exceptionArgumentPosition])) { return null; diff --git a/rules/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php b/rules/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php index 7a5dfa23c5c..3b919088b69 100644 --- a/rules/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php +++ b/rules/CodeQuality/Rector/ClassMethod/OptionalParametersAfterRequiredRector.php @@ -119,6 +119,10 @@ private function refactorNew(New_ $new, Scope $scope): ?New_ return null; } + if ($new->isFirstClassCallable()) { + return null; + } + $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromNew($new); if (! $methodReflection instanceof MethodReflection) { return null; @@ -136,6 +140,10 @@ private function refactorNew(New_ $new, Scope $scope): ?New_ private function refactorMethodCall(MethodCall|StaticCall $methodCall, Scope $scope): MethodCall|StaticCall|null { + if ($methodCall->isFirstClassCallable()) { + return null; + } + $methodReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($methodCall); if (! $methodReflection instanceof MethodReflection) { return null; diff --git a/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php b/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php index 13b788f2c66..6c99d5b6bc4 100644 --- a/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/BoolvalToTypeCastRector.php @@ -59,6 +59,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + if ($node->isFirstClassCallable()) { + return null; + } + if (! $this->isName($node, 'boolval')) { return null; } diff --git a/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php b/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php index 31d4e6a59b0..50868f172c8 100644 --- a/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php +++ b/rules/CodeQuality/Rector/FuncCall/CallUserFuncWithArrowFunctionToInlineRector.php @@ -67,6 +67,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + if ($node->isFirstClassCallable()) { + return null; + } + if (! $this->isName($node, 'call_user_func')) { return null; } diff --git a/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php b/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php index 22983587b5c..06cbc0a25ca 100644 --- a/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php +++ b/rules/CodeQuality/Rector/FuncCall/FloatvalToTypeCastRector.php @@ -76,9 +76,9 @@ public function refactor(Node $node): ?Node return null; } - // if (! isset($node->getArgs[0])) { - // return null; - // } + if ($node->isFirstClassCallable()) { + return null; + } $firstArg = $node->getArgs()[0]; diff --git a/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php b/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php index 02925611043..eeca6882232 100644 --- a/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php +++ b/rules/CodeQuality/Rector/FuncCall/IsAWithStringWithThirdArgumentRector.php @@ -63,6 +63,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (isset($node->getArgs()[2])) { return null; } diff --git a/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php b/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php index 9635ad56d83..a3529e24a8b 100644 --- a/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php +++ b/rules/CodeQuality/Rector/FuncCall/RemoveSoleValueSprintfRector.php @@ -62,6 +62,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (count($node->getArgs()) !== 2) { return null; } diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php index 6a4c7d65fd5..185413da134 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyFuncGetArgsCountRector.php @@ -40,6 +40,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + $firstArg = $node->getArgs()[0]; if (! $firstArg->value instanceof FuncCall) { diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php index 06790b28c1c..2b5893b4c76 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyInArrayValuesRector.php @@ -41,6 +41,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (! isset($node->args[1])) { return null; } diff --git a/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php b/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php index 631c60fa207..10ab3dd5f14 100644 --- a/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SimplifyStrposLowerRector.php @@ -41,6 +41,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (! isset($node->getArgs()[0])) { return null; } diff --git a/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php b/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php index 003e0b24305..229cf7f579f 100644 --- a/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php +++ b/rules/CodeQuality/Rector/FuncCall/SingleInArrayToCompareRector.php @@ -71,6 +71,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (! isset($node->args[1])) { return null; } diff --git a/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php b/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php index 9439af070f9..fb7869fd332 100644 --- a/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php +++ b/rules/CodeQuality/Rector/Identical/GetClassToInstanceOfRector.php @@ -78,6 +78,10 @@ public function refactor(Node $node): ?Node /** @var FuncCall $secondExpr */ $secondExpr = $twoNodeMatch->getSecondExpr(); + if ($secondExpr->isFirstClassCallable()) { + return null; + } + if (! isset($secondExpr->getArgs()[0])) { return null; } diff --git a/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php b/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php index 18dfa5b4a7f..4916b31cedd 100644 --- a/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php +++ b/rules/CodeQuality/Rector/If_/ExplicitBoolCompareRector.php @@ -152,6 +152,10 @@ private function resolveNewConditionNode(Expr $expr, bool $isNegated): ?BinaryOp private function resolveCount(bool $isNegated, FuncCall $funcCall): Identical | Greater | null { + if ($funcCall->isFirstClassCallable()) { + return null; + } + $countedType = $this->getType($funcCall->getArgs()[0]->value); if ($countedType->isArray()->yes()) { diff --git a/rules/CodingStyle/Rector/Class_/AddArrayDefaultToArrayPropertyRector.php b/rules/CodingStyle/Rector/Class_/AddArrayDefaultToArrayPropertyRector.php index f325f9df4a3..7fcb29c8049 100644 --- a/rules/CodingStyle/Rector/Class_/AddArrayDefaultToArrayPropertyRector.php +++ b/rules/CodingStyle/Rector/Class_/AddArrayDefaultToArrayPropertyRector.php @@ -184,6 +184,10 @@ private function clearNotNullBeforeCount(Class_ $class, array $propertyNames): v return false; } + if ($node->isFirstClassCallable()) { + return false; + } + if (! $this->isName($node, 'count')) { return false; } diff --git a/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php b/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php index 907c27a14d3..2a6ae379672 100644 --- a/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CallUserFuncToMethodCallRector.php @@ -70,6 +70,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (! isset($node->getArgs()[0])) { return null; } diff --git a/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php b/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php index 717a49d7c61..5fb70a0144c 100644 --- a/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php +++ b/rules/CodingStyle/Rector/FuncCall/ConsistentImplodeRector.php @@ -74,6 +74,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (count($node->getArgs()) === 1) { // complete default value '' $node->args[1] = $node->getArgs()[0]; diff --git a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php index cdedd61160c..c6fcbfd9012 100644 --- a/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php +++ b/rules/CodingStyle/Rector/FuncCall/CountArrayToEmptyArrayComparisonRector.php @@ -192,6 +192,10 @@ private function matchCountFuncCallArgExpr(Expr $expr): ?Expr return null; } + if ($expr->isFirstClassCallable()) { + return null; + } + $firstArg = $expr->getArgs()[0]; return $firstArg->value; } diff --git a/rules/DeadCode/NodeManipulator/CountManipulator.php b/rules/DeadCode/NodeManipulator/CountManipulator.php index 8d54cf0e26a..493048557ec 100644 --- a/rules/DeadCode/NodeManipulator/CountManipulator.php +++ b/rules/DeadCode/NodeManipulator/CountManipulator.php @@ -102,6 +102,10 @@ private function isCountWithExpression(Expr $node, Expr $expr): bool return false; } + if ($node->isFirstClassCallable()) { + return false; + } + if (! isset($node->getArgs()[0])) { return false; } diff --git a/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php b/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php index 627017299bc..4ec09f47537 100644 --- a/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php +++ b/rules/MysqlToMysqli/Rector/FuncCall/MysqlFuncCallToMysqliRector.php @@ -97,6 +97,10 @@ public function refactor(Node $node): ?FuncCall private function processMysqlCreateDb(FuncCall $funcCall): ?FuncCall { + if ($funcCall->isFirstClassCallable()) { + return null; + } + if (! isset($funcCall->getArgs()[0])) { return null; } @@ -113,6 +117,10 @@ private function processMysqlCreateDb(FuncCall $funcCall): ?FuncCall private function processMysqlDropDb(FuncCall $funcCall): ?FuncCall { + if ($funcCall->isFirstClassCallable()) { + return null; + } + if (! isset($funcCall->getArgs()[0])) { return null; } diff --git a/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php b/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php index 0ce4c8069d8..e083e792243 100644 --- a/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php +++ b/rules/MysqlToMysqli/Rector/FuncCall/MysqlPConnectToMysqliConnectRector.php @@ -67,6 +67,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (! isset($node->getArgs()[0])) { return null; } diff --git a/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php b/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php index 75953cd001f..d7b889e855f 100644 --- a/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php +++ b/rules/MysqlToMysqli/Rector/FuncCall/MysqlQueryMysqlErrorWithLinkRector.php @@ -126,6 +126,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + if ($node->isFirstClassCallable()) { + return null; + } + foreach (self::FUNCTION_RENAME_MAP as $oldFunction => $newFunction) { if (! $this->isName($node, $oldFunction)) { continue; diff --git a/rules/Naming/Naming/VariableNaming.php b/rules/Naming/Naming/VariableNaming.php index 27086ac3810..2eed75bca57 100644 --- a/rules/Naming/Naming/VariableNaming.php +++ b/rules/Naming/Naming/VariableNaming.php @@ -186,6 +186,10 @@ private function resolveBareFuncCallArgumentName( string $fallbackName, string $suffix ): string { + if ($funcCall->isFirstClassCallable()) { + return ''; + } + if (! isset($funcCall->getArgs()[0])) { return ''; } diff --git a/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php b/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php index a1ff3e857e5..b07aebd9900 100644 --- a/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php +++ b/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php @@ -63,6 +63,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (count($node->args) !== 1) { return null; } diff --git a/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php b/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php index 19ffd95a1f0..c0953f72bfc 100644 --- a/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php +++ b/rules/Php70/Rector/FuncCall/EregToPregMatchRector.php @@ -100,6 +100,10 @@ private function shouldSkipFuncCall(FuncCall $funcCall): bool return true; } + if ($funcCall->isFirstClassCallable()) { + return true; + } + return ! isset($funcCall->getArgs()[0]); } diff --git a/rules/Php70/Rector/FuncCall/MultiDirnameRector.php b/rules/Php70/Rector/FuncCall/MultiDirnameRector.php index 65a69da5218..7b6e3559f8c 100644 --- a/rules/Php70/Rector/FuncCall/MultiDirnameRector.php +++ b/rules/Php70/Rector/FuncCall/MultiDirnameRector.php @@ -87,6 +87,10 @@ private function matchNestedDirnameFuncCall(FuncCall $funcCall): ?FuncCall return null; } + if ($funcCall->isFirstClassCallable()) { + return null; + } + $args = $funcCall->getArgs(); if (count($args) >= 3) { return null; diff --git a/rules/Php71/IsArrayAndDualCheckToAble.php b/rules/Php71/IsArrayAndDualCheckToAble.php index 843109323be..34a2b12d640 100644 --- a/rules/Php71/IsArrayAndDualCheckToAble.php +++ b/rules/Php71/IsArrayAndDualCheckToAble.php @@ -55,6 +55,10 @@ public function processBooleanOr(BooleanOr $booleanOr, string $type, string $new return null; } + if ($funcCallExpr->isFirstClassCallable()) { + return null; + } + if (! isset($funcCallExpr->getArgs()[0])) { return null; } diff --git a/rules/Php71/Rector/FuncCall/CountOnNullRector.php b/rules/Php71/Rector/FuncCall/CountOnNullRector.php index f4f7a93c50c..26d77783add 100644 --- a/rules/Php71/Rector/FuncCall/CountOnNullRector.php +++ b/rules/Php71/Rector/FuncCall/CountOnNullRector.php @@ -156,6 +156,10 @@ private function shouldSkipFuncCall(FuncCall $funcCall): bool return true; } + if ($funcCall->isFirstClassCallable()) { + return true; + } + // skip ternary in trait, as impossible to analyse $trait = $this->betterNodeFinder->findParentType($funcCall, Trait_::class); if ($trait instanceof Trait_) { diff --git a/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php b/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php index 7c00ed1cb87..0ddfe8c69d5 100644 --- a/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php +++ b/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php @@ -85,6 +85,10 @@ public function refactor(Node $node): ?array /** @var FuncCall $eachFuncCall */ $eachFuncCall = $assign->expr; + if ($eachFuncCall->isFirstClassCallable()) { + return null; + } + if (! isset($eachFuncCall->getArgs()[0])) { return null; } diff --git a/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php b/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php index 1342350af23..af790ae1ea2 100644 --- a/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php +++ b/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php @@ -94,6 +94,10 @@ public function refactorWithScope(Node $node, Scope $scope): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + $firstArg = $node->getArgs()[0] ?? null; if (! $firstArg instanceof Arg) { return null; diff --git a/rules/Php72/Rector/FuncCall/StringifyDefineRector.php b/rules/Php72/Rector/FuncCall/StringifyDefineRector.php index 201c2e603c9..b17da18f0a9 100644 --- a/rules/Php72/Rector/FuncCall/StringifyDefineRector.php +++ b/rules/Php72/Rector/FuncCall/StringifyDefineRector.php @@ -77,6 +77,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (! isset($node->getArgs()[0])) { return null; } diff --git a/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php b/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php index cde9a633349..e5d7aa315cf 100644 --- a/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php +++ b/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php @@ -76,6 +76,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + $firstArg = $node->getArgs()[0]; $firstArgValue = $firstArg->value; diff --git a/rules/Php72/Rector/While_/WhileEachToForeachRector.php b/rules/Php72/Rector/While_/WhileEachToForeachRector.php index e72b193f7cd..dfa9654ebef 100644 --- a/rules/Php72/Rector/While_/WhileEachToForeachRector.php +++ b/rules/Php72/Rector/While_/WhileEachToForeachRector.php @@ -96,6 +96,10 @@ public function refactor(Node $node): ?Node /** @var FuncCall $eachFuncCall */ $eachFuncCall = $assignNode->expr; + if ($eachFuncCall->isFirstClassCallable()) { + return null; + } + /** @var List_ $listNode */ $listNode = $assignNode->var; diff --git a/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php b/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php index 10464fc23dc..690ed7d6a91 100644 --- a/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php +++ b/rules/Php73/Rector/FuncCall/ArrayKeyFirstLastRector.php @@ -159,6 +159,10 @@ private function processArrayKeyFirstLast( private function resolveKeyFuncCall(Stmt $nextStmt, FuncCall $resetOrEndFuncCall): ?FuncCall { + if ($resetOrEndFuncCall->isFirstClassCallable()) { + return null; + } + /** @var FuncCall|null */ return $this->betterNodeFinder->findFirst($nextStmt, function (Node $subNode) use ( $resetOrEndFuncCall @@ -171,6 +175,10 @@ private function resolveKeyFuncCall(Stmt $nextStmt, FuncCall $resetOrEndFuncCall return false; } + if ($subNode->isFirstClassCallable()) { + return false; + } + return $this->nodeComparator->areNodesEqual($resetOrEndFuncCall->getArgs()[0], $subNode->getArgs()[0]); }); } diff --git a/rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php b/rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php index 945dfde9e58..390406ebbef 100644 --- a/rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php +++ b/rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php @@ -83,6 +83,10 @@ private function shouldSkip(FuncCall $funcCall): bool return true; } + if ($funcCall->isFirstClassCallable()) { + return true; + } + if ($funcCall->args === null) { return true; } diff --git a/rules/Php73/Rector/FuncCall/SetCookieRector.php b/rules/Php73/Rector/FuncCall/SetCookieRector.php index 1c634e10d7d..017ba7f408c 100644 --- a/rules/Php73/Rector/FuncCall/SetCookieRector.php +++ b/rules/Php73/Rector/FuncCall/SetCookieRector.php @@ -98,6 +98,10 @@ private function shouldSkip(FuncCall $funcCall): bool return true; } + if ($funcCall->isFirstClassCallable()) { + return true; + } + $argsCount = count($funcCall->args); if ($argsCount <= 2) { return true; diff --git a/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php b/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php index 6546556c77e..b6906b2d7b1 100644 --- a/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php +++ b/rules/Php74/Rector/FuncCall/ArraySpreadInsteadOfArrayMergeRector.php @@ -204,6 +204,10 @@ private function isIteratorToArrayFuncCall(Expr $expr): bool return false; } + if ($expr->isFirstClassCallable()) { + return false; + } + return isset($expr->getArgs()[0]); } } diff --git a/rules/Php74/Rector/FuncCall/MoneyFormatToNumberFormatRector.php b/rules/Php74/Rector/FuncCall/MoneyFormatToNumberFormatRector.php index 073ac1604ab..2b4a1027865 100644 --- a/rules/Php74/Rector/FuncCall/MoneyFormatToNumberFormatRector.php +++ b/rules/Php74/Rector/FuncCall/MoneyFormatToNumberFormatRector.php @@ -86,6 +86,10 @@ public function refactorWithScope(Node $node, Scope $scope): ?array return null; } + if ($funcCall->isFirstClassCallable()) { + return null; + } + $args = $funcCall->getArgs(); if ($this->argsAnalyzer->hasNamedArg($args)) { return null; diff --git a/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php b/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php index aa1ea5e74cd..8eca4ebfca3 100644 --- a/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php +++ b/rules/Php74/Rector/StaticCall/ExportToReflectionFunctionRector.php @@ -75,6 +75,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + $firstArg = $node->getArgs()[0] ?? null; if (! $firstArg instanceof Arg) { return null; diff --git a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/SubstrMatchAndRefactor.php b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/SubstrMatchAndRefactor.php index 9cf7f745e83..b039a785035 100644 --- a/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/SubstrMatchAndRefactor.php +++ b/rules/Php80/MatchAndRefactor/StrStartsWithMatchAndRefactor/SubstrMatchAndRefactor.php @@ -72,6 +72,10 @@ private function isStrlenWithNeedleExpr(StrStartsWith $strStartsWith): bool { $substrFuncCall = $strStartsWith->getFuncCall(); + if ($substrFuncCall->isFirstClassCallable()) { + return false; + } + $firstArg = $substrFuncCall->getArgs()[1]; if (! $this->valueResolver->isValue($firstArg->value, 0)) { return false; @@ -99,6 +103,10 @@ private function isHardcodedStringWithLNumberLength(StrStartsWith $strStartsWith { $substrFuncCall = $strStartsWith->getFuncCall(); + if ($substrFuncCall->isFirstClassCallable()) { + return false; + } + $secondArg = $substrFuncCall->getArgs()[1]; if (! $this->valueResolver->isValue($secondArg->value, 0)) { return false; @@ -109,10 +117,6 @@ private function isHardcodedStringWithLNumberLength(StrStartsWith $strStartsWith return false; } - if ($substrFuncCall->isFirstClassCallable()) { - return false; - } - if (count($substrFuncCall->getArgs()) < 3) { return false; } diff --git a/rules/Php80/NodeManipulator/ResourceReturnToObject.php b/rules/Php80/NodeManipulator/ResourceReturnToObject.php index afc15581377..c00e8b4ff9d 100644 --- a/rules/Php80/NodeManipulator/ResourceReturnToObject.php +++ b/rules/Php80/NodeManipulator/ResourceReturnToObject.php @@ -226,6 +226,10 @@ private function shouldSkip(FuncCall $funcCall): bool return true; } + if ($funcCall->isFirstClassCallable()) { + return true; + } + if (! isset($funcCall->getArgs()[0])) { return true; } diff --git a/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php b/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php index ad431b01bb4..df2bcc4c39b 100644 --- a/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php +++ b/rules/Php80/Rector/FuncCall/ClassOnObjectRector.php @@ -68,6 +68,10 @@ public function refactor(Node $node): ?Node return null; } + if ($node->isFirstClassCallable()) { + return null; + } + if (! isset($node->getArgs()[0])) { return new ClassConstFetch(new Name('self'), 'class'); } diff --git a/rules/Php80/Rector/NotIdentical/StrContainsRector.php b/rules/Php80/Rector/NotIdentical/StrContainsRector.php index 9f4ebe8c17b..ebc2065dc9b 100644 --- a/rules/Php80/Rector/NotIdentical/StrContainsRector.php +++ b/rules/Php80/Rector/NotIdentical/StrContainsRector.php @@ -87,6 +87,10 @@ public function refactor(Node $node): ?Node return null; } + if ($funcCall->isFirstClassCallable()) { + return null; + } + if (isset($funcCall->getArgs()[2])) { $secondArg = $funcCall->getArgs()[2]; diff --git a/rules/Php80/Rector/Ternary/GetDebugTypeRector.php b/rules/Php80/Rector/Ternary/GetDebugTypeRector.php index bff54818f12..e513f4b2d9d 100644 --- a/rules/Php80/Rector/Ternary/GetDebugTypeRector.php +++ b/rules/Php80/Rector/Ternary/GetDebugTypeRector.php @@ -145,6 +145,10 @@ private function areValuesIdentical(Ternary $ternary): bool /** @var FuncCall $isObjectFuncCall */ $isObjectFuncCall = $ternary->cond; + if ($isObjectFuncCall->isFirstClassCallable()) { + return false; + } + $firstExpr = $isObjectFuncCall->getArgs()[0] ->value; diff --git a/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php b/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php index 48fed8d29d3..3d383351e42 100644 --- a/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php +++ b/rules/Php80/ValueObjectFactory/StrStartsWithFactory.php @@ -11,6 +11,10 @@ final class StrStartsWithFactory { public function createFromFuncCall(FuncCall $funcCall, bool $isPositive): ?StrStartsWith { + if ($funcCall->isFirstClassCallable()) { + return null; + } + if (count($funcCall->getArgs()) < 2) { return null; } diff --git a/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php b/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php index bb8ec89faac..5b721a8cbb5 100644 --- a/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php +++ b/rules/Php81/NodeAnalyzer/ComplexNewAnalyzer.php @@ -26,6 +26,10 @@ public function isDynamic(New_ $new): bool return true; } + if ($new->isFirstClassCallable()) { + return false; + } + $args = $new->getArgs(); foreach ($args as $arg) { diff --git a/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php b/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php index fd01d728e2a..a8147fa28fd 100644 --- a/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php +++ b/rules/Transform/Rector/MethodCall/MethodCallToFuncCallRector.php @@ -69,6 +69,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + if ($node->isFirstClassCallable()) { + return null; + } + foreach ($this->methodCallsToFuncCalls as $methodCallToFuncCall) { if (! $this->isName($node->name, $methodCallToFuncCall->getMethodName())) { continue; diff --git a/rules/Transform/Rector/New_/NewArgToMethodCallRector.php b/rules/Transform/Rector/New_/NewArgToMethodCallRector.php index b13be6e1e8f..d0d9630164f 100644 --- a/rules/Transform/Rector/New_/NewArgToMethodCallRector.php +++ b/rules/Transform/Rector/New_/NewArgToMethodCallRector.php @@ -70,6 +70,10 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + if ($node->isFirstClassCallable()) { + return null; + } + foreach ($this->newArgsToMethodCalls as $newArgToMethodCall) { if (! $this->isObjectType($node->class, $newArgToMethodCall->getObjectType())) { continue;