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
4 changes: 4 additions & 0 deletions .github/workflows/tests-unit-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ jobs:
wp: 'trunk'
experimental: true

- php: 'nightly'
wp: 'trunk'
experimental: true

steps:
- name: Harden Runner
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911
Expand Down
16 changes: 12 additions & 4 deletions tests/phpunit/shared/Private_Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ trait Private_Access {
*/
protected function call_private_method( $callback, array $args = [] ) {
$method = ( new ReflectionClass( $callback[0] ) )->getMethod( $callback[1] );
$method->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$method->setAccessible( true );
}
return $method->invokeArgs( $callback[0], $args );
}

Expand All @@ -72,7 +74,9 @@ protected function call_private_method( $callback, array $args = [] ) {
*/
protected function call_private_static_method( $callback, array $args = [] ) {
$method = ( new ReflectionClass( $callback[0] ) )->getMethod( $callback[1] );
$method->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$method->setAccessible( true );
}
return $method->invokeArgs( null, $args );
}

Expand All @@ -88,7 +92,9 @@ protected function call_private_static_method( $callback, array $args = [] ) {
protected function set_private_property( $instance, string $property_name, $value ): void {
$reflection_class = new ReflectionClass( $instance );
$property = $reflection_class->getProperty( $property_name );
$property->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$property->setAccessible( true );
}

$property->isStatic() ? $reflection_class->setStaticPropertyValue( $property_name, $value ) : $property->setValue( $instance, $value );
}
Expand All @@ -104,7 +110,9 @@ protected function set_private_property( $instance, string $property_name, $valu
*/
protected function get_private_property( $instance, string $property_name ) {
$property = ( new ReflectionClass( $instance ) )->getProperty( $property_name );
$property->setAccessible( true );
if ( PHP_VERSION_ID < 80100 ) {
$property->setAccessible( true );
}
return $property->getValue( $instance );
}

Expand Down
Loading