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

Refactor how annotations with non-constant arguments are emitted #169

Merged
merged 2 commits into from
Jun 4, 2023

Conversation

thekid
Copy link
Member

@thekid thekid commented Jun 4, 2023

This pull request changes the way annotations with non-constant arguments are emitted.

Single argument

// Declaration in user code
#[Verify(fn() => extension_loaded('pcntl')]

// Previous behavior
#[Verify(eval: 'fn() => extension_loaded(\'pcntl\')')]

// Code that is emitted now
#[Verify(eval: ['fn() => extension_loaded(\'pcntl\')'])]

Multiple (and named) arguments

// Declaration in user code
#[Verify(fn() => extension_loaded('pcntl'), optional: true)]

// Previous behavior created an ambiguity with supplying a single value with the respective array
#[Verify(eval: '[\'0\' => fn() => extension_loaded(\'pcntl\'), \'optional\' => true]')]

// Code that is emitted now
#[Verify(eval: ['fn() => extension_loaded(\'pcntl\'))', 'optional' => 'true'])]

The array notation is supported by the following changes:

See also xp-framework/rfc#338

composer.json Show resolved Hide resolved
return Reflection::type($this->type(
$declaration.(strstr($declaration, '<T>') ? '' : ' class <T> { }')
));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This should be moved to the parent class, it will aid the transition to using xp-framework/reflection!

@thekid thekid merged commit 1c45061 into master Jun 4, 2023
@thekid thekid deleted the refactor/annotation-emit branch June 4, 2023 08:54
@thekid
Copy link
Member Author

thekid commented Jun 4, 2023

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

Successfully merging this pull request may close these issues.

1 participant