Skip to content

Commit e29939d

Browse files
committed
PHP 8: Native support for union types
1 parent 3cbfccd commit e29939d

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Install PHP
1313
uses: shivammathur/setup-php@master
1414
with:
15-
php-version: 7.4
15+
php-version: 8.0
1616

1717
- name: Install composer deps
1818
run: |
@@ -26,7 +26,7 @@ jobs:
2626
- name: Check coding standards
2727
run: |
2828
php temp/code-checker/code-checker --short-arrays --strict-types --fix --no-progress
29-
php temp/coding-standard/ecs check src --config temp/coding-standard/coding-standard-php71.yml
29+
php temp/coding-standard/ecs check src --config temp/coding-standard/coding-standard-php80.yml
3030
3131
- name: Check PHPStan rules
3232
run: composer phpstan

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=7.4.0"
12+
"php": ">=8.0.0"
1313
},
1414
"require-dev": {
1515
"phpstan/phpstan": "^0.12.52",
@@ -24,7 +24,7 @@
2424
},
2525
"config": {
2626
"platform": {
27-
"php": "7.4.0"
27+
"php": "8.0.0"
2828
}
2929
},
3030
"scripts": {

src/SelectboxItem.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,14 @@
77

88
final class SelectboxItem
99
{
10-
/** @var int|string */
11-
private $id;
10+
private int|string $id;
1211

1312
private string $name;
1413

15-
/** @var int|string|null */
16-
private $parentId;
14+
private int|string|null $parentId;
1715

1816

19-
/**
20-
* @param int|string $id
21-
* @param int|string|null $parentId
22-
*/
23-
public function __construct($id, string $name, $parentId = null)
17+
public function __construct(int|string $id, string $name, int|string|null $parentId = null)
2418
{
2519
$this->id = $id;
2620
$this->name = $name;
@@ -36,7 +30,7 @@ public function toArray(): array
3630
return [
3731
'id' => $this->id,
3832
'name' => $this->name,
39-
'parent_id' => $this->parentId,
33+
'parent' => $this->parentId,
4034
];
4135
}
4236
}

src/SelectboxTree.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ public function setNameFormatter(NameFormatter $nameFormatter): void
9292
* Build category tree to simple selectbox array.
9393
*
9494
* @param string[][]|null[][]|null $categories
95-
* @param int|string|null $parent
9695
* @return mixed[][]
9796
*/
98-
private function serializeCategoriesToSelectbox(?array $categories, int $level = 0, $parent = null): array
97+
private function serializeCategoriesToSelectbox(?array $categories, int $level = 0, int|string|null $parent = null): array
9998
{
10099
static $usedIds = [];
101100

0 commit comments

Comments
 (0)