Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: [7.4, 8.0, 8.2, 8.3]
php-versions: [7.4, 8.0, 8.2, 8.3, 8.4]
name: PHP ${{ matrix.php-versions }}

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand All @@ -33,7 +33,7 @@ jobs:

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit_php5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand Down
8 changes: 6 additions & 2 deletions src/AbstractJsonSerializeObjData.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ final protected static function objectToJsonData($obj, $flags = 0, $objParents =
if ($includeProps !== true && !in_array($propName, $includeProps)) {
continue;
}
$prop->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$prop->setAccessible(true);
}
$propValue = $prop->getValue($obj);
$result[$propName] = self::valueToJsonData($propValue, $flags, $objParents);
}
Expand Down Expand Up @@ -237,7 +239,9 @@ final protected static function fillObjFromValue($value, $obj, $flags = 0, $map
} else {
$reflect = new ReflectionObject($obj);
foreach ($reflect->getProperties() as $prop) {
$prop->setAccessible(true);
if (PHP_VERSION_ID < 80100) {
$prop->setAccessible(true);
}
$propName = $prop->getName();
if ($map !== null) {
$map->setCurrent($propName, $current);
Expand Down
4 changes: 2 additions & 2 deletions src/JsonSerialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function unserializeWithMap($json, JsonUnserializeMap $map, $depth
public static function unserializeToObj($json, $obj, $depth = 512, $flags = 0)
{
if (is_object($obj)) {
} elseif (is_string($obj) && class_exists($obj)) {
} elseif (is_string($obj) && class_exists($obj)) { // @phpstan-ignore function.alreadyNarrowedType
$obj = self::getObjFromClass($obj);
} else {
throw new Exception('invalid obj param');
Expand Down Expand Up @@ -210,7 +210,7 @@ protected static function convertString($string)
if ($use_mb) {
$encoding = mb_detect_encoding($string, null, true);
if ($encoding) {
return mb_convert_encoding($string, 'UTF-8', $encoding);
return (string) mb_convert_encoding($string, 'UTF-8', $encoding);
} else {
return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
}
Expand Down
4 changes: 2 additions & 2 deletions src/JsonUnserializeMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ class JsonUnserializeMap
/**
* Class constructor
*
* @param array<string, string> $map values map
* @param array<string,string> $map values map
*/
public function __construct($map = [])
{
if (!is_array($map)) {
if (!is_array($map)) { // @phpstan-ignore function.alreadyNarrowedType
throw new Exception('map must be an array');
}
$this->map = new MapItem();
Expand Down
2 changes: 1 addition & 1 deletion tests/StdClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testStdClass()
$serializedValue = JsonSerialize::serialize($value);
$this->assertTrue(is_string($serializedValue), 'Value is string');
$unserializedValue = JsonSerialize::unserialize($serializedValue);
$this->assertSame($unserializedValue->c->e, null, 'Test stdClass object recursion'); /** @phpstan-ignore-line */
$this->assertSame($unserializedValue->c->e, null, 'Test stdClass object recursion');

$obj = new stdClass();
$obj->a = 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 9
level: 8
paths:
- ..
excludePaths:
Expand Down