()
| 1372 | |
| 1373 | #[test] |
| 1374 | fn completions_bare_at_function() { |
| 1375 | // Function with a param, non-void return, and a throw so that smart |
| 1376 | // tags are emitted for @param, @return, and @throws. |
| 1377 | let content = "<?php\n/**\n * @\n */\nfunction foo(string $x): int {\n throw new RuntimeException('boom');\n}\n"; |
| 1378 | let pos = Position { |
| 1379 | line: 2, |
| 1380 | character: 4, |
| 1381 | }; |
| 1382 | let items = build_phpdoc_completions( |
| 1383 | content, |
| 1384 | "@", |
| 1385 | DocblockContext::FunctionOrMethod, |
| 1386 | pos, |
| 1387 | &std::collections::HashMap::new(), |
| 1388 | &None, |
| 1389 | &SmartContext::EMPTY, |
| 1390 | ); |
| 1391 | let labels: Vec<&str> = items.iter().map(|i| i.label.as_str()).collect(); |
| 1392 | |
| 1393 | // Should suggest function tags (some may have pre-filled info) |
| 1394 | assert!( |
| 1395 | labels |
| 1396 | .iter() |
| 1397 | .any(|l| l.starts_with("@param") || l == &"@param Type $name"), |
| 1398 | "Should suggest @param. Got: {:?}", |
| 1399 | labels |
| 1400 | ); |
| 1401 | assert!( |
| 1402 | labels.iter().any(|l| l.starts_with("@return")), |
| 1403 | "Should suggest @return. Got: {:?}", |
| 1404 | labels |
| 1405 | ); |
| 1406 | assert!( |
| 1407 | labels.iter().any(|l| l.starts_with("@throws")), |
| 1408 | "Should suggest @throws. Got: {:?}", |
| 1409 | labels |
| 1410 | ); |
| 1411 | assert!( |
| 1412 | labels.iter().any(|l| l == &"@deprecated"), |
| 1413 | "Should suggest @deprecated" |
| 1414 | ); |
| 1415 | assert!( |
| 1416 | labels.iter().any(|l| l.starts_with("@phpstan-assert")), |
| 1417 | "Should suggest @phpstan-assert" |
| 1418 | ); |
| 1419 | |
| 1420 | // Should NOT suggest class-only tags |
| 1421 | assert!( |
| 1422 | !labels.iter().any(|l| l.starts_with("@property")), |
| 1423 | "Should NOT suggest @property in function context" |
| 1424 | ); |
| 1425 | assert!( |
| 1426 | !labels.iter().any(|l| l.starts_with("@method")), |
| 1427 | "Should NOT suggest @method in function context" |
| 1428 | ); |
| 1429 | assert!( |
| 1430 | !labels.iter().any(|l| l.starts_with("@mixin")), |
| 1431 | "Should NOT suggest @mixin in function context" |
nothing calls this directly
no test coverage detected