WordPress at Your Fingertips
function is not described


AbstractServiceProvider::get_class() private WC 1.0

Gets the class of a parameter.

This method is a replacement for ReflectionParameter::getClass, which is deprecated as of PHP 8.

{} It's a method of the class: AbstractServiceProvider{}

No Hooks.


\ReflectionClass|null. The class of the parameter, or null if it hasn't any.


// private - for code of main (parent) class only
$result = $this->get_class( $parameter );
$parameter(ReflectionParameter) (required)
The parameter to get the class for.

Code of AbstractServiceProvider::get_class() WC 5.9.0

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;