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

Method applies_to

src/virtual_members/phpdoc.rs:141–197  ·  view source on GitHub ↗

Returns `true` if the class has a non-empty class-level docblock or declares `@mixin` tags (directly or via ancestors). This is a cheap pre-check. No parsing is performed.

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

Source from the content-addressed store, hash-verified

139 ///
140 /// This is a cheap pre-check. No parsing is performed.
141 fn applies_to(
142 &self,
143 class: &ClassInfo,
144 class_loader: &dyn Fn(&str) -> Option<Arc<ClassInfo>>,
145 ) -> bool {
146 // Has a non-empty docblock with potential @method/@property tags.
147 if class.class_docblock.as_ref().is_some_and(|d| !d.is_empty()) {
148 return true;
149 }
150
151 // Has used traits that might have @method/@property tags.
152 for trait_name in &class.used_traits {
153 if let Some(trait_info) = class_loader(trait_name)
154 && trait_info
155 .class_docblock
156 .as_ref()
157 .is_some_and(|d| !d.is_empty())
158 {
159 return true;
160 }
161 }
162
163 // Has direct @mixin declarations.
164 if !class.mixins.is_empty() {
165 return true;
166 }
167
168 // Walk the parent chain to check for ancestor mixins or docblocks
169 // with @method/@property tags. Use a cheap Arc handle instead of
170 // cloning the entire ClassInfo at each level.
171 let mut current_parent = class.parent_class;
172 let mut depth = 0u32;
173 while let Some(ref parent_name) = current_parent {
174 depth += 1;
175 if depth > MAX_INHERITANCE_DEPTH {
176 break;
177 }
178 let parent = if let Some(p) = class_loader(parent_name) {
179 p
180 } else {
181 break;
182 };
183 if !parent.mixins.is_empty() {
184 return true;
185 }
186 if parent
187 .class_docblock
188 .as_ref()
189 .is_some_and(|d| !d.is_empty())
190 {
191 return true;
192 }
193 current_parent = parent.parent_class;
194 }
195
196 false
197 }
198

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected