Project

General

Profile

Actions

Feature #96688

closed

Use PHP 8 Attributes for Extbase Annotations

Added by Susanne Moog about 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
Start date:
2022-01-30
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Since PHP 8, native attributes are supported. In comparison to doc comments, attributes have auto-completion, are better readable and were "invented" for storing meta-information about properties. For more info on attributes see https://stitcher.io/blog/attributes-in-php-8 and https://www.php.net/manual/en/language.attributes.overview.php

Extbase annotations are already nearly 1:1 translatable to attributes.

The following annotations have been enriched for usage as attributes:

@Extbase\ORM\Transient
@Extbase\ORM\Cascade
@Extbase\ORM\Lazy
@Extbase\IgnoreValidation
@Extbase\Validate

Examples:

Before:

    /**
     * @Extbase\ORM\Cascade("remove")
     */

After:

    #[Extbase\ORM\Cascade(['value' => 'remove'])]

With promoted properties in constructor:

    public function __construct(
        #[Extbase\Validate(['validator' => 'StringLength', 'options' => ['minimum' => 1, 'maximum' => 10]])]
        #[Extbase\Validate(['validator' => 'NotEmpty'])]
        #[Extbase\Validate(['validator' => 'TYPO3.CMS.Extbase:NotEmpty'])]
        #[Extbase\Validate(['validator' => 'TYPO3.CMS.Extbase.Tests.Unit.Reflection.Fixture:DummyValidator'])]
        #[Extbase\Validate(['validator' => '\TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator'])]
        #[Extbase\Validate(['validator' => NotEmptyValidator::class])]
        public readonly string $dummyPromotedProperty
    )
    {

    }

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #96794: Wrong 'default' in match expressionClosed2022-02-08

Actions
Actions #1

Updated by Gerrit Code Review about 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73217

Actions #2

Updated by Gerrit Code Review about 2 years ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/73217

Actions #3

Updated by Susanne Moog about 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #4

Updated by Christian Kuhn about 2 years ago

  • Related to Task #96794: Wrong 'default' in match expression added
Actions #5

Updated by Benni Mack over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF