Skip to content

Commit d3e1893

Browse files
committed
Merge branch 'refs/heads/development'
2 parents 1ab65b2 + dd81bd8 commit d3e1893

28 files changed

+525
-433
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- 3306:3306
2424
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
2525

26-
name: PHP 8.1 - MariaDB
26+
name: PHP 8.3 - MariaDB
2727

2828
steps:
2929
- name: Checkout
@@ -32,7 +32,7 @@ jobs:
3232
- name: Setup PHP
3333
uses: shivammathur/setup-php@v2
3434
with:
35-
php-version: 8.1
35+
php-version: 8.3
3636
ini-values: mysqli.allow_local_infile=On
3737
tools: composer
3838
coverage: xdebug
@@ -124,7 +124,7 @@ jobs:
124124
- 3306:3306
125125
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
126126

127-
name: PHP 8.1 - MySQL
127+
name: PHP 8.3 - MySQL
128128

129129
steps:
130130
- name: Checkout
@@ -133,7 +133,7 @@ jobs:
133133
- name: Setup PHP
134134
uses: shivammathur/setup-php@v2
135135
with:
136-
php-version: 8.1
136+
php-version: 8.3
137137
ini-values: mysqli.allow_local_infile=On
138138
tools: composer
139139
coverage: xdebug

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
image: registry.gitlab.com/aplus-framework/images/base:2
2+
image: registry.gitlab.com/aplus-framework/images/base:4
33

44
include:
55
- template: Security/SAST.gitlab-ci.yml

.phpstorm.meta.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,45 @@
417417
1,
418418
argumentsSet('operators')
419419
);
420+
registerArgumentsSet(
421+
'explain_delete',
422+
\Framework\Database\Manipulation\Delete::EXP_EXTENDED,
423+
\Framework\Database\Manipulation\Delete::EXP_FORMAT_JSON,
424+
\Framework\Database\Manipulation\Delete::EXP_PARTITIONS,
425+
'EXTENDED',
426+
'FORMAT=JSON',
427+
'PARTITIONS',
428+
);
429+
expectedArguments(
430+
\Framework\Database\Manipulation\Delete::explain(),
431+
0,
432+
argumentsSet('explain_delete')
433+
);
434+
registerArgumentsSet(
435+
'explain_select',
436+
\Framework\Database\Manipulation\Select::EXP_EXTENDED,
437+
\Framework\Database\Manipulation\Select::EXP_FORMAT_JSON,
438+
\Framework\Database\Manipulation\Select::EXP_PARTITIONS,
439+
'EXTENDED',
440+
'FORMAT=JSON',
441+
'PARTITIONS',
442+
);
443+
expectedArguments(
444+
\Framework\Database\Manipulation\Select::explain(),
445+
0,
446+
argumentsSet('explain_select')
447+
);
448+
registerArgumentsSet(
449+
'explain_update',
450+
\Framework\Database\Manipulation\Update::EXP_EXTENDED,
451+
\Framework\Database\Manipulation\Update::EXP_FORMAT_JSON,
452+
\Framework\Database\Manipulation\Update::EXP_PARTITIONS,
453+
'EXTENDED',
454+
'FORMAT=JSON',
455+
'PARTITIONS',
456+
);
457+
expectedArguments(
458+
\Framework\Database\Manipulation\Update::explain(),
459+
0,
460+
argumentsSet('explain_update')
461+
);

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
}
3434
],
3535
"require": {
36-
"php": ">=8.1",
36+
"php": ">=8.3",
3737
"ext-mysqli": "*",
38-
"aplus/debug": "^3.0",
39-
"aplus/log": "^3.0"
38+
"aplus/debug": "^4.0",
39+
"aplus/log": "^4.0"
4040
},
4141
"require-dev": {
4242
"ext-xdebug": "*",

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3"
22
services:
33
package:
4-
image: registry.gitlab.com/aplus-framework/images/package:2
4+
image: registry.gitlab.com/aplus-framework/images/package:4
55
container_name: package-database
66
working_dir: /package
77
volumes:

phpstan.neon.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ parameters:
55
- tests
66
ignoreErrors:
77
- '#Access to an undefined property object::\$[a-zA-Z0-9_]+\.#'
8+
- '#Access to an uninitialized readonly property Framework\\Database\\Result\\Field::#'
89
- '#Call to protected method sql\(\) of class Framework\\Database\\Definition\\Table\\Columns\\Column\.#'
910
- '#Call to protected method sql\(\) of class Framework\\Database\\Definition\\Table\\Indexes\\IndexDefinition\.#'
1011
- '#Call to protected method sql\(\) of class Framework\\Database\\Definition\\Table\\Indexes\\Index\.#'
1112
- '#Call to protected method sql\(\) of class Framework\\Database\\Definition\\Table\\TableDefinition\.#'
12-
- '#Cannot access offset [0-9]+ on array<int, Framework\\Database\\Result\\Field>\|false\.#'
13+
- '#Class Framework\\Database\\Result\\Field has an uninitialized readonly property#'
14+
- '#Class Framework\\Database\\Result\\Explain has an uninitialized readonly property#'
15+
- '#Readonly property Framework\\Database\\Result\\Field::\$[a-zA-Z0-9_]+ is assigned outside of the constructor.#'

src/Database.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use LogicException;
3434
use mysqli;
3535
use mysqli_sql_exception;
36+
use mysqli_warning;
3637
use RuntimeException;
3738
use SensitiveParameter;
3839

@@ -198,7 +199,9 @@ protected function connect(
198199
if ($this->failoverIndex === null) {
199200
$this->config = $config;
200201
}
201-
\mysqli_report($config['report']);
202+
if (isset($config['report'])) {
203+
\mysqli_report($config['report']);
204+
}
202205
$this->mysqli = new mysqli();
203206
foreach ($config['options'] as $option => $value) {
204207
$this->mysqli->options($option, $value);
@@ -345,17 +348,22 @@ public function getConfig() : array
345348
return $this->config;
346349
}
347350

348-
public function warnings() : int
351+
public function getWarningsCount() : int
349352
{
350353
return $this->mysqli->warning_count;
351354
}
352355

356+
public function getWarnings() : false | mysqli_warning
357+
{
358+
return $this->mysqli->get_warnings();
359+
}
360+
353361
/**
354362
* Get a list of the latest errors.
355363
*
356364
* @return array<int,array<string,mixed>>
357365
*/
358-
public function errors() : array
366+
public function getErrors() : array
359367
{
360368
return $this->mysqli->error_list;
361369
}
@@ -365,7 +373,7 @@ public function errors() : array
365373
*
366374
* @return string|null
367375
*/
368-
public function error() : ?string
376+
public function getError() : ?string
369377
{
370378
return $this->mysqli->error ?: null;
371379
}
@@ -595,7 +603,7 @@ public function with() : With
595603
return new With($this);
596604
}
597605

598-
public function lastQuery() : string
606+
public function getLastQuery() : string
599607
{
600608
return $this->lastQuery;
601609
}
@@ -711,7 +719,7 @@ public function transaction(callable $statements) : static
711719
*
712720
* @return int|string
713721
*/
714-
public function insertId() : int | string
722+
public function getInsertId() : int | string
715723
{
716724
return $this->mysqli->insert_id;
717725
}
@@ -801,7 +809,7 @@ protected function finalizeAddToDebug(
801809
$this->debugCollector->addData([
802810
'start' => $start,
803811
'end' => $end,
804-
'statement' => $this->lastQuery(),
812+
'statement' => $this->getLastQuery(),
805813
'rows' => $rows,
806814
'description' => $description,
807815
]);

src/Debug/DatabaseCollection.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of Aplus Framework Database Library.
4+
*
5+
* (c) Natan Felles <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace Framework\Database\Debug;
11+
12+
use Framework\Debug\Collection;
13+
14+
/**
15+
* Class DatabaseCollection.
16+
*
17+
* @package database
18+
*/
19+
class DatabaseCollection extends Collection
20+
{
21+
protected string $iconPath = __DIR__ . '/icons/database.svg';
22+
}

src/Debug/DatabaseCollector.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,13 @@
2020
class DatabaseCollector extends Collector
2121
{
2222
protected Database $database;
23-
/**
24-
* @var string
25-
*
26-
* @deprecated Use {@see Database::getConnection()}
27-
*/
28-
protected string $serverInfo;
2923

3024
public function setDatabase(Database $database) : static
3125
{
3226
$this->database = $database;
3327
return $this;
3428
}
3529

36-
/**
37-
* @param string $serverInfo
38-
*
39-
* @deprecated Use {@see Database::getConnection()}
40-
*
41-
* @codeCoverageIgnore
42-
*/
43-
public function setServerInfo(string $serverInfo) : void
44-
{
45-
\trigger_error(
46-
'Method ' . __METHOD__ . ' is deprecated',
47-
\E_USER_DEPRECATED
48-
);
49-
$this->serverInfo = $serverInfo;
50-
}
51-
5230
public function getServerInfo() : string
5331
{
5432
return $this->database->getConnection()->server_info;

src/Debug/icons/database.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)