diff --git a/README.md b/README.md index a25d626..4b8787b 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ DB::select(DB::raw('select 1')); ### After ```php -DB::select(DB::raw('select 1')->getValue(DB::getQueryGrammar())); +DB::select('select 1'); ``` ## License diff --git a/src/LaravelDatabaseExpressionsRector.php b/src/LaravelDatabaseExpressionsRector.php index 88a676d..df8edcd 100644 --- a/src/LaravelDatabaseExpressionsRector.php +++ b/src/LaravelDatabaseExpressionsRector.php @@ -23,7 +23,7 @@ public function getRuleDefinition(): RuleDefinition [ new CodeSample( "DB::select(DB::raw('select 1'));", - "DB::select(DB::raw('select 1')->getValue(DB::getQueryGrammar()));" + "DB::select('select 1');" ), ] ); @@ -60,18 +60,7 @@ public function refactor(Node $node): ?Node return null; } - $arguments[] = new Arg( - new StaticCall( - new Name('DB'), - 'getQueryGrammar' - ) - ); - - $node->args[0]->value = new MethodCall( - $childNode, - new Identifier('getValue'), - $arguments - ); + $node->args[0]->value = $childNode->args[0]->value; return $node; } diff --git a/tests/fixture/TestFixture.php.inc b/tests/fixture/TestFixture.php.inc index f05cef3..3b0fe68 100644 --- a/tests/fixture/TestFixture.php.inc +++ b/tests/fixture/TestFixture.php.inc @@ -24,16 +24,16 @@ declare(strict_types=1); use Illuminate\Support\Facades\DB; -DB::select(DB::raw('select 1')->getValue(DB::getQueryGrammar())); +DB::select('select 1'); DB::select( - DB::raw('select 2')->getValue(DB::getQueryGrammar()) + 'select 2' ); $orders = DB::table('orders') - ->selectRaw(DB::raw('price * ? as price_with_tax')->getValue(DB::getQueryGrammar()), [1.0825]) + ->selectRaw('price * ? as price_with_tax', [1.0825]) ->get(); $orders = DB::table('orders') - ->whereRaw(DB::raw('price > IF(state = "TX", ?, 100)')->getValue(DB::getQueryGrammar()), [200]) + ->whereRaw('price > IF(state = "TX", ?, 100)', [200]) ->get();