Skip to content

Add support for attribute array shape #1681

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

Open
Khartir opened this issue Feb 19, 2025 · 1 comment
Open

Add support for attribute array shape #1681

Khartir opened this issue Feb 19, 2025 · 1 comment

Comments

@Khartir
Copy link

Khartir commented Feb 19, 2025

Summary

If an attribute has an array type that has a defined shape, the generation of the docblock breaks. It would be nice, if this was supported.

Example:

    /**
     * @param array{longitude: float|null, latitude: float|null} $coordinates
     */
    public function setCenterAttribute(array $coordinates): void
    {}

    /**
     * @return array{longitude: float|null, latitude: float|null}
     */
    public function getCenterAttribute(): array
    {}

generates the following docblock:

/**
 * @property \App\Models\array{longitude: $center
 * @mixin \Eloquent
 */
@smares
Copy link

smares commented Mar 3, 2025

+1

First I thought the problem was that I defined a custom type using @phpstan-type and used that as return type, but it breaks with @return array{...} as well.

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

No branches or pull requests

2 participants