Skip to content

Commit 1144521

Browse files
committed
Preparing for next major 4.x version with PHP 8.2 as minimum requirement
1 parent 3480b53 commit 1144521

File tree

12 files changed

+70
-79
lines changed

12 files changed

+70
-79
lines changed

.github/workflows/php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
php: [8.4, 8.3, 8.2, 8.1]
19+
php: [8.5, 8.4, 8.3, 8.2]
2020
# prefer-lowest is causing unit tests to fail when php 7.2 is run against PHPunit 7.x,
2121
# PHPUnit 8.x is the latest stable release that supports PHP 7.2 and that runs fine
2222
# dependency-version: [prefer-lowest, prefer-stable]
@@ -66,7 +66,7 @@ jobs:
6666

6767
steps:
6868
- name: Checkout code
69-
uses: actions/checkout@v4
69+
uses: actions/checkout@v6
7070

7171
- name: Setup PHP
7272
uses: shivammathur/setup-php@v2

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ These are the branches in this repository:
5252
- more stricter type-hinting applied across the code-base, leading to changes in some of the interface method signatures.
5353
>This is going to be the branch in which code for version 3.x releases of **rotexsoft/sqlschema** will reside
5454
55+
- **rotexsoft-4.x:** contains version 4.x code
5556

5657
There will be future branches like **rotexsoft-4.x** & the likes for versions 4.x & above.
5758

composer.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,25 @@
2121
"homepage": "https://github.com/rotexdegba/Aura.SqlSchema",
2222
"license": ["BSD-2-Clause", "BSD-3-Clause"],
2323
"require": {
24-
"php": ">=8.1.0"
24+
"php": ">=8.2.0"
2525
},
2626
"autoload": {
2727
"psr-4": {
2828
"Rotexsoft\\SqlSchema\\": "src/"
2929
}
3030
},
3131
"require-dev": {
32-
"rector/rector": "^1.0.1",
33-
"phpunit/phpunit": "^10.5",
34-
"vimeo/psalm": "^5.22.1 || ^6.0.0",
32+
"rector/rector": "^2.0",
33+
"vimeo/psalm" : "^6.0.0",
34+
"phpunit/phpunit": "^12.0 || ^11.0",
3535
"php-coveralls/php-coveralls": "^2.0"
3636
},
3737
"scripts": {
3838
"test": [
3939
"Composer\\Config::disableProcessTimeout",
4040
"vendor/bin/phpunit --coverage-text"
4141
],
42-
"rector-clear": "vendor/bin/rector --clear-cache",
43-
"rector": "vendor/bin/rector process src --dry-run -vvv",
42+
"rector": "vendor/bin/rector process src --dry-run",
4443
"psalm-clear-cache": "vendor/bin/psalm --clear-global-cache && vendor/bin/psalm --clear-cache",
4544
"psalm": "composer psalm-clear-cache && vendor/bin/psalm --threads=1",
4645
"qa": "composer test && composer rector && composer psalm",

rector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
$rectorConfigurator->import(SetList::PHP_74);
2626
$rectorConfigurator->import(SetList::PHP_80);
2727
$rectorConfigurator->import(SetList::PHP_81);
28+
$rectorConfigurator->import(SetList::PHP_82);
2829
$rectorConfigurator->import(SetList::CODE_QUALITY);
2930
$rectorConfigurator->import(SetList::CODING_STYLE);
3031
$rectorConfigurator->import(SetList::DEAD_CODE);

run-tests-against-multiple-db-versions.php

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,57 +61,53 @@ function readableElapsedTime($microtime, $format = null, $round = 3) {
6161
$container_creation_commands = [
6262
[
6363
'mysql:5.6.51' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:5.6.51",
64-
'postgres:12.18' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:12.18",
64+
'postgres:12.22' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:12.22",
6565
],
6666
[
6767
'mysql:5.7.44' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:5.7.44",
68-
'postgres:13.14' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:13.14",
68+
'postgres:13.23' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:13.23",
6969
],
7070
[
71-
'mysql:8.0.36' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:8.0.36",
72-
'postgres:14.11' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:14.11",
71+
'mysql:8.0.45' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:8.0.45",
72+
'postgres:14.20' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:14.20",
7373
],
7474
[
75-
'mysql:8.2.0' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:8.2.0",
76-
'postgres:15.6' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:15.6",
75+
'mysql:8.4.8' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:8.4.8",
76+
'postgres:15.15' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:15.15",
7777
],
7878
[
79-
'mysql:8.3.0' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:8.3.0",
80-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
79+
'mysql:9.5.2' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mysql:9.5.2",
80+
'postgres:16.11' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.11",
8181
],
8282

8383
// Maria db
8484
[
85-
'mariadb:10.4.33' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:10.4.33",
86-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
85+
'mariadb:10.4.34' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:10.4.34",
86+
'postgres:17.7' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:17.7",
8787
],
8888
[
89-
'mariadb:10.5.24' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:10.5.24",
90-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
89+
'mariadb:10.5.29' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:10.5.29",
90+
'postgres:18.1' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:18.1",
9191
],
9292
[
93-
'mariadb:10.6.17' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:10.6.17",
94-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
93+
'mariadb:10.6.24' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:10.6.24",
94+
'postgres:18.1' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:18.1",
9595
],
9696
[
97-
'mariadb:10.11.7' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:10.11.7",
98-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
97+
'postgres:18.1' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:18.1",
98+
'mariadb:10.11.15' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:10.11.15",
9999
],
100100
[
101-
'mariadb:11.0.5' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:11.0.5",
102-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
101+
'mariadb:11.4.9' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:11.4.9",
102+
'postgres:18.1' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:18.1",
103103
],
104104
[
105-
'mariadb:11.1.4' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:11.1.4",
106-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
105+
'postgres:18.1' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:18.1",
106+
'mariadb:11.8.5' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:11.8.5",
107107
],
108108
[
109-
'mariadb:11.2.3' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:11.2.3",
110-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
111-
],
112-
[
113-
'mariadb:11.3.2' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:11.3.2",
114-
'postgres:16.2' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:16.2",
109+
'mariadb:12.1.2' => "podman run -dt -p 3306:3306 -e MYSQL_ROOT_PASSWORD={$mysql_root_psw} docker.io/library/mariadb:12.1.2",
110+
'postgres:18.1' => "podman run -dt -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust docker.io/library/postgres:18.1",
115111
],
116112
];
117113

src/AbstractSchema.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function __construct(protected \PDO $pdo, protected \Rotexsoft\SqlSchema\
5353
* Returns the column factory object.
5454
*
5555
*/
56+
#[\Override]
5657
public function getColumnFactory(): ColumnFactory
5758
{
5859
return $this->column_factory;
@@ -111,7 +112,7 @@ protected function getTypeSizeScope(string $spec): array
111112
* element 0 will be null and element 1 will be the name as given.
112113
*
113114
*/
114-
protected function splitName(string $name)
115+
protected function splitName(string $name): array
115116
{
116117
$pos = strpos($name, '.');
117118
if ($pos === false) {
@@ -167,10 +168,8 @@ public function quoteName(string $name): string
167168
*
168169
* @param array $values Values to bind to the SQL statement.
169170
*
170-
* @return array
171-
*
172171
*/
173-
protected function pdoFetchAll($statement, array $values = [])
172+
protected function pdoFetchAll($statement, array $values = []): array
174173
{
175174
$sth = $this->pdo->prepare($statement);
176175
$sth->execute($values);
@@ -185,10 +184,8 @@ protected function pdoFetchAll($statement, array $values = [])
185184
*
186185
* @param array $values Values to bind to the SQL statement.
187186
*
188-
* @return array
189-
*
190187
*/
191-
protected function pdoFetchCol($statement, array $values = [])
188+
protected function pdoFetchCol($statement, array $values = []): array
192189
{
193190
$sth = $this->pdo->prepare($statement);
194191
$sth->execute($values);
@@ -203,10 +200,8 @@ protected function pdoFetchCol($statement, array $values = [])
203200
*
204201
* @param array $values Values to bind to the SQL statement.
205202
*
206-
* @return mixed
207-
*
208203
*/
209-
protected function pdoFetchValue($statement, array $values = [])
204+
protected function pdoFetchValue($statement, array $values = []): mixed
210205
{
211206
$sth = $this->pdo->prepare($statement);
212207
$sth->execute($values);

src/Column.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
namespace Rotexsoft\SqlSchema;
1010

1111
/**
12-
*
12+
* @psalm-suppress ClassMustBeFinal
13+
*
1314
* Represents one column from a table.
1415
*
1516
* @package Aura.SqlSchema
@@ -111,7 +112,7 @@ public function __construct(
111112
* @psalm-suppress PossiblyUnusedMethod
112113
*
113114
*/
114-
public function __get($key)
115+
public function __get(string $key): mixed
115116
{
116117
return $this->$key;
117118
}
@@ -120,10 +121,8 @@ public function __get($key)
120121
* Check if the property is defined with any value
121122
*
122123
* @param string $key The property name.
123-
*
124-
* @return bool
125124
*/
126-
public function __isset($key)
125+
public function __isset(string $key): bool
127126
{
128127
return property_exists($this, $key);
129128
}
@@ -145,7 +144,7 @@ public function __isset($key)
145144
*
146145
* @psalm-suppress MixedArgument
147146
*/
148-
public static function __set_state(array $array)
147+
public static function __set_state(array $array): object
149148
{
150149
return new \Rotexsoft\SqlSchema\Column(
151150
(string) $array['name'],

src/ColumnFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* A factory for column objects.
1414
*
1515
* @package Aura.SqlSchema
16-
*
16+
* @psalm-suppress ClassMustBeFinal
1717
*/
1818
class ColumnFactory
1919
{

src/MysqlSchema.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is part of Aura for PHP.
55
*
66
* @license http://opensource.org/licenses/bsd-license.php BSD
7-
*
87
*/
98
namespace Rotexsoft\SqlSchema;
109

@@ -15,6 +14,7 @@
1514
* @package Aura.SqlSchema
1615
*
1716
* @psalm-suppress UnusedClass
17+
* @psalm-suppress ClassMustBeFinal
1818
*/
1919
class MysqlSchema extends AbstractSchema
2020
{
@@ -50,15 +50,17 @@ public function __construct(\PDO $pdo, ColumnFactory $column_factory) {
5050

5151
$pdoObjId = \spl_object_hash($pdo);
5252

53+
/** @psalm-suppress MixedAssignment */
5354
$vars =
54-
!\array_key_exists($pdoObjId, static::$varsMap)
55-
? $pdo->query("SHOW VARIABLES LIKE '%version%'")
56-
->fetchAll(\PDO::FETCH_KEY_PAIR) // fetch values from DB
57-
: static::$varsMap[$pdoObjId]; // use cached value
55+
\array_key_exists($pdoObjId, static::$varsMap)
56+
? static::$varsMap[$pdoObjId] // use cached value
57+
: $pdo->query("SHOW VARIABLES LIKE '%version%'")
58+
->fetchAll(\PDO::FETCH_KEY_PAIR); // fetch values from DB
5859

5960
// cache result for this pdo connection
6061
if(!\array_key_exists($pdoObjId, static::$varsMap)) {
6162

63+
/** @psalm-suppress MixedAssignment */
6264
static::$varsMap[$pdoObjId] = $vars;
6365
}
6466

@@ -81,6 +83,7 @@ public function __construct(\PDO $pdo, ColumnFactory $column_factory) {
8183
*
8284
* @psalm-suppress MixedReturnTypeCoercion
8385
*/
86+
#[\Override]
8487
public function fetchTableList(?string $schema = null): array
8588
{
8689
$text = 'SHOW TABLES';
@@ -106,6 +109,7 @@ public function fetchTableList(?string $schema = null): array
106109
* @psalm-suppress MixedArrayOffset
107110
* @psalm-suppress MixedArgument
108111
*/
112+
#[\Override]
109113
public function fetchTableCols(string $spec): array
110114
{
111115
[$schema, $table] = $this->splitName($spec);
@@ -171,10 +175,8 @@ public function fetchTableCols(string $spec): array
171175
*
172176
* @param mixed $default The default value as reported by MySQL.
173177
*
174-
* @return mixed
175-
*
176178
*/
177-
protected function getDefault(mixed $default, bool $nullable)
179+
protected function getDefault(mixed $default, bool $nullable): mixed
178180
{
179181
if ($this->maria && $nullable && $default === 'NULL') {
180182
return null;

src/PgsqlSchema.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is part of Aura for PHP.
55
*
66
* @license http://opensource.org/licenses/bsd-license.php BSD
7-
*
87
*/
98
namespace Rotexsoft\SqlSchema;
109

@@ -15,6 +14,7 @@
1514
* @package Aura.SqlSchema
1615
*
1716
* @psalm-suppress UnusedClass
17+
* @psalm-suppress ClassMustBeFinal
1818
*/
1919
class PgsqlSchema extends AbstractSchema
2020
{
@@ -29,6 +29,7 @@ class PgsqlSchema extends AbstractSchema
2929
*
3030
* @psalm-suppress MixedReturnTypeCoercion
3131
*/
32+
#[\Override]
3233
public function fetchTableList(?string $schema = null): array
3334
{
3435
if ($schema !== null) {
@@ -65,6 +66,7 @@ public function fetchTableList(?string $schema = null): array
6566
* @psalm-suppress MixedArrayAccess
6667
* @psalm-suppress MixedArrayOffset
6768
*/
69+
#[\Override]
6870
public function fetchTableCols(string $spec): array
6971
{
7072
[$schema, $table] = $this->splitName($spec);
@@ -157,7 +159,7 @@ public function fetchTableCols(string $spec): array
157159
*
158160
* @psalm-suppress PossiblyUnusedParam
159161
*/
160-
protected function getDefault(mixed $default, string $type, bool $nullable)
162+
protected function getDefault(mixed $default, string $type, bool $nullable): mixed
161163
{
162164
// null?
163165
if ($default === null || strtoupper((string)$default) === 'NULL') {
@@ -182,12 +184,8 @@ protected function getDefault(mixed $default, string $type, bool $nullable)
182184
return null;
183185
}
184186

185-
/**
186-
* @psalm-suppress MixedInferredReturnType
187-
* @psalm-suppress MixedReturnStatement
188-
*/
189187
public function fetchCurrentSchema() : string
190188
{
191-
return $this->pdoFetchValue('SELECT CURRENT_SCHEMA');
189+
return (string)$this->pdoFetchValue('SELECT CURRENT_SCHEMA');
192190
}
193191
}

0 commit comments

Comments
 (0)