Skip to content

Commit

Permalink
Fix for compatibility of reflection function with PHP 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Konamiman committed Oct 19, 2020
1 parent 042e2cd commit 9aaee3d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Internal/DependencyManagement/AbstractServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ protected function add_with_auto_arguments( string $class_name, $concrete = null
* @return \ReflectionClass|null The class of the parameter, or null if it hasn't any.
*/
private function get_class( \ReflectionParameter $parameter ) {
// TODO: Remove this 'if' block once minimum PHP version for WooCommerce is bumped to at least 7.1.
if ( version_compare( PHP_VERSION, '7.1', '<' ) ) {
return $parameter->getClass();
}

return $parameter->getType() && ! $parameter->getType()->isBuiltin()
? new \ReflectionClass( $parameter->getType()->getName() )
: null;
Expand Down

0 comments on commit 9aaee3d

Please sign in to comment.