Skip to content

Commit e04cf74

Browse files
committed
Extracted shared function
1 parent 19ba736 commit e04cf74

3 files changed

Lines changed: 265 additions & 425 deletions

File tree

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4040

4141
### Fixed
4242

43+
- **Static method calls resolve return types as accurately as instance calls.** `Foo::bar()` previously missed inference that `$foo->bar()` already had: return types behind a `@phpstan-type` alias, inherited return types substituted through a generic interface or trait, and the `__callStatic()` magic-method fallback. These now resolve the same way for both call styles.
4344
- **Facade static calls keep concrete method return types.** Static calls on Laravel-style facades now resolve missing methods through `getFacadeAccessor()` and facade `@mixin` targets before falling back to `__callStatic()`, so values like `Driver::details()` keep the concrete provider method return type instead of degrading to the facade's broad magic-call return. Contributed by @calebdw.
4445
- **`class-string<static>` parameters no longer reject sibling subclass constants.** Static helper calls from a shared base class that pass concrete `::class` constants for sibling subclasses no longer report false argument-type mismatches against `class-string<static>`. Contributed by @calebdw.
4546
- **Built-in PHP classes shadowed by vendor polyfills resolve to the real definition.** When an installed package ships a polyfill for a PHP built-in (for example symfony/polyfill-php84's `RoundingMode`), resolution sometimes picked the polyfill's legacy pre-enum declaration instead of the built-in, turning enum cases into plain int constants and reporting false "expects RoundingMode, got int" argument mismatches. Which declaration won could change from one run to the next, making whole-project analysis results nondeterministic. Global names of built-in classes now always resolve to the bundled PHP definition, and classes discovered inside phar archives are indexed in a stable order.

docs/todo/refactor.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -220,35 +220,27 @@ Each item must include:
220220
copies-for-another-code-path that should collapse onto one
221221
implementation (do this after — or as part of — the splits above):
222222

223-
1. **Call return-type wrappers.** `resolve_rhs_method_call_inner` /
224-
`resolve_rhs_static_call` / `resolve_rhs_function_call`
225-
(`rhs_resolution/calls.rs`) call into
226-
`Backend::resolve_method_return_types_with_args`
227-
(`call_resolution/return_types.rs`) but each re-implements the
228-
surrounding self/static substitution, union-owner expansion, and
229-
scalar fallbacks. Consolidate the pre/post logic into one shared
230-
entry point.
231-
2. **Callable-param inference.** The `*_fw`-suffixed family in
223+
1. **Callable-param inference.** The `*_fw`-suffixed family in
232224
`forward_walk/` parallels the logic in
233225
`completion/variable/closure_resolution.rs`. The suffix itself marks
234226
a copy; unify them.
235-
3. **`$this`/`self`/`static` resolution.** ~32 call sites spread across
227+
2. **`$this`/`self`/`static` resolution.** ~32 call sites spread across
236228
`util.rs` (`is_self_or_static`, `resolve_class_keyword`),
237229
`call_resolution/callable_target.rs` (`resolve_class_name_keyword`),
238230
`resolver/mod.rs` (`resolve_static_owner_class`), and `forward_walk/`
239231
(`seed_this`), plus hand-rolled `== "$this"` checks. Back them with
240232
one helper module.
241-
4. **Subclass checks.** `is_subclass_of` (`forward_walk/`),
233+
3. **Subclass checks.** `is_subclass_of` (`forward_walk/`),
242234
`is_type_subclass_of` and `is_valid_virtual_narrowing`
243235
(`call_resolution/return_types.rs`), and `util::is_subtype_of*`
244236
overlap; route through the `util`/`php_type` versions.
245-
5. **Property-assignment scanning.** The
237+
4. **Property-assignment scanning.** The
246238
`find_*_this_property_assignment*` family
247239
(`rhs_resolution/property_access.rs`) and the
248240
`walk_property_narrowing_*` family (`resolver/property_narrowing.rs`)
249241
walk class members and statements with near-identical skeletons for
250242
different outputs. Share the traversal.
251-
6. **Argument-text extraction.** `extract_argument_texts_fw` /
243+
5. **Argument-text extraction.** `extract_argument_texts_fw` /
252244
`extract_first_arg_string_fw` (`forward_walk/`) vs
253245
`extract_first_arg_text` / `resolve_inline_arg_raw_type`
254246
(`call_resolution/arg_type_resolution.rs`) vs

0 commit comments

Comments
 (0)