diff --git a/src/Mutator/Extensions/BCMath.php b/src/Mutator/Extensions/BCMath.php index d734724019..921d32f4bf 100644 --- a/src/Mutator/Extensions/BCMath.php +++ b/src/Mutator/Extensions/BCMath.php @@ -217,6 +217,10 @@ private static function makeCastToStringMapper(Closure $converter): Closure private static function makeBinaryOperatorMapper(string $operator): Closure { return static function (Node\Expr\FuncCall $node) use ($operator): iterable { + if ($node->args[0] instanceof Node\VariadicPlaceholder || $node->args[1] instanceof Node\VariadicPlaceholder) { + return []; + } + yield new $operator($node->args[0]->value, $node->args[1]->value); }; } @@ -237,6 +241,10 @@ private static function makeSquareRootsMapper(): Closure private static function makePowerModuloMapper(): Closure { return static function (Node\Expr\FuncCall $node): iterable { + if ($node->args[2] instanceof Node\VariadicPlaceholder) { + return []; + } + yield new Node\Expr\BinaryOp\Mod( new Node\Expr\FuncCall( new Node\Name('\pow'), diff --git a/src/Mutator/Extensions/MBString.php b/src/Mutator/Extensions/MBString.php index 7bf1199817..10742cac30 100644 --- a/src/Mutator/Extensions/MBString.php +++ b/src/Mutator/Extensions/MBString.php @@ -202,6 +202,10 @@ private static function getConvertCaseModeValue(Node\Expr\FuncCall $node): ?int return null; } + if ($node->args[1] instanceof Node\VariadicPlaceholder) { + return null; + } + $mode = $node->args[1]->value; if ($mode instanceof Node\Scalar\LNumber) { @@ -244,7 +248,7 @@ private static function isInMbCaseMode(int $mode, string ...$cases): bool } /** - * @param Node\Arg[] $args + * @param array $args */ private static function mapFunctionCall(Node\Expr\FuncCall $node, string $newFuncName, array $args): Node\Expr\FuncCall { diff --git a/src/Mutator/Regex/AbstractPregMatch.php b/src/Mutator/Regex/AbstractPregMatch.php index 0d46860f93..cf5824386d 100644 --- a/src/Mutator/Regex/AbstractPregMatch.php +++ b/src/Mutator/Regex/AbstractPregMatch.php @@ -60,14 +60,16 @@ abstract class AbstractPregMatch implements Mutator */ public function mutate(Node $node): iterable { - $arguments = $node->args; - $firstArgument = $arguments[0]; - $originalRegex = $this->pullOutRegex($firstArgument); + if ($node->args[0] instanceof Node\VariadicPlaceholder) { + return []; + } + + $originalRegex = $this->pullOutRegex($node->args[0]); foreach ($this->mutateRegex($originalRegex) as $mutatedRegex) { - $newArgument = $this->getNewRegexArgument($mutatedRegex, $firstArgument); + $newArgument = $this->getNewRegexArgument($mutatedRegex, $node->args[0]); - yield new FuncCall($node->name, [$newArgument] + $arguments, $node->getAttributes()); + yield new FuncCall($node->name, [$newArgument] + $node->args, $node->getAttributes()); } } @@ -76,6 +78,7 @@ public function canMutate(Node $node): bool return $node instanceof FuncCall && $node->name instanceof Node\Name && strtolower((string) $node->name) === 'preg_match' + && $node->args[0] instanceof Node\Arg && $node->args[0]->value instanceof Node\Scalar\String_ && $this->isProperRegexToMutate($this->pullOutRegex($node->args[0])); } diff --git a/src/Mutator/Regex/PregMatchMatches.php b/src/Mutator/Regex/PregMatchMatches.php index a7b328dcad..310af0e3b6 100644 --- a/src/Mutator/Regex/PregMatchMatches.php +++ b/src/Mutator/Regex/PregMatchMatches.php @@ -89,6 +89,10 @@ public static function getDefinition(): ?Definition */ public function mutate(Node $node): iterable { + if ($node->args[2] instanceof Node\VariadicPlaceholder) { + return []; + } + yield new Node\Expr\Cast\Int_(new Node\Expr\Assign($node->args[2]->value, new Node\Expr\Array_())); } diff --git a/src/Mutator/Regex/PregQuote.php b/src/Mutator/Regex/PregQuote.php index f6dbb3db28..072cf1d8d8 100644 --- a/src/Mutator/Regex/PregQuote.php +++ b/src/Mutator/Regex/PregQuote.php @@ -84,6 +84,10 @@ public static function getDefinition(): ?Definition */ public function mutate(Node $node): iterable { + if ($node->args[0] instanceof Node\VariadicPlaceholder) { + return []; + } + yield $node->args[0]; } diff --git a/src/Mutator/Unwrap/AbstractUnwrapMutator.php b/src/Mutator/Unwrap/AbstractUnwrapMutator.php index 6fb42c6834..f9c48ae314 100644 --- a/src/Mutator/Unwrap/AbstractUnwrapMutator.php +++ b/src/Mutator/Unwrap/AbstractUnwrapMutator.php @@ -58,6 +58,10 @@ abstract class AbstractUnwrapMutator implements Mutator final public function mutate(Node $node): iterable { foreach ($this->getParameterIndexes($node) as $index) { + if ($node->args[$index] instanceof Node\VariadicPlaceholder) { + continue; + } + if ($node->args[$index]->unpack) { continue; }