Skip to main content

resolve_php_import

Function resolve_php_import 

Source
pub fn resolve_php_import(
    import_path: &str,
    _current_file: &str,
    project_root: &Path,
) -> Option<String>
Expand description

Resolve a PHP import path to a file path

This function handles PHP-specific namespace-to-file mapping:

  • Converts backslash-separated namespaces to forward-slash paths
  • Handles PSR-4 autoloading conventions
  • Filters out external vendor namespaces (returns None for non-project code)

§Arguments

  • import_path - PHP namespace path (e.g., “App\Http\Controllers\UserController”)
  • current_file - Not used for PHP (PHP uses absolute namespaces)
  • project_root - Root directory of the project

§Returns

Some(path) if the import resolves to a project file, None if it’s external/stdlib

§Examples

  • App\\Http\\Controllers\\FooControllerapp/Http/Controllers/FooController.php
  • App\\Models\\Userapp/Models/User.php
  • Illuminate\\Database\\MigrationNone (external vendor namespace)