From 8ed1361f57f7fc1b3127502f37d1a77a832741f0 Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Sun, 10 Mar 2024 21:44:56 -0300 Subject: [PATCH] Rename db object interfaces --- system/MagiQL/MagiQL.php | 2 +- system/MagiQL/Manipulation/AbstractBaseQuery.php | 2 +- system/database/Databases/Api/DriverInterface.php | 4 ++-- .../Databases/{ => Api}/Object/ItemInterface.php | 4 +--- .../Databases/{ => Api}/Object/ResultInterface.php | 4 ++-- system/database/Databases/Driver/MSSQL.php | 4 ++-- system/database/Databases/Driver/MySQL_PDO.php | 8 ++++---- system/database/Databases/Driver/MySQL_legacy.php | 6 +++--- system/database/Databases/Driver/MySQLi.php | 8 ++++---- system/database/Databases/Driver/Oracle.php | 8 ++++---- system/database/Databases/Driver/Oracle_PDO.php | 8 ++++---- system/database/Databases/Driver/Postgre.php | 8 ++++---- system/database/Databases/Driver/SQLSRV.php | 8 ++++---- system/database/Databases/Driver/SQLite3.php | 8 ++++---- system/database/Databases/Driver/mPDO.php | 8 ++++---- system/database/Databases/Driver/nullStatement.php | 11 +++++------ system/database/Databases/Driver/sqlsrvPDO.php | 8 ++++---- system/database/Databases/Object/Item.php | 6 +++--- system/database/Databases/Object/Result.php | 14 +++++++------- .../Databases/Object/ResultCacheIterator.php | 12 ++++++------ system/database/autoload.php | 2 +- system/engine/api/database.php | 4 ++-- system/etc/preferences.json | 4 ++-- system/session/Handlers/Database.php | 2 +- 24 files changed, 75 insertions(+), 78 deletions(-) rename system/database/Databases/{ => Api}/Object/ItemInterface.php (90%) rename system/database/Databases/{ => Api}/Object/ResultInterface.php (92%) diff --git a/system/MagiQL/MagiQL.php b/system/MagiQL/MagiQL.php index 6169664..8a7da72 100644 --- a/system/MagiQL/MagiQL.php +++ b/system/MagiQL/MagiQL.php @@ -41,7 +41,7 @@ class MagiQL extends AbstractBuilder { /** * * @param \Phacil\Framework\MagiQL\Api\QueryInterface $obj - * @return \Phacil\Framework\Databases\Object\ResultInterface|true + * @return \Phacil\Framework\Databases\Api\Object\ResultInterface|true * @throws \Phacil\Framework\MagiQL\Builder\BuilderException * @throws \Phacil\Framework\Exception */ diff --git a/system/MagiQL/Manipulation/AbstractBaseQuery.php b/system/MagiQL/Manipulation/AbstractBaseQuery.php index 5564b25..483d8c3 100644 --- a/system/MagiQL/Manipulation/AbstractBaseQuery.php +++ b/system/MagiQL/Manipulation/AbstractBaseQuery.php @@ -276,7 +276,7 @@ abstract class AbstractBaseQuery implements QueryInterface, QueryPartInterface /** * - * @return \Phacil\Framework\Databases\Object\ResultInterface|true|array + * @return \Phacil\Framework\Databases\Api\Object\ResultInterface|true|array * @throws \Phacil\Framework\Exception */ public function load() { diff --git a/system/database/Databases/Api/DriverInterface.php b/system/database/Databases/Api/DriverInterface.php index e500f7e..30f2fe0 100644 --- a/system/database/Databases/Api/DriverInterface.php +++ b/system/database/Databases/Api/DriverInterface.php @@ -43,7 +43,7 @@ * Execute the SQL Query. * * @param string|null $sql - * @return \Phacil\Framework\Databases\Object\ResultInterface|\Phacil\Framework\MagiQL|bool + * @return \Phacil\Framework\Databases\Api\Object\ResultInterface|\Phacil\Framework\MagiQL|bool * @throws Exception */ public function query($sql); @@ -78,7 +78,7 @@ * * @param string $sql SQL query with named placeholders * @param array $params Associative array of parameters - * @return \Phacil\Framework\Databases\Object\ResultInterface|true + * @return \Phacil\Framework\Databases\Api\Object\ResultInterface|true * @throws \Phacil\Framework\Exception */ public function execute($sql, array $params = []); diff --git a/system/database/Databases/Object/ItemInterface.php b/system/database/Databases/Api/Object/ItemInterface.php similarity index 90% rename from system/database/Databases/Object/ItemInterface.php rename to system/database/Databases/Api/Object/ItemInterface.php index 71f6f92..5d8cd51 100644 --- a/system/database/Databases/Object/ItemInterface.php +++ b/system/database/Databases/Api/Object/ItemInterface.php @@ -6,7 +6,7 @@ * Phacil PHP Framework - https://github.com/exacti/phacil-framework */ -namespace Phacil\Framework\Databases\Object; +namespace Phacil\Framework\Databases\Api\Object; /** * @method mixed getValue(string $field) @@ -20,8 +20,6 @@ interface ItemInterface extends \Countable, \IteratorAggregate, \Serializable { */ public function setData(array $data); - public function __get($key); - /** * * @param string $key diff --git a/system/database/Databases/Object/ResultInterface.php b/system/database/Databases/Api/Object/ResultInterface.php similarity index 92% rename from system/database/Databases/Object/ResultInterface.php rename to system/database/Databases/Api/Object/ResultInterface.php index 83eba34..c81565b 100644 --- a/system/database/Databases/Object/ResultInterface.php +++ b/system/database/Databases/Api/Object/ResultInterface.php @@ -7,7 +7,7 @@ */ -namespace Phacil\Framework\Databases\Object; +namespace Phacil\Framework\Databases\Api\Object; /** * A Database result object with all stored data @@ -67,7 +67,7 @@ interface ResultInterface extends \Countable, \ArrayAccess, \Traversable { /** * - * @return \Phacil\Framework\Databases\Object\ResultInterface + * @return \Phacil\Framework\Databases\Api\Object\ResultInterface */ public function __toObject(); diff --git a/system/database/Databases/Driver/MSSQL.php b/system/database/Databases/Driver/MSSQL.php index 5748b36..6b96566 100644 --- a/system/database/Databases/Driver/MSSQL.php +++ b/system/database/Databases/Driver/MSSQL.php @@ -59,8 +59,8 @@ class MSSQL implements \Phacil\Framework\Databases\Api\DriverInterface \mssql_free_result($resource); - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $query = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $query = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$data]); $query->setNumRows($i); unset($data); diff --git a/system/database/Databases/Driver/MySQL_PDO.php b/system/database/Databases/Driver/MySQL_PDO.php index bed2556..2d93d6d 100644 --- a/system/database/Databases/Driver/MySQL_PDO.php +++ b/system/database/Databases/Driver/MySQL_PDO.php @@ -99,8 +99,8 @@ class MySQL_PDO implements DatabasesDriver $sth->execute(); //$sth= $this->dbh->query($sql); $this->affectedRows = $sth->rowCount(); - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$sth ? $sth->fetchAll(\PDO::FETCH_ASSOC) : array()]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$sth ? $sth->fetchAll(\PDO::FETCH_ASSOC) : array()]); $data->setNumRows($this->affectedRows); return $data; } @@ -185,8 +185,8 @@ class MySQL_PDO implements DatabasesDriver $stmt->execute(); if ($stmt->columnCount()) { - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$stmt->fetchAll(\PDO::FETCH_ASSOC)]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$stmt->fetchAll(\PDO::FETCH_ASSOC)]); $data->setNumRows($stmt->rowCount()); $stmt->closeCursor(); diff --git a/system/database/Databases/Driver/MySQL_legacy.php b/system/database/Databases/Driver/MySQL_legacy.php index 0055938..0cfdc6b 100644 --- a/system/database/Databases/Driver/MySQL_legacy.php +++ b/system/database/Databases/Driver/MySQL_legacy.php @@ -61,11 +61,11 @@ class MySQL_legacy implements \Phacil\Framework\Databases\Api\DriverInterface { } \mysql_free_result($resource); - + /** - * @var \Phacil\Framework\Databases\Object\ResultInterface + * @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ - $query = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Object\ResultInterface", [$data]); + $query = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Api\Object\ResultInterface", [$data]); $query->setNumRows($i); unset($data); diff --git a/system/database/Databases/Driver/MySQLi.php b/system/database/Databases/Driver/MySQLi.php index 5c0f716..2bd5e5f 100644 --- a/system/database/Databases/Driver/MySQLi.php +++ b/system/database/Databases/Driver/MySQLi.php @@ -80,8 +80,8 @@ class MySQLi implements DriverInterface { $query = $this->connection->query($sql); if (!$this->connection->errno) { if ($query instanceof \mysqli_result) { - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$query->fetch_all(MYSQLI_ASSOC)]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$query->fetch_all(MYSQLI_ASSOC)]); $result->setNumRows($query->num_rows); $query->close(); return $result; @@ -164,8 +164,8 @@ class MySQLi implements DriverInterface { // Processar resultados se for um SELECT if ($result instanceof \mysqli_result) { //$resultObj = new \Phacil\Framework\Databases\Object\Result($result->fetch_all(MYSQLI_ASSOC)); - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $resultObj = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$result->fetch_all(MYSQLI_ASSOC)]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $resultObj = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$result->fetch_all(MYSQLI_ASSOC)]); $resultObj->setNumRows($result->num_rows); $result->close(); diff --git a/system/database/Databases/Driver/Oracle.php b/system/database/Databases/Driver/Oracle.php index 36b7919..e3173ae 100644 --- a/system/database/Databases/Driver/Oracle.php +++ b/system/database/Databases/Driver/Oracle.php @@ -59,8 +59,8 @@ class Oracle implements Databases { if (!$this->connection) { \oci_fetch_all($stid, $res); - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $result = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Object\ResultInterface", [$res]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $result = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Api\Object\ResultInterface", [$res]); $result->setNumRows(\oci_num_rows($stid)); return $result; @@ -119,8 +119,8 @@ class Oracle implements Databases { $res = []; \oci_fetch_all($stid, $res); - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $resultObj = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Object\ResultInterface", [$res]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $resultObj = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Api\Object\ResultInterface", [$res]); $resultObj->setNumRows(\oci_num_rows($stid)); return $resultObj; diff --git a/system/database/Databases/Driver/Oracle_PDO.php b/system/database/Databases/Driver/Oracle_PDO.php index 988a1b3..0dda667 100644 --- a/system/database/Databases/Driver/Oracle_PDO.php +++ b/system/database/Databases/Driver/Oracle_PDO.php @@ -107,8 +107,8 @@ class Oracle_PDO implements DriverInterface $this->statement->closeCursor(); $this->statement = null; - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$data]); $result->setNumRows($this->rowCount); } } catch (\PDOException $e) { @@ -179,8 +179,8 @@ class Oracle_PDO implements DriverInterface $stmt->execute(); if ($stmt->columnCount()) { - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$stmt->fetchAll(\PDO::FETCH_ASSOC)]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$stmt->fetchAll(\PDO::FETCH_ASSOC)]); $data->setNumRows($stmt->rowCount()); $stmt->closeCursor(); diff --git a/system/database/Databases/Driver/Postgre.php b/system/database/Databases/Driver/Postgre.php index ce873d0..487baf9 100644 --- a/system/database/Databases/Driver/Postgre.php +++ b/system/database/Databases/Driver/Postgre.php @@ -55,8 +55,8 @@ class Postgre implements DriverInterface { } pg_free_result($resource); - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $query = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Object\ResultInterface", [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $query = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Api\Object\ResultInterface", [$data]); $query->setNumRows($i); unset($data); @@ -111,8 +111,8 @@ class Postgre implements DriverInterface { if(!empty($data)) { - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $resultObj = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Object\ResultInterface", [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $resultObj = \Phacil\Framework\Registry::getInstance()->create("Phacil\Framework\Databases\Api\Object\ResultInterface", [$data]); $resultObj->setNumRows(count($data)); return $resultObj; diff --git a/system/database/Databases/Driver/SQLSRV.php b/system/database/Databases/Driver/SQLSRV.php index c581c6e..6bed28d 100644 --- a/system/database/Databases/Driver/SQLSRV.php +++ b/system/database/Databases/Driver/SQLSRV.php @@ -74,8 +74,8 @@ class SQLSRV implements DriverInterface { \sqlsrv_free_stmt($resource); - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $query = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $query = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$data]); $query->setNumRows($i); unset($data); @@ -156,8 +156,8 @@ class SQLSRV implements DriverInterface { $data[] = $row; } - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $resultObj = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $resultObj = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$data]); $resultObj->setNumRows(count($data)); return $resultObj; diff --git a/system/database/Databases/Driver/SQLite3.php b/system/database/Databases/Driver/SQLite3.php index 143bd1d..ebbef2f 100644 --- a/system/database/Databases/Driver/SQLite3.php +++ b/system/database/Databases/Driver/SQLite3.php @@ -55,8 +55,8 @@ class SQLite3 implements DriverInterface { $data[] = $row; } - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$data]); $result->setNumRows((!empty($data)) ? count($data) : 0); $query->finalize(); @@ -122,8 +122,8 @@ class SQLite3 implements DriverInterface { $data[] = $row; } - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $resultObj = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $resultObj = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$data]); $resultObj->setNumRows(count($data)); $result->finalize(); diff --git a/system/database/Databases/Driver/mPDO.php b/system/database/Databases/Driver/mPDO.php index 4dd9ba0..de35376 100644 --- a/system/database/Databases/Driver/mPDO.php +++ b/system/database/Databases/Driver/mPDO.php @@ -87,8 +87,8 @@ class mPDO implements DriverInterface { // free up resources $this->statement->closeCursor(); $this->statement = null; - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$data]); $result->setNumRows($this->rowCount); } @@ -158,8 +158,8 @@ class mPDO implements DriverInterface { $stmt->execute(); if ($stmt->columnCount()) { - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$stmt->fetchAll(\PDO::FETCH_ASSOC)]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$stmt->fetchAll(\PDO::FETCH_ASSOC)]); $data->setNumRows($stmt->rowCount()); $stmt->closeCursor(); diff --git a/system/database/Databases/Driver/nullStatement.php b/system/database/Databases/Driver/nullStatement.php index 1496593..9380f66 100644 --- a/system/database/Databases/Driver/nullStatement.php +++ b/system/database/Databases/Driver/nullStatement.php @@ -39,7 +39,7 @@ final class nullStatement implements DriverInterface { } /** {@inheritdoc} */ - public function __construct($hostname, $username, $password, $database, $charset = 'utf8mb4') { + public function __construct($hostname = null, $username = null, $password = null, $database = null, $charset = 'utf8mb4') { //$this->connection = NULL; } @@ -53,10 +53,9 @@ final class nullStatement implements DriverInterface { * {@inheritdoc} */ public function query($sql) { - $result = new \Phacil\Framework\Databases\Object\Result(); - $result->num_rows = NULL; - $result->row = NULL; - $result->rows = NULL; + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [[]]); + $result->setNumRows(0); return $result; } @@ -80,6 +79,6 @@ final class nullStatement implements DriverInterface { */ public function execute($sql, array $params = []) { - return [null]; + return $this->query($sql); } } diff --git a/system/database/Databases/Driver/sqlsrvPDO.php b/system/database/Databases/Driver/sqlsrvPDO.php index 9b4d24b..d2fe75d 100644 --- a/system/database/Databases/Driver/sqlsrvPDO.php +++ b/system/database/Databases/Driver/sqlsrvPDO.php @@ -87,8 +87,8 @@ class sqlsrvPDO implements DriverInterface { $data[] = $row; } - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $result = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$data]); $result->setNumRows($this->statement->rowCount()); } } catch (\PDOException $e) { @@ -158,8 +158,8 @@ class sqlsrvPDO implements DriverInterface { $this->statement->execute(); if ($this->statement->columnCount()) { - /** @var \Phacil\Framework\Databases\Object\ResultInterface */ - $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ResultInterface::class, [$this->statement->fetchAll(\PDO::FETCH_ASSOC)]); + /** @var \Phacil\Framework\Databases\Api\Object\ResultInterface */ + $data = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ResultInterface::class, [$this->statement->fetchAll(\PDO::FETCH_ASSOC)]); $data->setNumRows($this->statement->rowCount()); $this->statement->closeCursor(); diff --git a/system/database/Databases/Object/Item.php b/system/database/Databases/Object/Item.php index c5a14d5..ab4b77b 100644 --- a/system/database/Databases/Object/Item.php +++ b/system/database/Databases/Object/Item.php @@ -8,8 +8,8 @@ namespace Phacil\Framework\Databases\Object; -use ArrayObject; -use Phacil\Framework\Databases\Object\ItemInterface as ObjectInterface; +use ArrayObject as NativeArrayObject; +use Phacil\Framework\Databases\Api\Object\ItemInterface as ObjectInterface; /** @@ -18,7 +18,7 @@ use Phacil\Framework\Databases\Object\ItemInterface as ObjectInterface; * @method mixed getValues(string field, ...) * @package Phacil\Framework\Databases\Object */ -class Item extends \ArrayObject implements ObjectInterface { +class Item extends NativeArrayObject implements ObjectInterface { /** * diff --git a/system/database/Databases/Object/Result.php b/system/database/Databases/Object/Result.php index cb229b4..b9d9ca9 100644 --- a/system/database/Databases/Object/Result.php +++ b/system/database/Databases/Object/Result.php @@ -8,7 +8,7 @@ namespace Phacil\Framework\Databases\Object; -use Phacil\Framework\Databases\Object\ResultInterface; +use Phacil\Framework\Databases\Api\Object\ResultInterface; use Phacil\Framework\Databases\Object\ResultCacheIterator; /** @@ -44,7 +44,7 @@ class Result extends \ArrayIterator implements ResultInterface { /** * * @param string $name - * @return \Phacil\Framework\Databases\Object\ItemInterface[]|\Phacil\Framework\Databases\Object\ItemInterface|null + * @return \Phacil\Framework\Databases\Api\Object\ItemInterface[]|\Phacil\Framework\Databases\Api\Object\ItemInterface|null * @throws \Phacil\Framework\Exception\RuntimeException */ public function __get($name) { @@ -151,7 +151,7 @@ class Result extends \ArrayIterator implements ResultInterface { /** * * @param mixed $array - * @return \Phacil\Framework\Databases\Object\ItemInterface[] + * @return \Phacil\Framework\Databases\Api\Object\ItemInterface[] */ protected function loop($array) { @@ -175,8 +175,8 @@ class Result extends \ArrayIterator implements ResultInterface { $data = parent::offsetGet($index); - /** @var \Phacil\Framework\Databases\Object\ItemInterface */ - $item = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ItemInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ItemInterface */ + $item = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ItemInterface::class, [$data]); return $item; } @@ -186,8 +186,8 @@ class Result extends \ArrayIterator implements ResultInterface { #[\ReturnTypeWillChange] public function current() { - /** @var \Phacil\Framework\Databases\Object\ItemInterface */ - $item = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ItemInterface::class, [parent::current()]); + /** @var \Phacil\Framework\Databases\Api\Object\ItemInterface */ + $item = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ItemInterface::class, [parent::current()]); return $item; } diff --git a/system/database/Databases/Object/ResultCacheIterator.php b/system/database/Databases/Object/ResultCacheIterator.php index db942e5..00a0863 100644 --- a/system/database/Databases/Object/ResultCacheIterator.php +++ b/system/database/Databases/Object/ResultCacheIterator.php @@ -8,7 +8,7 @@ namespace Phacil\Framework\Databases\Object; -use Phacil\Framework\Databases\Object\ResultInterface; +use Phacil\Framework\Databases\Api\Object\ResultInterface; /** * Result Databse iterator class with memory cache. @@ -37,7 +37,7 @@ class ResultCacheIterator extends \CachingIterator implements ResultInterface { private $Iterator; /** - * @param array|\Phacil\Framework\Databases\Object\ResultInterface $results + * @param array|\Phacil\Framework\Databases\Api\Object\ResultInterface $results * @param int $flags * @return $this */ @@ -45,7 +45,7 @@ class ResultCacheIterator extends \CachingIterator implements ResultInterface { { if(is_array($results)) $this->Iterator = new \Phacil\Framework\Databases\Object\Result($results); - elseif($results instanceof \Phacil\Framework\Databases\Object\ResultInterface) + elseif($results instanceof \Phacil\Framework\Databases\Api\Object\ResultInterface) $this->Iterator = $results; parent::__construct($this->Iterator, $flags); @@ -56,7 +56,7 @@ class ResultCacheIterator extends \CachingIterator implements ResultInterface { /** * * @param string $name - * @return \Phacil\Framework\Databases\Object\ItemInterface[]|\Phacil\Framework\Databases\Object\ItemInterface|null + * @return \Phacil\Framework\Databases\Api\Object\ItemInterface[]|\Phacil\Framework\Databases\Api\Object\ItemInterface|null * @throws \Phacil\Framework\Exception\RuntimeException */ public function __get($name) @@ -185,8 +185,8 @@ class ResultCacheIterator extends \CachingIterator implements ResultInterface { if(!$data) return null; - /** @var \Phacil\Framework\Databases\Object\ItemInterface */ - $item = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Object\ItemInterface::class, [$data]); + /** @var \Phacil\Framework\Databases\Api\Object\ItemInterface */ + $item = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\Databases\Api\Object\ItemInterface::class, [$data]); return $item; } diff --git a/system/database/autoload.php b/system/database/autoload.php index ff986f7..c6c8868 100644 --- a/system/database/autoload.php +++ b/system/database/autoload.php @@ -192,7 +192,7 @@ class Database implements DatabaseApi { } $query = $this->driver->query($sql); - if($query instanceof \Phacil\Framework\Databases\Object\ResultInterface){ + if($query instanceof \Phacil\Framework\Databases\Api\Object\ResultInterface){ $cache->set($this->cachePrefix.md5($sql), $query); return $query; diff --git a/system/engine/api/database.php b/system/engine/api/database.php index 1f42f0e..99611c8 100644 --- a/system/engine/api/database.php +++ b/system/engine/api/database.php @@ -39,7 +39,7 @@ interface Database { * * @param string|null $sql * @param bool $cacheUse - * @return \Phacil\Framework\Databases\Object\ResultInterface|\Phacil\Framework\Database::Cache|\Phacil\Framework\MagiQL + * @return \Phacil\Framework\Databases\Api\Object\ResultInterface|\Phacil\Framework\Database::Cache|\Phacil\Framework\MagiQL * @throws PhpfastcacheInvalidArgumentException */ public function query($sql = null, $cacheUse = true); @@ -92,7 +92,7 @@ interface Database { * * @param string $sql SQL query with named placeholders * @param array $params Associative array of parameters - * @return \Phacil\Framework\Databases\Object\ResultInterface|true + * @return \Phacil\Framework\Databases\Api\Object\ResultInterface|true * @throws \Phacil\Framework\Exception */ public function execute($sql, array $params = []); diff --git a/system/etc/preferences.json b/system/etc/preferences.json index f7c52e1..23707fc 100644 --- a/system/etc/preferences.json +++ b/system/etc/preferences.json @@ -1,9 +1,9 @@ { "preferences": { - "Phacil\\Framework\\Databases\\Object\\ResultInterface": "Phacil\\Framework\\Databases\\Object\\Result", + "Phacil\\Framework\\Databases\\Api\\Object\\ResultInterface": "Phacil\\Framework\\Databases\\Object\\Result", "Phacil\\Framework\\Interfaces\\Loader": "Phacil\\Framework\\Loader", "Phacil\\Framework\\Interfaces\\Url": "Phacil\\Framework\\Url", - "Phacil\\Framework\\Databases\\Object\\ItemInterface": "Phacil\\Framework\\Databases\\Object\\Item", + "Phacil\\Framework\\Databases\\Api\\Object\\ItemInterface": "Phacil\\Framework\\Databases\\Object\\Item", "Phacil\\Framework\\Api\\Database": "Phacil\\Framework\\Database", "Cm\\RedisSession\\Handler\\ConfigInterface": "Phacil\\Framework\\Session\\Redis\\Config", "Cm\\RedisSession\\Handler\\LoggerInterface": "Phacil\\Framework\\Session\\Redis\\Logger", diff --git a/system/session/Handlers/Database.php b/system/session/Handlers/Database.php index 7cc0cd0..181a165 100644 --- a/system/session/Handlers/Database.php +++ b/system/session/Handlers/Database.php @@ -39,7 +39,7 @@ class Database implements \Phacil\Framework\Session\Api\HandlerInterface /** * Database write connection * - * @var \Phacil\Framework\Databases\Object\ResultInterface|\Phacil\Framework\Database::Cache|\Phacil\Framework\MagiQL + * @var \Phacil\Framework\Databases\Api\Object\ResultInterface|\Phacil\Framework\Database::Cache|\Phacil\Framework\MagiQL */ protected $connection;