Skip to content

Commit 995db7a

Browse files
authored
Merge pull request #202 from iansltx/4.x
Enable PHP 7.2-8.1 compat
2 parents 0fd71a5 + aadf10f commit 995db7a

17 files changed

+77
-75
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
operating-system:
1616
- ubuntu-latest
1717
php-version:
18+
- '7.2'
19+
- '7.3'
20+
- '7.4'
21+
- '8.0'
1822
- '8.1'
1923
steps:
2024
- name: Checkout
@@ -40,7 +44,7 @@ jobs:
4044
restore-keys: ${{ runner.os }}-composer-
4145

4246
- name: Install dependencies
43-
run: composer install --no-interaction --prefer-dist --ignore-platform-req=php
47+
run: composer install --no-interaction --prefer-dist
4448

4549
- name: Run test suite
4650
run: ./vendor/bin/phpunit

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 4.0.0
4+
5+
- Backports 5.x branch (which includes 8.1 compatibility) to PHP 7.2-8.0 compat, including annotations as needed.
6+
37
## 3.0.0
48

59
- Fixed issue #163: Add getAttribute and setAttribute functions to make sure pdo is connected before calling the functions

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ Alternatively, [download a release][], or clone this repository, then map the
5454

5555
## Dependencies
5656

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

6160
Aura library packages may sometimes depend on external interfaces, but never on
6261
external implementations. This allows compliance with community standards

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
],
2424
"require": {
25-
"php": ">=8.1",
25+
"php": ">=7.2",
2626
"psr/log": "^1.0 || ^2.0",
2727
"ext-pdo": "*"
2828
},
@@ -33,7 +33,7 @@
3333
},
3434
"require-dev": {
3535
"pds/skeleton": "~1.0",
36-
"phpunit/phpunit": "~5.7|~9.5"
36+
"phpunit/phpunit": "^8.0|^9.5"
3737
},
3838
"autoload-dev": {
3939
"psr-4": {

phpunit.xml.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<?xml version="1.0"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./phpunit.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage processUncoveredFiles="true">
4-
<include>
5-
<directory suffix=".php">./src</directory>
6-
</include>
7-
</coverage>
83
<testsuites>
94
<testsuite name="unit">
105
<directory>./tests</directory>

src/AbstractExtendedPdo.php

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
3232
* @var PDO|null
3333
*
3434
*/
35-
protected ?PDO $pdo = null;
35+
protected $pdo = null;
3636

3737
/**
3838
*
@@ -41,7 +41,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
4141
* @var ProfilerInterface
4242
*
4343
*/
44-
protected ProfilerInterface $profiler;
44+
protected $profiler;
4545

4646
/**
4747
*
@@ -50,7 +50,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
5050
* @var ParserInterface
5151
*
5252
*/
53-
protected ParserInterface $parser;
53+
protected $parser;
5454

5555
/**
5656
*
@@ -59,7 +59,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
5959
* @var string
6060
*
6161
*/
62-
protected string $quoteNamePrefix = '"';
62+
protected $quoteNamePrefix = '"';
6363

6464
/**
6565
*
@@ -68,7 +68,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
6868
* @var string
6969
*
7070
*/
71-
protected string $quoteNameSuffix = '"';
71+
protected $quoteNameSuffix = '"';
7272

7373
/**
7474
*
@@ -77,7 +77,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
7777
* @var string
7878
*
7979
*/
80-
protected string $quoteNameEscapeFind = '"';
80+
protected $quoteNameEscapeFind = '"';
8181

8282
/**
8383
*
@@ -86,7 +86,7 @@ abstract class AbstractExtendedPdo extends PDO implements ExtendedPdoInterface
8686
* @var string
8787
*
8888
*/
89-
protected string $quoteNameEscapeRepl = '""';
89+
protected $quoteNameEscapeRepl = '""';
9090

9191
/**
9292
*
@@ -205,7 +205,8 @@ public function errorInfo(): array
205205
* @see http://php.net/manual/en/pdo.exec.php
206206
*
207207
*/
208-
public function exec(string $statement): int
208+
#[\ReturnTypeWillChange]
209+
public function exec($statement)
209210
{
210211
$this->connect();
211212
$this->profiler->start(__FUNCTION__);
@@ -405,7 +406,7 @@ public function fetchObjects(
405406
* @return array|false
406407
*
407408
*/
408-
public function fetchOne(string $statement, array $values = []): array|false
409+
public function fetchOne(string $statement, array $values = [])
409410
{
410411
$sth = $this->perform($statement, $values);
411412
return $sth->fetch(self::FETCH_ASSOC);
@@ -440,7 +441,7 @@ public function fetchPairs(string $statement, array $values = []): array
440441
* @return mixed
441442
*
442443
*/
443-
public function fetchValue(string $statement, array $values = []): mixed
444+
public function fetchValue(string $statement, array $values = [])
444445
{
445446
$sth = $this->perform($statement, $values);
446447
return $sth->fetchColumn(0);
@@ -523,7 +524,8 @@ public function isConnected(): bool
523524
*
524525
* @see http://php.net/manual/en/pdo.lastinsertid.php
525526
*/
526-
public function lastInsertId(?string $name = null): string|false
527+
#[\ReturnTypeWillChange]
528+
public function lastInsertId($name = null)
527529
{
528530
$this->connect();
529531
$this->profiler->start(__FUNCTION__);
@@ -564,18 +566,18 @@ public function perform(string $statement, array $values = []): PDOStatement
564566
*
565567
* @param string $query The SQL statement to prepare for execution.
566568
*
567-
* @param array $options Set these attributes on the returned
569+
* @param array|null $options Set these attributes on the returned
568570
* PDOStatement.
569571
*
570572
* @return PDOStatement
571573
*
572574
* @see http://php.net/manual/en/pdo.prepare.php
573575
*
574576
*/
575-
public function prepare(string $query, array $options = []): PDOStatement
577+
public function prepare($query, $options = null): PDOStatement
576578
{
577579
$this->connect();
578-
$sth = $this->pdo->prepare($query, $options);
580+
$sth = $this->pdo->prepare($query, $options ?? []);
579581
return $sth;
580582
}
581583

@@ -634,20 +636,18 @@ public function prepareWithValues(string $statement, array $values = []): PDOSta
634636
*
635637
* @param string $query The SQL statement to prepare and execute.
636638
*
637-
* @param int|null $fetchMode
638-
*
639-
* @param mixed ...$fetch_mode_args Optional fetch-related parameters.
639+
* @param mixed ...$fetch Optional fetch-related parameters.
640640
*
641641
* @return PDOStatement
642642
*
643643
* @see http://php.net/manual/en/pdo.query.php
644644
*
645645
*/
646-
public function query(string $query, ?int $fetchMode = null, mixed ...$fetch_mode_args): PDOStatement
646+
public function query(string $query, ...$fetch): PDOStatement
647647
{
648648
$this->connect();
649649
$this->profiler->start(__FUNCTION__);
650-
$sth = $this->pdo->query($query, $fetchMode, ...$fetch_mode_args);
650+
$sth = $this->pdo->query($query, ...$fetch);
651651
$this->profiler->finish($sth->queryString);
652652
return $sth;
653653
}
@@ -668,7 +668,7 @@ public function query(string $query, ?int $fetchMode = null, mixed ...$fetch_mod
668668
* @see http://php.net/manual/en/pdo.quote.php
669669
*
670670
*/
671-
public function quote(string|int|array|float|null $value, int $type = self::PARAM_STR): string
671+
public function quote($value, $type = self::PARAM_STR): string
672672
{
673673
$this->connect();
674674

@@ -908,7 +908,7 @@ public function yieldPairs(string $statement, array $values = []): Generator
908908
* bindable (e.g., array, object, or resource).
909909
*
910910
*/
911-
protected function bindValue(PDOStatement $sth, mixed $key, mixed $val): bool
911+
protected function bindValue(PDOStatement $sth, $key, $val): bool
912912
{
913913
if (is_int($val)) {
914914
return $sth->bindValue($key, $val, self::PARAM_INT);
@@ -990,7 +990,8 @@ protected function setQuoteName(string $driver): void
990990
* @param int $attribute
991991
* @return bool|int|string|array|null
992992
*/
993-
public function getAttribute(int $attribute): bool|int|string|array|null
993+
#[\ReturnTypeWillChange]
994+
public function getAttribute($attribute)
994995
{
995996
$this->connect();
996997
return $this->pdo->getAttribute($attribute);
@@ -1004,7 +1005,8 @@ public function getAttribute(int $attribute): bool|int|string|array|null
10041005
* @param mixed $value
10051006
* @return bool
10061007
*/
1007-
public function setAttribute(int $attribute, mixed $value): bool
1008+
#[\ReturnTypeWillChange]
1009+
public function setAttribute($attribute, $value)
10081010
{
10091011
$this->connect();
10101012
return $this->pdo->setAttribute($attribute, $value);

src/ConnectionLocator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ConnectionLocator implements ConnectionLocatorInterface
3333
* @var array
3434
*
3535
*/
36-
protected array $read = [];
36+
protected $read = [];
3737

3838
/**
3939
*
@@ -42,7 +42,7 @@ class ConnectionLocator implements ConnectionLocatorInterface
4242
* @var array
4343
*
4444
*/
45-
protected array $write = [];
45+
protected $write = [];
4646

4747
/**
4848
*
@@ -92,7 +92,7 @@ public function setDefault(callable $callable): void
9292
*
9393
* @throws Exception\ConnectionNotFound
9494
*/
95-
public function getDefault(): ExtendedPdoInterface
95+
public function getDefault()
9696
{
9797
if (! $this->default) {
9898
throw new Exception\ConnectionNotFound("default");
@@ -132,7 +132,7 @@ public function setRead(string $name, callable $callable): void
132132
*
133133
* @throws \Aura\Sql\Exception\ConnectionNotFound
134134
*/
135-
public function getRead(string $name = ''): ExtendedPdoInterface
135+
public function getRead(string $name = '')
136136
{
137137
return $this->getConnection('read', $name);
138138
}
@@ -164,7 +164,7 @@ public function setWrite(string $name, callable $callable): void
164164
*
165165
* @throws \Aura\Sql\Exception\ConnectionNotFound
166166
*/
167-
public function getWrite(string $name = ''): ExtendedPdoInterface
167+
public function getWrite(string $name = '')
168168
{
169169
return $this->getConnection('write', $name);
170170
}
@@ -182,7 +182,7 @@ public function getWrite(string $name = ''): ExtendedPdoInterface
182182
* @throws Exception\ConnectionNotFound
183183
*
184184
*/
185-
protected function getConnection(string $type, string $name): ExtendedPdoInterface
185+
protected function getConnection(string $type, string $name)
186186
{
187187
$conn = &$this->{$type};
188188

src/ConnectionLocatorInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function setDefault(callable $callable): void;
3434
* @return ExtendedPdoInterface
3535
*
3636
*/
37-
public function getDefault(): ExtendedPdoInterface;
37+
public function getDefault();
3838

3939
/**
4040
*
@@ -59,7 +59,7 @@ public function setRead(string $name, callable $callable): void;
5959
* @return ExtendedPdoInterface
6060
*
6161
*/
62-
public function getRead(string $name = ''): ExtendedPdoInterface;
62+
public function getRead(string $name = '');
6363

6464
/**
6565
*
@@ -84,5 +84,5 @@ public function setWrite(string $name, callable $callable): void;
8484
* @return ExtendedPdoInterface
8585
*
8686
*/
87-
public function getWrite(string $name = ''): ExtendedPdoInterface;
87+
public function getWrite(string $name = '');
8888
}

src/ExtendedPdo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ExtendedPdo extends AbstractExtendedPdo
2828
* @var array
2929
*
3030
*/
31-
protected array $args = [];
31+
protected $args = [];
3232

3333
/**
3434
*

src/ExtendedPdoInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function fetchObjects(
187187
* @return array|false
188188
*
189189
*/
190-
public function fetchOne(string $statement, array $values = []): array|false;
190+
public function fetchOne(string $statement, array $values = []);
191191

192192
/**
193193
*
@@ -214,7 +214,7 @@ public function fetchPairs(string $statement, array $values = []): array;
214214
* @return mixed
215215
*
216216
*/
217-
public function fetchValue(string $statement, array $values = []): mixed;
217+
public function fetchValue(string $statement, array $values = []);
218218

219219
/**
220220
*

0 commit comments

Comments
 (0)