Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for PHP-8 (CakePHP 4.5) #74

Open
wants to merge 5 commits into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"preferred-install": "src"
},
"require": {
"php": ">=7.3",
"php": ">=8.0",
"cakephp/chronos": "*",
"ext-pdo": "*"
},
"require-dev": {
"cakephp/cakephp-codesniffer": "^4.0",
"phpunit/phpunit": "^8.5",
"cakephp/cakephp": "4.2.*"
"cakephp/cakephp": "4.5.*"
},
"repositories": [],
"autoload": {
Expand Down
67 changes: 3 additions & 64 deletions src/Config/ConfigTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
namespace CakeDC\OracleDriver\Config;

use Cake\Core\Exception\Exception;
use Cake\Core\Exception\CakeException;
use Cake\Utility\Hash;

/**
Expand All @@ -27,67 +27,6 @@ trait ConfigTrait
*/
protected $_configInitialized = false;

/**
* ### Usage
*
* Reading the whole config:
*
* ```
* $this->config();
* ```
*
* Reading a specific value:
*
* ```
* $this->config('key');
* ```
*
* Reading a nested value:
*
* ```
* $this->config('some.nested.key');
* ```
*
* Setting a specific value:
*
* ```
* $this->config('key', $value);
* ```
*
* Setting a nested value:
*
* ```
* $this->config('some.nested.key', $value);
* ```
*
* Updating multiple config settings at the same time:
*
* ```
* $this->config(['one' => 'value', 'another' => 'value']);
* ```
*
* @param string|array|null $key The key to get/set, or a complete array of configs.
* @param mixed|null $value The value to set.
* @param bool $merge Whether to recursively merge or overwrite existing config, defaults to true.
* @return mixed Config value being read, or the object itself on write operations.
* @throws \Cake\Core\Exception\Exception When trying to set a key that is invalid.
*/
public function config($key = null, $value = null, $merge = true)
{
if (!$this->_configInitialized) {
$this->_config += $this->_baseConfig;
$this->_configInitialized = true;
}

if (is_array($key) || func_num_args() >= 2) {
$this->_configWrite($key, $value, $merge);

return $this;
}

return $this->_configRead($key);
}

/**
* Write a config variable
*
Expand Down Expand Up @@ -136,7 +75,7 @@ protected function _configWrite($key, $value, $merge = false)

foreach ($stack as $k) {
if (!is_array($update)) {
throw new Exception(sprintf('Cannot set %s value', $key));
throw new CakeException(sprintf('Cannot set %s value', $key));
}

if (!isset($update[$k])) {
Expand Down Expand Up @@ -170,7 +109,7 @@ protected function _configDelete($key)

foreach ($stack as $i => $k) {
if (!is_array($update)) {
throw new Exception(sprintf('Cannot unset %s value', $key));
throw new CakeException(sprintf('Cannot unset %s value', $key));
}

if (!isset($update[$k])) {
Expand Down
6 changes: 3 additions & 3 deletions src/Database/Dialect/OracleDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Cake\Database\ExpressionInterface;
use Cake\Database\Query;
use Cake\Database\QueryCompiler;
use Cake\Database\Schema\BaseSchema;
use Cake\Database\SqlDialectTrait;
use Cake\Database\Schema\SchemaDialect;
use Cake\Database\Driver\SqlDialectTrait;
use CakeDC\OracleDriver\Database\Expression\SimpleExpression;
use CakeDC\OracleDriver\Database\Oracle12Compiler;
use CakeDC\OracleDriver\Database\OracleCompiler;
Expand Down Expand Up @@ -244,7 +244,7 @@ protected function _transformFunctionExpression(FunctionExpression $expression):
*
* @return \CakeDC\OracleDriver\Database\Schema\OracleSchema
*/
public function schemaDialect(): BaseSchema
public function schemaDialect(): SchemaDialect
{
if (!$this->_schemaDialect) {
$this->_schemaDialect = new OracleSchema($this);
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Exception/UnallowedDataTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
namespace CakeDC\OracleDriver\Database\Exception;

use Cake\Core\Exception\Exception;
use Cake\Core\Exception\CakeException;

class UnallowedDataTypeException extends Exception
class UnallowedDataTypeException extends CakeException
{
/**
* {@inheritDoc}
Expand Down
26 changes: 13 additions & 13 deletions src/Database/OCI8/OCI8Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
*/
namespace CakeDC\OracleDriver\Database\OCI8;

use Cake\Core\InstanceConfigTrait;
use PDO;
use Cake\Core\InstanceConfigTrait;
use PDOStatement;

/**
* OCI8 implementation of the Connection interface.
Expand Down Expand Up @@ -79,8 +80,6 @@ public function __construct($dsn, $username, $password, $options)
} else {
$this->dbh = @oci_connect($username, $password, $dsn);
}

// $this->dbh = @oci_connect($username, $password, $dsn, $charset, $sessionMode);
}

if (!$this->dbh) {
Expand Down Expand Up @@ -119,15 +118,16 @@ public function getServerVersion()
/**
* {@inheritdoc}
*/
public function prepare($statement, $options = null)
public function prepare($statement, $options = null): PDOStatement|false
{
return new OCI8Statement($this->dbh, $statement, $this);
}

/**
* {@inheritdoc}
*/
public function query($statement, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 = null, array $ctorargs = [])
//#[\ReturnTypeWillChange]
public function query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs): PDOStatement|false
{
$args = func_get_args();
$sql = $args[0];
Expand All @@ -140,7 +140,7 @@ public function query($statement, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, $arg3 =
/**
* {@inheritdoc}
*/
public function quote($string, $type = \PDO::PARAM_STR)
public function quote($string, $type = \PDO::PARAM_STR): string|false
{
if (is_int($string) || is_float($string)) {
return $string;
Expand All @@ -153,7 +153,7 @@ public function quote($string, $type = \PDO::PARAM_STR)
/**
* {@inheritdoc}
*/
public function exec($statement)
public function exec($statement): int|false
{
$stmt = $this->prepare($statement);
$stmt->execute();
Expand Down Expand Up @@ -185,15 +185,15 @@ public function isTransaction()
/**
* {@inheritdoc}
*/
public function inTransaction()
public function inTransaction(): bool
{
return $this->executeMode === OCI_NO_AUTO_COMMIT;
}

/**
* {@inheritdoc}
*/
public function beginTransaction()
public function beginTransaction(): bool
{
$this->executeMode = OCI_NO_AUTO_COMMIT;

Expand All @@ -203,7 +203,7 @@ public function beginTransaction()
/**
* {@inheritdoc}
*/
public function commit()
public function commit(): bool
{
if (!oci_commit($this->dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
Expand All @@ -216,7 +216,7 @@ public function commit()
/**
* {@inheritdoc}
*/
public function rollBack()
public function rollBack(): bool
{
if (!oci_rollback($this->dbh)) {
throw OCI8Exception::fromErrorInfo($this->errorInfo());
Expand All @@ -229,7 +229,7 @@ public function rollBack()
/**
* {@inheritdoc}
*/
public function errorCode()
public function errorCode(): ?string
{
$error = oci_error($this->dbh);
if ($error !== false) {
Expand All @@ -244,7 +244,7 @@ public function errorCode()
/**
* {@inheritdoc}
*/
public function errorInfo()
public function errorInfo(): array
{
return oci_error($this->dbh);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Database/OCI8/OCI8Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
namespace CakeDC\OracleDriver\Database\OCI8;

use Cake\Core\Exception\Exception;
use Cake\Core\Exception\CakeException;

class OCI8Exception extends Exception
class OCI8Exception extends CakeException
{
/**
* OCI Error builder.
Expand Down
Loading