fix: ide auto complete for callable syntax#37
Conversation
Greptile SummaryThis PR simplifies PHPDoc type annotations in Confidence Score: 4/5Safe to merge — PHPDoc-only changes with no runtime impact; one minor P2 note about unnecessary loss of generic type binding on return annotations. All changes are PHPDoc annotations with zero runtime effect. The callable-syntax simplification is the stated goal and is well-targeted. The only concern is that src/DataTransferObject.php — specifically the
|
| Filename | Overview |
|---|---|
| src/DataTransferObject.php | PHPDoc-only change: removes <static> generic parameter from PropertyReference/IsDefinedReference return types and simplifies callable parameter types to callable(static $ref): array; no runtime impact but slightly reduces type precision on ref() and refIsDefined() return annotations. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Caller passes\narray or callable to make() / withOnly() / etc."] --> B["resolveIfCallable(\$parameters)"]
B -->|is_callable| C["Invoke callable with\nstatic::ref()"]
C --> D["PropertyReference instance\n(@mixin T where T=DTO)"]
D --> E["Callable body:\n\$ref->propertyName\n(IDE sees 'static' for completion)"]
E --> F["Returns array of\nproperty names / overrides"]
B -->|is array| F
F --> G["DTO construction /\nmutation logic"]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/DataTransferObject.php
Line: 97
Comment:
**Generic binding loss on `ref()` / `refIsDefined()` return types**
The old `PropertyReference<static>|static` bound the `@template T of DataTransferObject` on `PropertyReference` to the concrete calling class, meaning PHPStan/Psalm and PhpStorm would see the `@mixin T` as the specific DTO subclass. Without `<static>`, the `PropertyReference` part of the union is now unparameterised — IDEs that resolve the union to `PropertyReference` (rather than falling back to `static`) lose that binding. The `|static` fallback preserves completion in most cases, but the callable-syntax fix doesn't require removing `<static>` from these `@return` tags. Consider keeping them as `@return PropertyReference<static>|static` (and same for `IsDefinedReference`) to retain the strongest possible static-analysis signal, and limit the simplification to just the callable parameter annotations where the IDE issue was actually observed.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: ide auto complete for callable synt..." | Re-trigger Greptile
Description
Describe your changes in detail.
Motivation and context
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here (if you write
fixes #numor
closes #num, the issue will be automatically closed when the pull is accepted.)How has this been tested?
Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc.
Screenshots (if appropriate)
Types of changes
What types of changes does your code introduce? Put an
xin all the boxes that apply:Checklist:
Go over all the following points, and put an
xin all the boxes that apply.Please, please, please, don't send your pull request until all of the boxes are ticked. Once your pull request is created, it will trigger a build on our continuous integration server to make sure your tests and code style pass.
If you're unsure about any of these, don't hesitate to ask. We're here to help!