Build a [`ResolvedCallableTarget`] for a constructor call. Loads and merges the class, then extracts `__construct` parameters. When `args_text` is provided, class-level `@template` parameters are resolved from the call-site argument types and substituted into the constructor's parameter types. For example, given `/** @template T */ class Box { /** @param T $value */ … }`, calling `new Box(new Gi
(
class_name: &str,
class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
cache: &crate::virtual_members::ResolvedClassCache,
args_text: Option<&str>,
rctx: &R
| 664 | /// into the constructor parameters so that type-error diagnostics see |
| 665 | /// `Gift` instead of the raw `T`. |
| 666 | fn resolve_constructor_callable( |
| 667 | class_name: &str, |
| 668 | class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>, |
| 669 | cache: &crate::virtual_members::ResolvedClassCache, |
| 670 | args_text: Option<&str>, |
| 671 | rctx: &ResolutionCtx<'_>, |
| 672 | ) -> Option<ResolvedCallableTarget> { |
| 673 | let ci = class_loader(class_name)?; |
| 674 | let merged = crate::virtual_members::resolve_class_fully_cached(&ci, class_loader, cache); |
| 675 | let ctor = match merged.get_method("__construct") { |
| 676 | Some(c) => c.clone(), |
| 677 | None => { |
| 678 | return Some(ResolvedCallableTarget { |
| 679 | parameters: vec![], |
| 680 | return_type: None, |
| 681 | }); |
| 682 | } |
| 683 | }; |
| 684 | |
| 685 | // Apply class-level template substitutions from the call-site |
| 686 | // argument types when the constructor has template bindings. |
| 687 | if let Some(at) = args_text |
| 688 | && !ctor.template_bindings.is_empty() |
| 689 | { |
| 690 | let split_args = crate::completion::types::conditional::split_text_args(at); |
| 691 | let subs = Self::build_method_template_subs(&merged, "__construct", &split_args, rctx); |
| 692 | if !subs.is_empty() { |
| 693 | let mut result_ctor = ctor; |
| 694 | crate::inheritance::apply_substitution_to_method(&mut result_ctor, &subs); |
| 695 | return Some(ResolvedCallableTarget { |
| 696 | parameters: result_ctor.parameters.clone(), |
| 697 | return_type: result_ctor.return_type.clone(), |
| 698 | }); |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | Some(ResolvedCallableTarget { |
| 703 | parameters: ctor.parameters.clone(), |
| 704 | return_type: ctor.return_type.clone(), |
| 705 | }) |
| 706 | } |
| 707 | |
| 708 | // ── Main callable target resolution ───────────────────────────────── |
| 709 |
nothing calls this directly
no test coverage detected