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

feat: add an ApiResource PHP 8 attribute #3851

Merged
merged 3 commits into from
Nov 27, 2020

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Nov 26, 2020

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tickets n/a
License MIT
Doc PR todo

PHP 8 has been released today, let's celebrate!

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;

#[ApiResource(description: "Hey PHP 8", iri: "https://php.net")]
class DummyPhp8
{
    #[ApiProperty(description: "We support attributes!")]
    public string $hello = 'hi';
}

@dunglas dunglas force-pushed the feat/php8-attributes branch 3 times, most recently from 5b37fc6 to 6a7d09d Compare November 26, 2020 23:43

foreach ($defaults as $option => $value) {
if (\in_array($option, $rootLevelOptions, true)) {
if (isset($publicProperties[$option])) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (isset($publicProperties[$option])) {
if ($publicProperties[$option] ?? false) {

Copy link
Member Author

Choose a reason for hiding this comment

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

it's longer :p

@@ -598,7 +598,7 @@ private function addDefaultsSection(ArrayNodeDefinition $rootNode): void
return $normalizedDefaults;
});

foreach (ApiResource::CONFIGURABLE_DEFAULTS as $attribute) {
foreach (ApiResource::getConfigMetadata()[1] as $attribute => $_) {
Copy link
Member

Choose a reason for hiding this comment

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

[1] isn't so clear, I wish we could [, $configurableAttributes]; $configurableAttributes as ... :/

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have something better for now.

@dunglas dunglas merged commit f99cc0a into api-platform:master Nov 27, 2020
@dunglas dunglas deleted the feat/php8-attributes branch November 27, 2020 11:59
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.

None yet

2 participants