Skip to content

Commit 3b4bf95

Browse files
committed
Add PHP 8.4, drop PHP 8.1
1 parent eba9988 commit 3b4bf95

File tree

6 files changed

+47
-28
lines changed

6 files changed

+47
-28
lines changed

.github/workflows/check.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Check
22

33
on:
44
push:
5-
branches: ['3.0']
5+
branches: ['4.0']
66
pull_request:
7-
branches: ['3.0']
7+
branches: ['4.0']
88

99
jobs:
1010

@@ -14,11 +14,11 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.1', '8.2', '8.3']
17+
php: ['8.2', '8.3', '8.4']
1818
steps:
1919

2020
- name: Checkout
21-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
2222

2323
- name: Setup PHP
2424
uses: shivammathur/setup-php@v2
@@ -28,10 +28,10 @@ jobs:
2828

2929
- name: Get composer cache directory
3030
id: composer-cache
31-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
31+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3232

3333
- name: Cache composer dependencies
34-
uses: actions/cache@v2
34+
uses: actions/cache@v4
3535
with:
3636
path: ${{ steps.composer-cache.outputs.dir }}
3737
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}

.php-cs-fixer.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$config = new PhpCsFixer\Config();
4+
5+
return $config
6+
->setRules([
7+
'@PSR12' => true,
8+
'@PHP82Migration' => true,
9+
])
10+
->setFinder(
11+
PhpCsFixer\Finder::create()
12+
->in(__DIR__)
13+
);

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 4.0.0
4+
5+
### PHP support
6+
7+
- Dropped support for PHP `8.1` and lower.
8+
- Added support for PHP `8.4`.
9+
- Removed `DomainObject::propertyIsTraversable`.
10+
311
## 3.0.0
412

513
### PHP support

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
}
2323
},
2424
"require": {
25-
"php": "8.1.* || 8.2.* || 8.3.*"
25+
"php": "8.2 - 8.4"
2626
},
2727
"require-dev": {
28-
"phpstan/phpstan": "1.10.46",
29-
"phpunit/phpunit": "10.4.2",
30-
"squizlabs/php_codesniffer": "3.7.2"
28+
"phpstan/phpstan": "2.0.3",
29+
"phpunit/phpunit": "11.5.1",
30+
"squizlabs/php_codesniffer": "3.11.2",
31+
"friendsofphp/php-cs-fixer": "^3.65"
3132
}
3233
}

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ parameters:
2121
path: tests/AngryBytes/DomainObject/Test/ComposedTest.php
2222

2323
-
24-
message: "#^Parameter \\#2 \\$array of method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) expects array\\|ArrayAccess, mixed given\\.$#"
24+
identifier: argument.type
2525
count: 2
2626
path: tests/AngryBytes/DomainObject/Test/ComposedTest.php
2727

src/AngryBytes/DomainObject.php

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,37 +116,34 @@ public function toArrayWithProperties(array $properties): array
116116
*/
117117
public function getPropertyValueAsSimple(string $property)
118118
{
119-
if ($this->$property instanceof DomainObject) {
119+
$value = $this->$property;
120+
121+
if ($value instanceof DomainObject) {
120122
// Simple recursion for child DO's
121-
return $this->$property->toArray();
123+
return $value->toArray();
122124
}
123125

124-
if ($this->propertyIsTraversable($property)) {
126+
if ($value instanceof \stdClass) {
127+
$value = (array) $value;
128+
}
129+
if (is_iterable($value)) {
125130
// Property is traversable
126-
$value = [];
131+
$newValue = [];
127132

128133
// Traverse the
129-
foreach ($this->$property as $childKey => $childValue) {
134+
foreach ($value as $childKey => $childValue) {
130135
if ($childValue instanceof DomainObject) {
131-
$value[$childKey] = $childValue->toArray();
136+
$newValue[$childKey] = $childValue->toArray();
132137
} else {
133-
$value[$childKey] = $childValue;
138+
$newValue[$childKey] = $childValue;
134139
}
135140
}
136141

137-
return $value;
142+
return $newValue;
138143
}
139144

140145
// All other properties are returned as is
141-
return $this->$property;
142-
}
143-
144-
/**
145-
* Is a property traversable?
146-
*/
147-
public function propertyIsTraversable(string $property): bool
148-
{
149-
return is_iterable($this->$property) || $this->$property instanceof \stdClass;
146+
return $value;
150147
}
151148

152149
/**

0 commit comments

Comments
 (0)