Project

General

Profile

Actions

Task #97559

open

Attributes: Use constructor parameter per property instead of an array

Added by Markus Pircher over 2 years ago. Updated over 1 year ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Extbase
Start date:
2022-05-05
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.0
Tags:
Complexity:
Sprint Focus:

Description

I saw that with v12 attribute support.
Unfortunately, i find it counterproductive that arrays are used for the parameters here. This breaks type safety, breaks code completion, and can easily lead to overlooked typos.
constructor parameters for each parameter would also make it easier to show the programmers which parameters are required.
PHP 8 offers named parameters, so the argument that you don't have to fill in all parameters with the array, wouldn't count.


Files

Actions #1

Updated by Markus Pircher over 2 years ago

doctrine/annotation has named nonstructor option, so the backward compatibility would be given, and the syntax for both annotation and attribute would be almost identical
https://www.doctrine-project.org/projects/doctrine-annotations/en/1.13/custom.html#optional-constructors-with-named-parameters

Both Neos Flow and doctrine ORM use that.

Actions #2

Updated by Benni Mack about 2 years ago

  • Target version changed from 12.0 to 12.1
Actions #3

Updated by Benni Mack almost 2 years ago

  • Target version changed from 12.1 to 12.2
Actions #4

Updated by Benni Mack almost 2 years ago

  • Target version changed from 12.2 to 12.3
Actions #5

Updated by Benni Mack over 1 year ago

  • Target version changed from 12.3 to 12 LTS
Actions #6

Updated by Benni Mack over 1 year ago

  • Target version changed from 12 LTS to Candidate for patchlevel
Actions

Also available in: Atom PDF