Automattic\Jetpack\Autoloader\jp1c37d41437aca3a88a6b698473c4d5c4
Version_Loader::find_psr4_file() private WC 1.0
Finds the file for a given class in a PSR-4 namespace.
{} Это метод класса: Version_Loader{}
Хуков нет.
Возвращает
Массив/null. $data The version and path path to the file if found, null otherwise.
Использование
// private - только в коде основоного (родительского) класса $result = $this->find_psr4_file( $class_name );
- $class_name(строка) (обязательный)
- The class to find.
Код Version_Loader::find_psr4_file() Version Loader::find psr4 file WC 5.0.0
private function find_psr4_file( $class_name ) {
if ( ! isset( $this->psr4_map ) ) {
return null;
}
// Don't bother with classes that have no namespace.
$class_index = strrpos( $class_name, '\\' );
if ( ! $class_index ) {
return null;
}
$class_for_path = str_replace( '\\', '/', $class_name );
// Search for the namespace by iteratively cutting off the last segment until
// we find a match. This allows us to check the most-specific namespaces
// first as well as minimize the amount of time spent looking.
for (
$class_namespace = substr( $class_name, 0, $class_index );
! empty( $class_namespace );
$class_namespace = substr( $class_namespace, 0, strrpos( $class_namespace, '\\' ) )
) {
$namespace = $class_namespace . '\\';
if ( ! isset( $this->psr4_map[ $namespace ] ) ) {
continue;
}
$data = $this->psr4_map[ $namespace ];
foreach ( $data['path'] as $path ) {
$path .= '/' . substr( $class_for_path, strlen( $namespace ) ) . '.php';
if ( file_exists( $path ) ) {
return array(
'version' => $data['version'],
'path' => $path,
);
}
}
}
return null;
}