Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to define a more complex accessor return type? #1630

Open
joelstein opened this issue Dec 17, 2024 · 1 comment
Open

How to define a more complex accessor return type? #1630

joelstein opened this issue Dec 17, 2024 · 1 comment
Labels

Comments

@joelstein
Copy link

Versions:

  • ide-helper Version: 3.2.2
  • Laravel Version: 11.35.1
  • PHP Version: 8.3.14

Question:

Suppose I have a model with an accessor attribute that returns an array of ints:

protected function minutes(): Attribute
{
return Attribute::make(
get: fn (): array => [0, 15, 30, 45],
);
}
This will produce @property-read array $minutes.

How can I help this package produce something like @property-read array<int> $minutes?

@barryvdh
Copy link
Owner

I think you can add it to the phpdocs of the function itself, not sure if phpstan detects this correctly otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants