Issue Task Closed

#97559Attributes: Use constructor parameter per property instead of an array

Markus Pircher 05/05/22, 10:55 updated 12/02/25, 14:33

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.

Reviews 2

Files 1

History 920

  1. Markus Pircher commented and changed attached Bildschirmfoto 2022-05-06 um 08.36.20.png <span data-processor="relativetime" data-value="2022-05-06T06:38:14+00:00" > 05/06/22, 06:38 </span>

    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.

  2. Anonymous commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2025-11-20T13:15:09+00:00" > 11/20/25, 13:15 </span>

    Applied in changeset commit:d06cc54897151923107b6dbd35fc1506d1225450.