Task #97559
openAttributes: Use constructor parameter per property instead of an array
0%
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
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.
Updated by Benni Mack about 2 years ago
- Target version changed from 12.0 to 12.1
Updated by Benni Mack almost 2 years ago
- Target version changed from 12.1 to 12.2
Updated by Benni Mack almost 2 years ago
- Target version changed from 12.2 to 12.3
Updated by Benni Mack over 1 year ago
- Target version changed from 12.3 to 12 LTS
Updated by Benni Mack over 1 year ago
- Target version changed from 12 LTS to Candidate for patchlevel