Skip to content

Commit 9dcbb50

Browse files
authored
Merge pull request #20 from andreamk/20251118_upate_for_php_8.5
Update PHP versions in PHPUnit workflow to include 8.4
2 parents 4a6256d + a546ce4 commit 9dcbb50

7 files changed

Lines changed: 16 additions & 12 deletions

File tree

.github/workflows/phpunit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
php-versions: [7.4, 8.0, 8.2, 8.3]
11+
php-versions: [7.4, 8.0, 8.2, 8.3, 8.4]
1212
name: PHP ${{ matrix.php-versions }}
1313

1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717

1818
- name: Install PHP
1919
uses: shivammathur/setup-php@v2
@@ -33,7 +33,7 @@ jobs:
3333

3434
- name: Cache Composer packages
3535
id: composer-cache
36-
uses: actions/cache@v2
36+
uses: actions/cache@v4
3737
with:
3838
path: vendor
3939
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}

.github/workflows/phpunit_php5.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717

1818
- name: Install PHP
1919
uses: shivammathur/setup-php@v2

src/AbstractJsonSerializeObjData.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ final protected static function objectToJsonData($obj, $flags = 0, $objParents =
6969
if ($includeProps !== true && !in_array($propName, $includeProps)) {
7070
continue;
7171
}
72-
$prop->setAccessible(true);
72+
if (PHP_VERSION_ID < 80100) {
73+
$prop->setAccessible(true);
74+
}
7375
$propValue = $prop->getValue($obj);
7476
$result[$propName] = self::valueToJsonData($propValue, $flags, $objParents);
7577
}
@@ -237,7 +239,9 @@ final protected static function fillObjFromValue($value, $obj, $flags = 0, $map
237239
} else {
238240
$reflect = new ReflectionObject($obj);
239241
foreach ($reflect->getProperties() as $prop) {
240-
$prop->setAccessible(true);
242+
if (PHP_VERSION_ID < 80100) {
243+
$prop->setAccessible(true);
244+
}
241245
$propName = $prop->getName();
242246
if ($map !== null) {
243247
$map->setCurrent($propName, $current);

src/JsonSerialize.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public static function unserializeWithMap($json, JsonUnserializeMap $map, $depth
114114
public static function unserializeToObj($json, $obj, $depth = 512, $flags = 0)
115115
{
116116
if (is_object($obj)) {
117-
} elseif (is_string($obj) && class_exists($obj)) {
117+
} elseif (is_string($obj) && class_exists($obj)) { // @phpstan-ignore function.alreadyNarrowedType
118118
$obj = self::getObjFromClass($obj);
119119
} else {
120120
throw new Exception('invalid obj param');
@@ -210,7 +210,7 @@ protected static function convertString($string)
210210
if ($use_mb) {
211211
$encoding = mb_detect_encoding($string, null, true);
212212
if ($encoding) {
213-
return mb_convert_encoding($string, 'UTF-8', $encoding);
213+
return (string) mb_convert_encoding($string, 'UTF-8', $encoding);
214214
} else {
215215
return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
216216
}

src/JsonUnserializeMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ class JsonUnserializeMap
4646
/**
4747
* Class constructor
4848
*
49-
* @param array<string, string> $map values map
49+
* @param array<string,string> $map values map
5050
*/
5151
public function __construct($map = [])
5252
{
53-
if (!is_array($map)) {
53+
if (!is_array($map)) { // @phpstan-ignore function.alreadyNarrowedType
5454
throw new Exception('map must be an array');
5555
}
5656
$this->map = new MapItem();

tests/StdClassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testStdClass()
5151
$serializedValue = JsonSerialize::serialize($value);
5252
$this->assertTrue(is_string($serializedValue), 'Value is string');
5353
$unserializedValue = JsonSerialize::unserialize($serializedValue);
54-
$this->assertSame($unserializedValue->c->e, null, 'Test stdClass object recursion'); /** @phpstan-ignore-line */
54+
$this->assertSame($unserializedValue->c->e, null, 'Test stdClass object recursion');
5555

5656
$obj = new stdClass();
5757
$obj->a = 1;

tests/phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
level: 9
2+
level: 8
33
paths:
44
- ..
55
excludePaths:

0 commit comments

Comments
 (0)