generated from yiisoft/package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
Description
I propose to add an alternative syntax for a simplified notation of the constructor and its arguments.
For example:
use \Yiisoft\Definitions\ArrayDefinition;
$definition = ArrayDefinition::fromConfig([
'class' => MyServiceInterface::class,
'__construct()' => [42],
'$propertyName' => 'value',
'setName()' => ['Alex'],
]);So it can be written like this:
use \Yiisoft\Definitions\ArrayDefinition;
$definition = ArrayDefinition::fromConfig([
MyServiceInterface::class,
[42],
'propertyName' => 'value',
'setName()' => ['Alex'],
]);Here the unnamed first (0) parameter (string) is the name of the class.
The second unnamed (1) parameter (array, if present) is the constructor arguments.
Raise an error if unnamed parameters are present along with "__construct()" or "class".
Also, the '$' notation here may be redundant and looks like a developer error visually (lack of double quotes).
This improvement will simplify development and reduce the amount of code.
Reactions are currently unavailable