From 236ed91a00e58c1deac017e53bfef4fa3383a318 Mon Sep 17 00:00:00 2001 From: Takayasu Oyama Date: Wed, 19 Jul 2023 17:12:24 +0900 Subject: [PATCH] feat: stop using call_user_func (#121) * feat: stop using call_user_func * add changelog --- CHANGELOG.md | 1 + src/Concerns/ManagesStaleReads.php | 4 +--- src/Connection.php | 2 +- src/Schema/Builder.php | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8f54c9b..4a007c89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Added Changed - `Connection::waitForOperation` and `Connection::isDoneOperation` has been removed. (#99) - Update `export-ignore` entries in `.gitattributes` (#104) +- Stop using `call_user_func` (#121) Fixed - Transaction state was not being cleared if rolled back failed. (#107) diff --git a/src/Concerns/ManagesStaleReads.php b/src/Concerns/ManagesStaleReads.php index c2df1d85..29fac4de 100644 --- a/src/Concerns/ManagesStaleReads.php +++ b/src/Concerns/ManagesStaleReads.php @@ -33,9 +33,7 @@ public function cursorWithTimestampBound($query, $bindings = [], TimestampBoundI { return $this->run($query, $bindings, function ($query, $bindings) use ($timestampBound) { if ($this->pretending()) { - return call_user_func(function() { - yield from []; - }); + return (static fn() => yield from [])(); } $options = ['parameters' => $this->prepareBindings($bindings)]; diff --git a/src/Connection.php b/src/Connection.php index b475726a..4890105a 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -276,7 +276,7 @@ public function cursor($query, $bindings = [], $useReadPdo = true): Generator { return $this->run($query, $bindings, function ($query, $bindings) { if ($this->pretending()) { - return call_user_func(function() { yield from []; }); + return (static fn() => yield from [])(); } return $this->getDatabaseContext() diff --git a/src/Schema/Builder.php b/src/Schema/Builder.php index 9ff8d3eb..1c9c911d 100644 --- a/src/Schema/Builder.php +++ b/src/Schema/Builder.php @@ -108,7 +108,7 @@ public function dropIndexIfExist($table, $name) protected function createBlueprint($table, Closure $callback = null) { return isset($this->resolver) - ? call_user_func($this->resolver, $table, $callback) + ? ($this->resolver)($table, $callback) : new Blueprint($table, $callback); } }