diff --git a/lib/Db/AbstractStatement.php b/lib/Db/AbstractStatement.php index 8390194..f787cbc 100644 --- a/lib/Db/AbstractStatement.php +++ b/lib/Db/AbstractStatement.php @@ -18,18 +18,18 @@ abstract class AbstractStatement implements Statement { return $this->runArray($values); } - public function rebind(...$bindings): bool { - return $this->rebindArray($bindings); + public function retype(...$bindings): bool { + return $this->retypeArray($bindings); } - public function rebindArray(array $bindings, bool $append = false): bool { + public function retypeArray(array $bindings, bool $append = false): bool { if (!$append) { $this->types = []; } foreach ($bindings as $binding) { if (is_array($binding)) { // recursively flatten any arrays, which may be provided for SET or IN() clauses - $this->rebindArray($binding, true); + $this->retypeArray($binding, true); } else { $binding = trim(strtolower($binding)); if (strpos($binding, "strict ")===0) { diff --git a/lib/Db/PDOStatement.php b/lib/Db/PDOStatement.php index 6a2534d..d05255c 100644 --- a/lib/Db/PDOStatement.php +++ b/lib/Db/PDOStatement.php @@ -24,7 +24,7 @@ class PDOStatement extends AbstractStatement { public function __construct(\PDO $db, \PDOStatement $st, array $bindings = []) { $this->db = $db; $this->st = $st; - $this->rebindArray($bindings); + $this->retypeArray($bindings); } public function __destruct() { diff --git a/lib/Db/SQLite3/Statement.php b/lib/Db/SQLite3/Statement.php index 55da642..ee3cd44 100644 --- a/lib/Db/SQLite3/Statement.php +++ b/lib/Db/SQLite3/Statement.php @@ -31,7 +31,7 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement { public function __construct(\SQLite3 $db, \SQLite3Stmt $st, array $bindings = []) { $this->db = $db; $this->st = $st; - $this->rebindArray($bindings); + $this->retypeArray($bindings); } public function __destruct() { diff --git a/lib/Db/Statement.php b/lib/Db/Statement.php index 02677c4..b59e075 100644 --- a/lib/Db/Statement.php +++ b/lib/Db/Statement.php @@ -29,6 +29,6 @@ interface Statement { public function run(...$values): Result; public function runArray(array $values = []): Result; - public function rebind(...$bindings): bool; - public function rebindArray(array $bindings): bool; + public function retype(...$bindings): bool; + public function retypeArray(array $bindings): bool; } diff --git a/tests/cases/Db/SQLite3/TestStatement.php b/tests/cases/Db/SQLite3/TestStatement.php index 4bcb326..dcb0e2a 100644 --- a/tests/cases/Db/SQLite3/TestStatement.php +++ b/tests/cases/Db/SQLite3/TestStatement.php @@ -35,10 +35,10 @@ class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest { $s = new self::$imp($this->c, $nativeStatement); $types = array_unique(Statement::TYPES); foreach ($types as $type) { - $s->rebindArray([$strict ? "strict $type" : $type]); + $s->retypeArray([$strict ? "strict $type" : $type]); $val = $s->runArray([$input])->getRow()['value']; $this->assertSame($expectations[$type], $val, "Binding from type $type failed comparison."); - $s->rebind(...[$strict ? "strict $type" : $type]); + $s->retype(...[$strict ? "strict $type" : $type]); $val = $s->run(...[$input])->getRow()['value']; $this->assertSame($expectations[$type], $val, "Binding from type $type failed comparison."); } @@ -56,7 +56,7 @@ class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest { ) as pass" ); $s = new self::$imp($this->c, $nativeStatement); - $s->rebindArray([$type, $type]); + $s->retypeArray([$type, $type]); $act = (bool) $s->run(...[$value, $value])->getRow()['pass']; $this->assertTrue($act); } diff --git a/tests/cases/Db/SQLite3PDO/TestStatement.php b/tests/cases/Db/SQLite3PDO/TestStatement.php index 69e0345..9a269a1 100644 --- a/tests/cases/Db/SQLite3PDO/TestStatement.php +++ b/tests/cases/Db/SQLite3PDO/TestStatement.php @@ -36,10 +36,10 @@ class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest { $s = new self::$imp($this->c, $nativeStatement); $types = array_unique(Statement::TYPES); foreach ($types as $type) { - $s->rebindArray([$strict ? "strict $type" : $type]); + $s->retypeArray([$strict ? "strict $type" : $type]); $val = $s->runArray([$input])->getRow()['value']; $this->assertSame($expectations[$type], $val, "Binding from type $type failed comparison."); - $s->rebind(...[$strict ? "strict $type" : $type]); + $s->retype(...[$strict ? "strict $type" : $type]); $val = $s->run(...[$input])->getRow()['value']; $this->assertSame($expectations[$type], $val, "Binding from type $type failed comparison."); } @@ -57,7 +57,7 @@ class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest { ) as pass" ); $s = new self::$imp($this->c, $nativeStatement); - $s->rebind(...[$type, $type]); + $s->retype(...[$type, $type]); $act = (bool) $s->run(...[$value, $value])->getRow()['pass']; $this->assertTrue($act); }