Uh oh!
There was an error while loading. Please reload this page.
Service definition - #78
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@## master #78 +/- ##
===========================================
Coverage 100.00% 100.00% - Complexity 242 260 +18
===========================================
Files 16 17 +1 Lines 664 712 +48 ===========================================
+ Hits 664 712 +48
☔ View full report in Codecov by Sentry. |
PR Summary
|
vjik
commented
Jul 29, 2023
It is more correct to compare variants: // New
ServiceDefinition::for(Phone::class)
->constructor(['name' => 'Retro', 'version' => '1.0'])
->setProperty('$dev', true)
->setProperty('$codeName', 'b')
->callMethod('setId()', [42])
->callMethod('setColors()', ['yellow']);
// Current
[
'class' => Phone::class,
'__construct()' => ['version' => '2.0'],
'$dev' => true,
'$codeName' => 'b',
'setId()' => [42],
'setColors()' => ['yellow'],
]For me new variant gives one benefit only:
Everything else is redundant and only complicates code:
My opinion is keep current syntax and do not add |
samdark
commented
Aug 18, 2023
@xepozz please check tests. |
samdark
commented
Aug 26, 2023
// New
ServiceDefinition::for(Phone::class)
->constructor(['name' => 'Retro', 'version' => '1.0'])
->set('dev', true)
->set('codeName', 'b')
->call('setId', [42])
->call('setColors', ['yellow']);
// Current
[
'class' => Phone::class,
'__construct()' => ['version' => '2.0'],
'$dev' => true,
'$codeName' => 'b',
'setId()' => [42],
'setColors()' => ['yellow'],
] |
samdark
commented
Aug 26, 2023
While the syntax is alright, it adds another way to do the same thing which I'm not sure it a good thing. |
Tigrov
commented
Aug 26, 2023
The syntax is great. But as already noted:
But why not, if somebody likes to write the config in this way. Does it work faster? |
xepozz
commented
Oct 4, 2023
It's incorrect comparison. Correct so: // New
ServiceDefinition::for(Phone::class)
->constructor(['version' => '1.0'])
->set('dev', true)
->set('codeName', 'b')
->call('setId', [42])
->call('setColors', ['yellow']);
// Current
[
'class' => Phone::class,
'__construct()' => ['version' => '2.0'],
'$dev' => true,
'$codeName' => 'b',
'setId()' => [42],
'setColors()' => ['yellow'],
]Also appear problem with configuration merge. With objects it is more difficult in implementation. |




I'd like to present a new way to configure services:
It's the same as the configuration with
ArrayDefinition: