Skip to content

Commit 418adff

Browse files
committed
rename stan type logEntryType; added php 8.0 in the run; removed version from composer changed min to 8.0
1 parent 8c065ec commit 418adff

File tree

6 files changed

+30
-29
lines changed

6 files changed

+30
-29
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
fail-fast: true
3737
matrix:
3838
php:
39+
- '8.0'
3940
- '8.1'
4041
- '8.2'
4142
- '8.3'
@@ -72,6 +73,7 @@ jobs:
7273
strategy:
7374
matrix:
7475
php:
76+
- '8.0'
7577
- '8.1'
7678
- '8.2'
7779
- '8.3'

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "atlas/pdo",
33
"type": "library",
4-
"version": "2.0.0",
54
"description": "Provides a PDO instance decorator with convenience methods, and a connection manager.",
65
"keywords": [
76
"pdo",
@@ -18,7 +17,7 @@
1817
}
1918
],
2019
"require": {
21-
"php": "^8.1",
20+
"php": "^8.0",
2221
"ext-pdo": "*"
2322
},
2423
"autoload": {

src/Connection.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* options?: array<int, mixed>
3333
* }
3434
*
35-
* @phpstan-type logEntry array{
35+
* @phpstan-type logEntryType array{
3636
* start: float,
3737
* finish: ?float,
3838
* duration: ?float,
@@ -71,7 +71,7 @@ static public function factory(mixed ...$args) : callable
7171
/**
7272
* @var callable|null
7373
*/
74-
protected mixed /* callable */ $queryLogger = null;
74+
protected mixed $queryLogger = null;
7575

7676
public function __construct(protected PDO $pdo)
7777
{
@@ -153,7 +153,7 @@ public function prepare(
153153
$sth = PersistentLoggedStatement::new(
154154
$sth,
155155
function (array $entry) : void {
156-
/** @var logEntry $entry */
156+
/** @var logEntryType $entry */
157157
$this->addLogEntry($entry);
158158
},
159159
$this->newLogEntry()
@@ -310,7 +310,7 @@ public function fetchOne(
310310
array $values = []
311311
) : array|false
312312
{
313-
$sth = $this->perform($statement, $values);
313+
$sth = $this->perform($statement, $values);
314314
/** @var array<array-key, mixed> $result */
315315
$result = $sth->fetch(PDO::FETCH_ASSOC);
316316

@@ -437,7 +437,7 @@ public function logQueries(bool $logQueries = true) : void
437437
LoggedStatement::CLASS,
438438
[
439439
function (array $entry) : void {
440-
/** @var logEntry $entry */
440+
/** @var logEntryType $entry */
441441
$this->addLogEntry($entry);
442442
},
443443
$this->newLogEntry()
@@ -458,23 +458,23 @@ public function setQueryLogger(callable $queryLogger) : void
458458
/**
459459
* @param string|null $statement
460460
*
461-
* @return logEntry
461+
* @return logEntryType
462462
*/
463463
protected function newLogEntry(?string $statement = null) : array
464464
{
465465
return [
466-
'start' => microtime(true),
467-
'finish' => null,
468-
'duration' => null,
466+
'start' => microtime(true),
467+
'finish' => null,
468+
'duration' => null,
469469
'performed' => null,
470470
'statement' => $statement,
471-
'values' => [],
472-
'trace' => null,
471+
'values' => [],
472+
'trace' => null,
473473
];
474474
}
475475

476476
/**
477-
* @param logEntry $entry
477+
* @param logEntryType $entry
478478
*
479479
* @return void
480480
*/

src/ConnectionLocator.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* READ: array<string, ?Connection>,
1717
* WRITE: array<string, ?Connection>
1818
* }
19-
* @phpstan-import-type logEntry from Connection
19+
* @phpstan-import-type logEntryType from Connection
2020
*/
2121
class ConnectionLocator
2222
{
@@ -53,8 +53,8 @@ static public function new(mixed $arg, mixed ...$args) : static
5353
*/
5454
protected array $instances = [
5555
self::DEFAULT => null,
56-
self::READ => [],
57-
self::WRITE => [],
56+
self::READ => [],
57+
self::WRITE => [],
5858
];
5959

6060
protected ?Connection $read = null;
@@ -66,7 +66,7 @@ static public function new(mixed $arg, mixed ...$args) : static
6666
protected bool $logQueries = false;
6767

6868
/**
69-
* @var logEntry[]
69+
* @var logEntryType[]
7070
*/
7171
protected array $queries = [];
7272

@@ -205,7 +205,7 @@ protected function newConnection(
205205
$connection = $factory();
206206

207207
$queryLogger = function (array $entry) use ($label) : void {
208-
/** @var logEntry $entry */
208+
/** @var logEntryType $entry */
209209
$entry = ['connection' => $label] + $entry;
210210
$this->addLogEntry($entry);
211211
};
@@ -258,7 +258,7 @@ public function logQueries(bool $logQueries = true) : void
258258
}
259259

260260
/**
261-
* @return logEntry[]
261+
* @return logEntryType[]
262262
*/
263263
public function getQueries() : array
264264
{
@@ -271,7 +271,7 @@ public function setQueryLogger(callable $queryLogger) : void
271271
}
272272

273273
/**
274-
* @param logEntry $entry
274+
* @param logEntryType $entry
275275
*
276276
* @return void
277277
*/

src/LoggedStatement.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
use PDOStatement;
1515

1616
/**
17-
* @phpstan-import-type logEntry from Connection
17+
* @phpstan-import-type logEntryType from Connection
1818
*/
1919
class LoggedStatement extends PDOStatement
2020
{
2121
/**
22-
* @param callable $queryLogger
23-
* @param logEntry $logEntry
22+
* @param callable $queryLogger
23+
* @param logEntryType $logEntry
2424
*/
2525
protected function __construct(
26-
protected mixed /* callable */ $queryLogger,
26+
protected mixed $queryLogger,
2727
protected array $logEntry
2828
) {
2929
$this->logEntry['statement'] = $this->queryString;
@@ -45,7 +45,7 @@ public function bindValue(
4545
/** @var int|string $parameter */
4646
$result = parent::bindValue($parameter, $value, $dataType);
4747

48-
if ($result && !empty($this->logEntry)) {
48+
if ($result && $this->logEntry !== null) {
4949
$this->logEntry['values'][$parameter] = $value;
5050
}
5151

src/PersistentLoggedStatement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
use PDOStatement;
1616

1717
/**
18-
* @phpstan-import-type logEntry from Connection
18+
* @phpstan-import-type logEntryType from Connection
1919
*/
2020
class PersistentLoggedStatement extends PDOStatement
2121
{
2222
/**
2323
* @param PDOStatement $parent
2424
* @param callable $queryLogger
25-
* @param logEntry $logEntry
25+
* @param logEntryType $logEntry
2626
*
2727
* @return static
2828
*/
@@ -45,7 +45,7 @@ static public function new(
4545
private mixed /* callable */ $queryLogger;
4646

4747
/**
48-
* @var logEntry
48+
* @var logEntryType
4949
*/
5050
private array $logEntry;
5151

0 commit comments

Comments
 (0)