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

Add support for multiple arguments using arrays in eval #35

Merged
merged 2 commits into from
Jun 3, 2023

Conversation

thekid
Copy link
Member

@thekid thekid commented Jun 1, 2023

Change

Currently, we can only supply one annotation argument via eval:

#[Callback(eval: 'fn() => ...')]
class T { }

Reflection::type(T::class)->annotation(Callback::class)->argument(0); // Closure

This pull request add support for multiple arguments by passing an array:

#[Callbacks(eval: ['fn() => 1', 'fn() => 2'])]
class T { }

Reflection::type(T::class)->annotation(Callbacks::class)->arguments(); // [Closure#1, Closure#2]

It also supports named arguments:

#[Callback(eval: ['function' => 'fn() => ...'])]
class T { }

Reflection::type(T::class)->annotation(Callback::class)->argument('function'); // Closure

Together with xp-framework/core#324, this is a prerequisite for extracting reflection code as proposed by xp-framework/rfc#338.

@thekid thekid added the enhancement New feature or request label Jun 2, 2023
@thekid thekid changed the title Change eval to require an argument list Add support for multiple arguments using arrays in eval Jun 2, 2023
@thekid thekid merged commit bdd30bc into main Jun 3, 2023
@thekid thekid deleted the refactor/eval branch June 3, 2023 19:14
@thekid
Copy link
Member Author

thekid commented Jun 3, 2023

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

Successfully merging this pull request may close these issues.

1 participant