-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service definition #78
base: master
Are you sure you want to change the base?
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
|
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 |
@xepozz please check tests. |
// 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'],
] |
While the syntax is alright, it adds another way to do the same thing which I'm not sure it a good thing. |
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? |
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
: