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
1 change: 1 addition & 0 deletions docs/changelogs/v4.8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,6 @@ Release Date: Unreleased
## Bugs Fixed

- **Config:** Fixed a bug where instantiating an anonymous `BaseConfig` subclass threw a `ValueError` from `getenv()` on PHP 8.6.
- **Testing:** Fixed a bug where `ReflectionHelper::getPrivateMethodInvoker()` passed an object when invoking a static method, which is deprecated in PHP 8.6.

See the repo's [CHANGELOG.md](https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md) for a complete list of bugs fixed.
4 changes: 2 additions & 2 deletions system/Test/ReflectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ trait ReflectionHelper
public static function getPrivateMethodInvoker($obj, $method)
{
$refMethod = new ReflectionMethod($obj, $method);
$obj = (gettype($obj) === 'object') ? $obj : null;
$object = gettype($obj) === 'object' && ! $refMethod->isStatic() ? $obj : null;

return static fn (...$args): mixed => $refMethod->invokeArgs($obj, $args);
return static fn (...$args): mixed => $refMethod->invokeArgs($object, $args);
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/system/Test/ReflectionHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ public function testGetPrivateMethodInvokerWithObject(): void
);
}

public function testGetPrivateMethodInvokerWithStaticMethodOnObject(): void
{
$method = self::getPrivateMethodInvoker(
new TestForReflectionHelper(),
'privateStaticMethod',
);
$this->assertSame(
'private_static param1param2',
$method('param1', 'param2'),
);
}

public function testGetPrivateMethodInvokerWithStatic(): void
{
$method = self::getPrivateMethodInvoker(
Expand Down
Loading