From efe2da55223586d940c20c71998ceac84c6e95a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kowalik?= Date: Wed, 13 Mar 2019 23:07:06 +0100 Subject: [PATCH] #654 drop support fro mb_ereg* functions --- src/Mutator/Extensions/MBString.php | 50 ------------- tests/Mutator/Extensions/MBStringTest.php | 90 ----------------------- 2 files changed, 140 deletions(-) diff --git a/src/Mutator/Extensions/MBString.php b/src/Mutator/Extensions/MBString.php index 633630c85a..9b789792c3 100644 --- a/src/Mutator/Extensions/MBString.php +++ b/src/Mutator/Extensions/MBString.php @@ -84,12 +84,6 @@ private function setupConverters(array $functionsMap): void { $converters = [ 'mb_chr' => $this->mapNameSkipArg('chr', 1), - 'mb_ereg_match' => $this->mapEreg($this->mapNameSkipArg('preg_match', 2), '^', '', [$this, 'warpEqOne']), - 'mb_ereg_replace_callback' => $this->mapEreg($this->mapNameSkipArg('preg_replace_callback', 3)), - 'mb_ereg_replace' => $this->mapEreg($this->mapNameSkipArg('preg_replace', 3)), - 'mb_ereg' => $this->mapEreg($this->mapName('preg_match'), '', '', [$this, 'warpTernary']), - 'mb_eregi_replace' => $this->mapEreg($this->mapNameSkipArg('preg_replace', 3), '', 'i'), - 'mb_eregi' => $this->mapEreg($this->mapName('preg_match'), '', 'i', [$this, 'warpTernary']), 'mb_ord' => $this->mapNameSkipArg('ord', 1), 'mb_parse_str' => $this->mapName('parse_str'), 'mb_send_mail' => $this->mapName('mail'), @@ -132,50 +126,6 @@ private function mapNameSkipArg(string $functionName, int $skipArgs): callable }; } - private function mapEreg(callable $baseConverter, string $prefix = '', string $modifiers = '', callable $warp = null): callable - { - return function (Node\Expr\FuncCall $node) use ($baseConverter, $prefix, $modifiers, $warp): Generator { - foreach ($baseConverter($node) as $newNode) { - /* @var Node\Expr\FuncCall $newNode */ - $newNode->args[0] = new Node\Arg( - new Node\Expr\BinaryOp\Concat( - new Node\Expr\BinaryOp\Concat( - new Node\Scalar\String_("/$prefix"), - new Node\Expr\FuncCall( - new Node\Name('\str_replace'), - [ - new Node\Arg(new Node\Scalar\String_('/')), - new Node\Arg(new Node\Scalar\String_('\/')), - new Node\Arg($newNode->args[0]->value), - ] - ) - ), - new Node\Scalar\String_("/$modifiers") - ) - ); - - yield $warp ? $warp($newNode) : $newNode; - } - }; - } - - private function warpEqOne(Node\Expr\FuncCall $node): Node - { - return new Node\Expr\BinaryOp\Identical( - $node, - new Node\Scalar\LNumber(1) - ); - } - - private function warpTernary(Node\Expr\FuncCall $node): Node - { - return new Node\Expr\Ternary( - $node, - new Node\Scalar\LNumber(1), - new Node\Expr\ConstFetch(new Node\Name('false')) - ); - } - private function mapConvertCase(): callable { return function (Node\Expr\FuncCall $node): Generator { diff --git a/tests/Mutator/Extensions/MBStringTest.php b/tests/Mutator/Extensions/MBStringTest.php index 4511907112..5bd128fce4 100644 --- a/tests/Mutator/Extensions/MBStringTest.php +++ b/tests/Mutator/Extensions/MBStringTest.php @@ -81,18 +81,6 @@ public function provideMutationCases(): Generator yield from $this->provideMutationCasesForChr(); - yield from $this->provideMutationCasesForEregMatch(); - - yield from $this->provideMutationCasesForEregReplaceCallback(); - - yield from $this->provideMutationCasesForEregReplace(); - - yield from $this->provideMutationCasesForEreg(); - - yield from $this->provideMutationCasesForEregiReplace(); - - yield from $this->provideMutationCasesForEregi(); - yield from $this->provideMutationCasesForOrd(); yield from $this->provideMutationCasesForParseStr(); @@ -143,84 +131,6 @@ private function provideMutationCasesForChr(): Generator ]; } - private function provideMutationCasesForEregMatch(): Generator - { - yield 'It converts mb_ereg_match to preg_match' => [ - " [ - " [ - " [ - " [ - " [ - " [ - " [ - " [ - " [ - " [ - " [ - " [