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

Method find_builder_forwarded_method

src/definition/member/mod.rs:799–820  ·  view source on GitHub ↗

Check if a method is available on the Eloquent Builder for a Model subclass. Laravel's `Model::__callStatic()` forwards static calls to `Builder`, but the real `Model` class has no `@mixin Builder` annotation. This function bridges that gap for go-to-definition by loading the Builder and searching its inheritance chain (including `@mixin Query\Builder` and traits like `BuildsQueries`) for the re

(
        class: &ClassInfo,
        member_name: &str,
        class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
    )

Source from the content-addressed store, hash-verified

797 /// method is found, or `None` if the class is not an Eloquent Model
798 /// subclass or the method does not exist on Builder.
799 fn find_builder_forwarded_method(
800 class: &ClassInfo,
801 member_name: &str,
802 class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
803 ) -> Option<(ClassInfo, String)> {
804 if !extends_eloquent_model(class, class_loader) {
805 return None;
806 }
807 let builder = class_loader(ELOQUENT_BUILDER_FQN)?;
808 let (declaring_class, fqn) =
809 Self::find_declaring_class(&builder, member_name, class_loader)?;
810 // When the declaring class is the Eloquent Builder itself,
811 // find_declaring_class returns the short name ("Builder").
812 // Replace it with the fully-qualified name so that
813 // find_class_file_content can disambiguate classes that share
814 // the same short name (e.g. Eloquent\Builder vs Demo\Builder).
815 if !fqn.contains('\\') && fqn == builder.name {
816 Some((declaring_class, ELOQUENT_BUILDER_FQN.to_string()))
817 } else {
818 Some((declaring_class, fqn))
819 }
820 }
821
822 /// Find a scope method's declaration on the model when the target
823 /// class is an Eloquent Builder instance.

Callers

nothing calls this directly

Calls 3

extends_eloquent_modelFunction · 0.85
find_declaring_classFunction · 0.85
containsMethod · 0.80

Tested by

no test coverage detected