Skip to content

Commit 4c4987c

Browse files
phpfuishmax
andauthored
Port to PHP 8.4 (#121)
* Port to PHP 8.4 * Add default value for $isAscending * Update to PHP 8.4 and ubuntu-22.04 * use 8.3 for lint * make stan happy --------- Co-authored-by: shmax <shmax@shmax.com>
1 parent ae219b0 commit 4c4987c

61 files changed

Lines changed: 178 additions & 149 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/static-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
phpstan:
1212
name: PHPStan
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-22.04
1414
strategy:
1515
fail-fast: false
1616

@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
coverage: pcov
2525
ini-values: zend.assertions=1, assert.exception=1
26-
php-version: 8.1
26+
php-version: 8.4
2727
extensions: memcached
2828
tools: cs2pr
2929

.github/workflows/style.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
phpcsfixer:
1212
name: PHP CS Fixer
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-22.04
1414
strategy:
1515
fail-fast: false
1616

@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
coverage: pcov
2525
ini-values: zend.assertions=1, assert.exception=1
26-
php-version: 8.1
26+
php-version: 8.3
2727
extensions: memcached
2828
tools: cs2pr
2929

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
phpunit:
1212
name: PHPUnit
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-22.04
1414
services:
1515
memcached:
1616
image: memcached:1.6
@@ -47,6 +47,8 @@ jobs:
4747
php-version:
4848
- 8.1
4949
- 8.2
50+
- 8.3
51+
- 8.4
5052
database:
5153
- mysql
5254
- pgsql

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"php": ">=8.1.0"
1111
},
1212
"require-dev": {
13-
"phpstan/phpstan": "^1.10",
13+
"phpstan/phpstan": "1.12.23",
1414
"phpstan/phpstan-phpunit": "^1.3",
1515
"phpunit/phpunit": "^10",
1616
"friendsofphp/php-cs-fixer": "^v3.23.0",

lib/Adapter/MysqlAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @package ActiveRecord
45
*/
@@ -69,7 +70,7 @@ public function create_column(array $column): Column
6970

7071
$c->raw_type = (count($matches) > 0 ? $matches[1] : $column['type']);
7172

72-
if (count($matches) >= 4) {
73+
if (isset($matches[3])) {
7374
$c->length = intval($matches[3]);
7475
}
7576
}

lib/Adapter/PgsqlAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @package ActiveRecord
45
*/
@@ -131,7 +132,7 @@ public function create_column(array $column): Column
131132
preg_match('/^([A-Za-z0-9_]+)(\(([0-9]+(,[0-9]+)?)\))?/', $column['type'], $matches);
132133

133134
$c->raw_type = (count($matches) > 0 ? $matches[1] : $column['type']);
134-
$c->length = count($matches) >= 4 ? intval($matches[3]) : intval($column['attlen']);
135+
$c->length = isset($matches[3]) ? intval($matches[3]) : intval($column['attlen']);
135136

136137
if ($c->length < 0) {
137138
$c->length = null;

lib/Adapter/SqliteAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @package ActiveRecord
45
*/

lib/Cache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function flush(): void
8383
*
8484
* @param int $expire in seconds
8585
*/
86-
public static function get(string $key, \Closure $closure, int $expire = null): mixed
86+
public static function get(string $key, \Closure $closure, ?int $expire = null): mixed
8787
{
8888
if (!static::$adapter) {
8989
return $closure();
@@ -98,7 +98,7 @@ public static function get(string $key, \Closure $closure, int $expire = null):
9898
return $value;
9999
}
100100

101-
public static function set(string $key, mixed $var, int $expire = null): void
101+
public static function set(string $key, mixed $var, ?int $expire = null): void
102102
{
103103
assert(isset(static::$adapter), 'Adapter required to set');
104104

lib/CallBack.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @package ActiveRecord
45
*/
@@ -163,7 +164,7 @@ public function get_callbacks(string $name): array
163164
* that was for a before_* callback and that method returned false. If this happens, execution
164165
* of any other callbacks after the offending callback will not occur.
165166
*/
166-
public function invoke(Model|null $model, string $name, bool $must_exist = true)
167+
public function invoke(?Model $model, string $name, bool $must_exist = true)
167168
{
168169
if ($must_exist && !array_key_exists($name, $this->registry)) {
169170
throw new ActiveRecordException("No callbacks were defined for: $name on " . ($model ? get_class($model) : 'null'));
@@ -214,7 +215,7 @@ public function invoke(Model|null $model, string $name, bool $must_exist = true)
214215
*
215216
* @throws ActiveRecordException if invalid callback type or callback method was not found
216217
*/
217-
public function register(string $name, \Closure|string $closure_or_method_name = null, array $options = []): void
218+
public function register(string $name, \Closure|string|null $closure_or_method_name = null, array $options = []): void
218219
{
219220
$closure_or_method_name ??= $name;
220221

lib/Column.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @package ActiveRecord
45
*/
@@ -66,7 +67,7 @@ class Column
6667
/**
6768
* The maximum length of this column.
6869
*/
69-
public int|null $length = null;
70+
public ?int $length = null;
7071

7172
/**
7273
* True if this column allows null.

0 commit comments

Comments
 (0)