Skip to content
Merged
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
6 changes: 5 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
operating-system:
- ubuntu-latest
php-version:
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
steps:
- name: Checkout
Expand All @@ -40,7 +44,7 @@ jobs:
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
run: composer install --no-interaction --prefer-dist

- name: Run test suite
run: ./vendor/bin/phpunit
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 4.0.0

- Backports 5.x branch (which includes 8.1 compatibility) to PHP 7.2-8.0 compat, including annotations as needed.

## 3.0.0

- Fixed issue #163: Add getAttribute and setAttribute functions to make sure pdo is connected before calling the functions
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ Alternatively, [download a release][], or clone this repository, then map the

## Dependencies

This package requires PHP 5.6 or later; it has also been tested on PHP 7 and
HHVM. We recommend using the latest available version of PHP as a matter of
principle.
This package requires PHP 7.2 or later. It has been tested on PHP 7.2-8.1.
We recommend using the latest available version of PHP as a matter of principle.

Aura library packages may sometimes depend on external interfaces, but never on
external implementations. This allows compliance with community standards
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
],
"require": {
"php": ">=8.1",
"php": ">=7.2",
"psr/log": "^1.0 || ^2.0",
"ext-pdo": "*"
},
Expand All @@ -33,7 +33,7 @@
},
"require-dev": {
"pds/skeleton": "~1.0",
"phpunit/phpunit": "~5.7|~9.5"
"phpunit/phpunit": "^8.0|^9.5"
},
"autoload-dev": {
"psr-4": {
Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./phpunit.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="unit">
<directory>./tests</directory>
Expand Down
48 changes: 25 additions & 23 deletions src/AbstractExtendedPdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
* @var PDO|null
*
*/
protected ?PDO $pdo = null;
protected $pdo = null;

/**
*
Expand All @@ -41,7 +41,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
* @var ProfilerInterface
*
*/
protected ProfilerInterface $profiler;
protected $profiler;

/**
*
Expand All @@ -50,7 +50,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
* @var ParserInterface
*
*/
protected ParserInterface $parser;
protected $parser;

/**
*
Expand All @@ -59,7 +59,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
* @var string
*
*/
protected string $quoteNamePrefix = '"';
protected $quoteNamePrefix = '"';

/**
*
Expand All @@ -68,7 +68,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
* @var string
*
*/
protected string $quoteNameSuffix = '"';
protected $quoteNameSuffix = '"';

/**
*
Expand All @@ -77,7 +77,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
* @var string
*
*/
protected string $quoteNameEscapeFind = '"';
protected $quoteNameEscapeFind = '"';

/**
*
Expand All @@ -86,7 +86,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
* @var string
*
*/
protected string $quoteNameEscapeRepl = '""';
protected $quoteNameEscapeRepl = '""';

/**
*
Expand Down Expand Up @@ -205,7 +205,8 @@ public function errorInfo(): array
* @see http://php.net/manual/en/pdo.exec.php
*
*/
public function exec(string $statement): int
#[\ReturnTypeWillChange]
public function exec($statement)
{
$this->connect();
$this->profiler->start(__FUNCTION__);
Expand Down Expand Up @@ -405,7 +406,7 @@ public function fetchObjects(
* @return array|false
*
*/
public function fetchOne(string $statement, array $values = []): array|false
public function fetchOne(string $statement, array $values = [])
{
$sth = $this->perform($statement, $values);
return $sth->fetch(self::FETCH_ASSOC);
Expand Down Expand Up @@ -440,7 +441,7 @@ public function fetchPairs(string $statement, array $values = []): array
* @return mixed
*
*/
public function fetchValue(string $statement, array $values = []): mixed
public function fetchValue(string $statement, array $values = [])
{
$sth = $this->perform($statement, $values);
return $sth->fetchColumn(0);
Expand Down Expand Up @@ -523,7 +524,8 @@ public function isConnected(): bool
*
* @see http://php.net/manual/en/pdo.lastinsertid.php
*/
public function lastInsertId(?string $name = null): string|false
#[\ReturnTypeWillChange]
public function lastInsertId($name = null)
{
$this->connect();
$this->profiler->start(__FUNCTION__);
Expand Down Expand Up @@ -564,18 +566,18 @@ public function perform(string $statement, array $values = []): PDOStatement
*
* @param string $query The SQL statement to prepare for execution.
*
* @param array $options Set these attributes on the returned
* @param array|null $options Set these attributes on the returned
* PDOStatement.
*
* @return PDOStatement
*
* @see http://php.net/manual/en/pdo.prepare.php
*
*/
public function prepare(string $query, array $options = []): PDOStatement
public function prepare($query, $options = null): PDOStatement
Comment thread
kenjis marked this conversation as resolved.
{
$this->connect();
$sth = $this->pdo->prepare($query, $options);
$sth = $this->pdo->prepare($query, $options ?? []);
return $sth;
}

Expand Down Expand Up @@ -634,20 +636,18 @@ public function prepareWithValues(string $statement, array $values = []): PDOSta
*
* @param string $query The SQL statement to prepare and execute.
*
* @param int|null $fetchMode
*
* @param mixed ...$fetch_mode_args Optional fetch-related parameters.
* @param mixed ...$fetch Optional fetch-related parameters.
*
* @return PDOStatement
*
* @see http://php.net/manual/en/pdo.query.php
*
*/
public function query(string $query, ?int $fetchMode = null, mixed ...$fetch_mode_args): PDOStatement
public function query(string $query, ...$fetch): PDOStatement
Comment thread
kenjis marked this conversation as resolved.
{
$this->connect();
$this->profiler->start(__FUNCTION__);
$sth = $this->pdo->query($query, $fetchMode, ...$fetch_mode_args);
$sth = $this->pdo->query($query, ...$fetch);
$this->profiler->finish($sth->queryString);
return $sth;
}
Expand All @@ -668,7 +668,7 @@ public function query(string $query, ?int $fetchMode = null, mixed ...$fetch_mod
* @see http://php.net/manual/en/pdo.quote.php
*
*/
public function quote(string|int|array|float|null $value, int $type = self::PARAM_STR): string
public function quote($value, $type = self::PARAM_STR): string
{
$this->connect();

Expand Down Expand Up @@ -908,7 +908,7 @@ public function yieldPairs(string $statement, array $values = []): Generator
* bindable (e.g., array, object, or resource).
*
*/
protected function bindValue(PDOStatement $sth, mixed $key, mixed $val): bool
protected function bindValue(PDOStatement $sth, $key, $val): bool
{
if (is_int($val)) {
return $sth->bindValue($key, $val, self::PARAM_INT);
Expand Down Expand Up @@ -990,7 +990,8 @@ protected function setQuoteName(string $driver): void
* @param int $attribute
* @return bool|int|string|array|null
*/
public function getAttribute(int $attribute): bool|int|string|array|null
#[\ReturnTypeWillChange]
public function getAttribute($attribute)
{
$this->connect();
return $this->pdo->getAttribute($attribute);
Expand All @@ -1004,7 +1005,8 @@ public function getAttribute(int $attribute): bool|int|string|array|null
* @param mixed $value
* @return bool
*/
public function setAttribute(int $attribute, mixed $value): bool
#[\ReturnTypeWillChange]
public function setAttribute($attribute, $value)
{
$this->connect();
return $this->pdo->setAttribute($attribute, $value);
Expand Down
12 changes: 6 additions & 6 deletions src/ConnectionLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ConnectionLocator implements ConnectionLocatorInterface
* @var array
*
*/
protected array $read = [];
protected $read = [];

/**
*
Expand All @@ -42,7 +42,7 @@ class ConnectionLocator implements ConnectionLocatorInterface
* @var array
*
*/
protected array $write = [];
protected $write = [];

/**
*
Expand Down Expand Up @@ -92,7 +92,7 @@ public function setDefault(callable $callable): void
*
* @throws Exception\ConnectionNotFound
*/
public function getDefault(): ExtendedPdoInterface
public function getDefault()
{
if (! $this->default) {
throw new Exception\ConnectionNotFound("default");
Expand Down Expand Up @@ -132,7 +132,7 @@ public function setRead(string $name, callable $callable): void
*
* @throws \Aura\Sql\Exception\ConnectionNotFound
*/
public function getRead(string $name = ''): ExtendedPdoInterface
public function getRead(string $name = '')
{
return $this->getConnection('read', $name);
}
Expand Down Expand Up @@ -164,7 +164,7 @@ public function setWrite(string $name, callable $callable): void
*
* @throws \Aura\Sql\Exception\ConnectionNotFound
*/
public function getWrite(string $name = ''): ExtendedPdoInterface
public function getWrite(string $name = '')
{
return $this->getConnection('write', $name);
}
Expand All @@ -182,7 +182,7 @@ public function getWrite(string $name = ''): ExtendedPdoInterface
* @throws Exception\ConnectionNotFound
*
*/
protected function getConnection(string $type, string $name): ExtendedPdoInterface
protected function getConnection(string $type, string $name)
{
$conn = &$this->{$type};

Expand Down
6 changes: 3 additions & 3 deletions src/ConnectionLocatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function setDefault(callable $callable): void;
* @return ExtendedPdoInterface
*
*/
public function getDefault(): ExtendedPdoInterface;
public function getDefault();

/**
*
Expand All @@ -59,7 +59,7 @@ public function setRead(string $name, callable $callable): void;
* @return ExtendedPdoInterface
*
*/
public function getRead(string $name = ''): ExtendedPdoInterface;
public function getRead(string $name = '');

/**
*
Expand All @@ -84,5 +84,5 @@ public function setWrite(string $name, callable $callable): void;
* @return ExtendedPdoInterface
*
*/
public function getWrite(string $name = ''): ExtendedPdoInterface;
public function getWrite(string $name = '');
}
2 changes: 1 addition & 1 deletion src/ExtendedPdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ExtendedPdo extends AbstractExtendedPdo
* @var array
*
*/
protected array $args = [];
protected $args = [];

/**
*
Expand Down
4 changes: 2 additions & 2 deletions src/ExtendedPdoInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function fetchObjects(
* @return array|false
*
*/
public function fetchOne(string $statement, array $values = []): array|false;
public function fetchOne(string $statement, array $values = []);

/**
*
Expand All @@ -214,7 +214,7 @@ public function fetchPairs(string $statement, array $values = []): array;
* @return mixed
*
*/
public function fetchValue(string $statement, array $values = []): mixed;
public function fetchValue(string $statement, array $values = []);

/**
*
Expand Down
Loading