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

Function adds_missing_throws

src/code_actions/update_docblock.rs:2024–2054  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2022
2023 #[test]
2024 fn adds_missing_throws() {
2025 let php = r#"<?php
2026class Foo {
2027 /**
2028 * @param string $a
2029 *
2030 * @return string
2031 */
2032 public function bar(string $a): string {
2033 throw new \RuntimeException('oops');
2034 }
2035}
2036"#;
2037 let pos = php.find("@param string").unwrap() as u32;
2038 let info = find_info(php, pos).unwrap();
2039 let cl = no_class_loader();
2040 let updated = build_updated_docblock(
2041 &info,
2042 php,
2043 &[],
2044 &cl,
2045 no_function_loader(),
2046 &HashMap::new(),
2047 &None,
2048 );
2049 assert!(
2050 updated.contains("@throws RuntimeException"),
2051 "Should add missing @throws: {}",
2052 updated
2053 );
2054 }
2055
2056 #[test]
2057 fn does_not_duplicate_existing_throws() {

Callers

nothing calls this directly

Calls 6

find_infoFunction · 0.85
no_class_loaderFunction · 0.85
build_updated_docblockFunction · 0.85
no_function_loaderFunction · 0.85
unwrapMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected