Skip to content

fix: ide auto complete for callable syntax#37

Merged
MarkHolmesRex merged 1 commit into
mainfrom
fix/ide-autocomplete-for-callables
May 11, 2026
Merged

fix: ide auto complete for callable syntax#37
MarkHolmesRex merged 1 commit into
mainfrom
fix/ide-autocomplete-for-callables

Conversation

@MarkHolmesRex

Copy link
Copy Markdown
Contributor

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 #num
or 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 x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in 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.

  • I have read the CONTRIBUTING document.
  • My pull request addresses exactly one patch/feature.
  • I have created a branch for this patch/feature.
  • Each individual commit in the pull request is meaningful.
  • I have added tests to cover my changes.
  • If my change requires a change to the documentation, I have updated it accordingly.

If you're unsure about any of these, don't hesitate to ask. We're here to help!

@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown

Greptile Summary

This PR simplifies PHPDoc type annotations in DataTransferObject.php to improve IDE auto-complete for callable syntax, replacing callable(PropertyReference<static>|static $ref): array with callable(static $ref): array across several methods and removing the <static> generic parameter from @return tags for ref() and refIsDefined(). All changes are documentation-only with no runtime behaviour impact.

Confidence Score: 4/5

Safe 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 <static> was also removed from @return tags for ref() and refIsDefined(), which is not strictly required by the fix and slightly reduces type precision for static-analysis tools — a P2 finding only.

src/DataTransferObject.php — specifically the @return tags for ref() (line 97) and refIsDefined() (line 108).

Important Files Changed

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"]
Loading
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

@MarkHolmesRex
MarkHolmesRex merged commit 4bdd4db into main May 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants