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>>,
)
| 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. |
nothing calls this directly
no test coverage detected