Skip to content

Commit

Permalink
Merge pull request #7911 from kenjis/fix-ReflectionHelper-setValue
Browse files Browse the repository at this point in the history
[PHP 8.3] refactor: ReflectionProperty::setValue() signature deprecation
  • Loading branch information
samsonasik authored Sep 8, 2023
2 parents eb1d5e0 + ddd2317 commit b38cec4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion system/Test/ReflectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ private static function getAccessibleRefProperty($obj, $property)
public static function setPrivateProperty($obj, $property, $value)
{
$refProperty = self::getAccessibleRefProperty($obj, $property);
$refProperty->setValue($obj, $value);

if (is_object($obj)) {
$refProperty->setValue($obj, $value);
} else {
$refProperty->setValue(null, $value);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/system/CLI/CLITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,13 @@ public function testWindow(): void
{
$height = new ReflectionProperty(CLI::class, 'height');
$height->setAccessible(true);
$height->setValue(null);
$height->setValue(null, null);

$this->assertIsInt(CLI::getHeight());

$width = new ReflectionProperty(CLI::class, 'width');
$width->setAccessible(true);
$width->setValue(null);
$width->setValue(null, null);

$this->assertIsInt(CLI::getWidth());
}
Expand Down

0 comments on commit b38cec4

Please sign in to comment.