Skip to content

[Feature]: Parse accessor attribute type from return value of closure #85

@joelstein

Description

@joelstein

What happened?

Suppose I have the following code:

protected function label(): Attribute
{
    return Attribute::make(
        get: fn (): string => 'Some label',
    );
}

The get function type hints that the return value is "string" but it will produce label?: any.

The docs for this package suggest doing something like this:

/**
 * @return string
 */
protected function label(): Attribute
{
    return Attribute::make(
        get: fn (): string => 'Some label',
    );
}

But that confused my IDE because the PHPDoc doesn't match the function return type.

Is it possible to parse the return type from the Attribute's get closure?

How to reproduce the bug

See above.

Package Version

3.1.03

PHP Version

8.3

Which operating systems does with happen with?

macOS

Notes

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions