Automattic\WooCommerce
Autoloader::read_scoped_file_path
Read a resolved file path out of a fallback loader's findFile(), degrading to null on any non-string shape.
The sibling of {@see self::read_scoped_psr4_map()}: ClassLoader::findFile() carries no return-type declaration either, so the same older or foreign Composer\Autoload\ClassLoader reused by {@see self::build_woocommerce_psr4_fallback()} may return a non-string. The caller, {@see self::find_scoped_file()}, declares a : ?string return, so a non-string result would raise an uncatchable TypeError at that return statement — which, on an autoload miss, runs outside the registered handler's own try/catch, exactly the shape this fallback guards against for getPrefixesPsr4(). Composer's own miss sentinel is false, which is not a string and so degrades to null here, unchanged. Validating keeps the degrade-don't-fatal contract whole.
Метод класса: Autoloader{}
Хуков нет.
Возвращает
Строку|null. The resolved absolute file path, or null on a miss or non-string shape.
Использование
$result = Autoloader::read_scoped_file_path( $loader, $class_name ): ?string;
- $loader(ClassLoader) (обязательный)
- A loader built from the scoped PSR-4 map.
- $class_name(строка) (обязательный)
- Fully-qualified class name to resolve.
Список изменений
| С версии 11.0.0 | Введена. |
Код Autoloader::read_scoped_file_path() Autoloader::read scoped file path WC 11.0.1
public static function read_scoped_file_path( ClassLoader $loader, string $class_name ): ?string {
$file = $loader->findFile( $class_name );
return is_string( $file ) ? $file : null;
}