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

Function is_obvious_single_param

src/inlay_hints.rs:538–637  ·  view source on GitHub ↗

Check whether a single-parameter call has an obvious relationship between the function/method name and the parameter, making the hint redundant noise. For example, `strlen($text)` — the function name already implies the parameter is a string.

(call_expression: &str, _param_name: &str)

Source from the content-addressed store, hash-verified

536/// For example, `strlen($text)` — the function name already implies
537/// the parameter is a string.
538fn is_obvious_single_param(call_expression: &str, _param_name: &str) -> bool {
539 // Extract the function/method name from the call expression.
540 let func_name = if let Some(pos) = call_expression.rfind("->") {
541 &call_expression[pos + 2..]
542 } else if let Some(pos) = call_expression.rfind("::") {
543 &call_expression[pos + 2..]
544 } else if let Some(name) = call_expression.strip_prefix("new ") {
545 // Constructor calls: `new Foo($bar)` — always show.
546 let _ = name;
547 return false;
548 } else {
549 call_expression
550 };
551
552 // Common single-param functions where the hint is noise.
553 matches!(
554 func_name.to_ascii_lowercase().as_str(),
555 "count"
556 | "strlen"
557 | "isset"
558 | "empty"
559 | "unset"
560 | "print"
561 | "echo"
562 | "var_dump"
563 | "print_r"
564 | "var_export"
565 | "intval"
566 | "floatval"
567 | "strval"
568 | "boolval"
569 | "trim"
570 | "ltrim"
571 | "rtrim"
572 | "strtolower"
573 | "strtoupper"
574 | "ucfirst"
575 | "lcfirst"
576 | "abs"
577 | "ceil"
578 | "floor"
579 | "round"
580 | "is_null"
581 | "is_array"
582 | "is_string"
583 | "is_int"
584 | "is_integer"
585 | "is_float"
586 | "is_double"
587 | "is_bool"
588 | "is_numeric"
589 | "is_object"
590 | "is_callable"
591 | "json_encode"
592 | "json_decode"
593 | "serialize"
594 | "unserialize"
595 | "base64_encode"

Callers 1

emit_parameter_hintsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected