Skip to content

Add support for attribute accessors without return type declared in closures#1439

Open
EmanueleCoppola wants to merge 4 commits into
barryvdh:masterfrom
EmanueleCoppola:patch-1
Open

Add support for attribute accessors without return type declared in closures#1439
EmanueleCoppola wants to merge 4 commits into
barryvdh:masterfrom
EmanueleCoppola:patch-1

Conversation

@EmanueleCoppola

@EmanueleCoppola EmanueleCoppola commented May 18, 2023

Copy link
Copy Markdown

Summary

Enable the recognition of attributes without any return type in the declared closures.

The following example was not recognized before:

protected function attributeWithoutReturnTypes(): Attribute
{
    return new Attribute(
        function (?string $name) {
            return $name;
        },
        function (?string $name) {
            return $name === null ? null : ucfirst($name);
        }
    );
}

Now the aforementioned method should produce the following declaration:

 * @property mixed $attribute_without_return_types

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • Existing tests have been adapted and/or new tests have been added
  • Add a CHANGELOG.md entry
  • Update the README.md
  • Code style has been fixed via composer fix-style

@EmanueleCoppola EmanueleCoppola changed the title Enable the recognition of attributes without any return type in the declared closures Add support for attribute accessors without return type declared in closures May 18, 2023
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Attributes\Models\Simple
*
* @property integer $id
* @property mixed $attribute_without_return_types

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was returned before?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before it didn't even show the attribute

@barryvdh

barryvdh commented Feb 8, 2024

Copy link
Copy Markdown
Owner

Is this fixed with #1411 ?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants