MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / create_psr4_workspace

Function create_psr4_workspace

tests/integration/common/mod.rs:430–448  ·  view source on GitHub ↗

Helper: create a temp workspace with a composer.json and PHP files, then return a Backend configured with that workspace root + PSR-4 mappings.

(
    composer_json: &str,
    files: &[(&str, &str)],
)

Source from the content-addressed store, hash-verified

428/// Helper: create a temp workspace with a composer.json and PHP files,
429/// then return a Backend configured with that workspace root + PSR-4 mappings.
430pub fn create_psr4_workspace(
431 composer_json: &str,
432 files: &[(&str, &str)],
433) -> (Backend, tempfile::TempDir) {
434 let dir = tempfile::tempdir().expect("failed to create temp dir");
435 fs::write(dir.path().join("composer.json"), composer_json)
436 .expect("failed to write composer.json");
437 for (rel_path, content) in files {
438 let full = dir.path().join(rel_path);
439 if let Some(parent) = full.parent() {
440 fs::create_dir_all(parent).expect("failed to create dirs");
441 }
442 fs::write(&full, content).expect("failed to write PHP file");
443 }
444
445 let (mappings, _vendor_dir) = phpantom_lsp::composer::parse_composer_json(dir.path());
446 let backend = Backend::new_test_with_workspace(dir.path().to_path_buf(), mappings);
447 (backend, dir)
448}
449
450/// Like [`create_psr4_workspace`] but the returned backend also has
451/// minimal `Exception` and `RuntimeException` stubs injected. This

Calls 1

parse_composer_jsonFunction · 0.85