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

Use @param tags from constructor with property promotion #628

Conversation

oojacoboo
Copy link
Collaborator

@oojacoboo oojacoboo commented Oct 15, 2023

When using property promotion, particularly with input types, you're required to define the generic type details for lists (array, collection, etc) using a variable docblock. Not only is this ugly, it requires duplicate docblock definitions for internal docblock usage and is entirely unnecessary.

This PR adds support for constructor docblock generic type definitions with property promotion.

Example:

/**
 * Constructor
 * 
 * @param array<string> $array
 */
#[Input]
public function __construct(
    #[Field]
    public array $array
) {}

As opposed to:

#[Input]
public function __construct(
    /** @var array<string> */
    #[Field]
    public array $array
) {}

The additional support is fully BC.

@oojacoboo
Copy link
Collaborator Author

Should be ready. A review would be nice.

tests/FieldsBuilderTest.php Show resolved Hide resolved
src/Mappers/Parameters/TypeHandler.php Outdated Show resolved Hide resolved
@oojacoboo oojacoboo merged commit 3c4045a into thecodingmachine:master Oct 16, 2023
6 checks passed
@oojacoboo oojacoboo deleted the constructor-docblock-property-promotion branch October 16, 2023 17:18
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.

2 participants