Automattic\WooCommerce

Autoloader::read_scoped_psr4_mappublic staticWC 11.0.0

Read the scoped PSR-4 prefix map out of a built fallback loader, degrading to null on any non-array shape.

ClassLoader::getPrefixesPsr4() carries no return-type declaration, so an older or foreign Composer\Autoload\ClassLoader — one another plugin or wp-cli loaded from a different path, then reused by {@see self::build_woocommerce_psr4_fallback()} — may return a non-array. The registered handler passes this map straight into {@see self::find_scoped_file()}, whose array $psr4_entries parameter would raise an uncatchable TypeError on the first autoload miss, outside the handler's own try/catch. Validating here keeps the fallback's degrade-don't-fatal contract whole, mirroring the is_array() guard build() already applies to the file-sourced map.

Метод класса: Autoloader{}

Хуков нет.

Возвращает

Массив<Строку,. list<string>>|null The scoped PSR-4 map, or null on a non-array shape.

Использование

$result = Autoloader::read_scoped_psr4_map( $loader ): ?array;
$loader(ClassLoader) (обязательный)
A loader returned by build_woocommerce_psr4_fallback().

Список изменений

С версии 11.0.0 Введена.

Код Autoloader::read_scoped_psr4_map() WC 11.0.1

public static function read_scoped_psr4_map( ClassLoader $loader ): ?array {
	$psr4_entries = $loader->getPrefixesPsr4();

	return is_array( $psr4_entries ) ? $psr4_entries : null;
}