-
Notifications
You must be signed in to change notification settings - Fork 13
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
Feature/no special treatment for injected arrays #67
Feature/no special treatment for injected arrays #67
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #67 +/- ##
===========================================
- Coverage 99.62% 99.62% -0.01%
===========================================
Files 12 12
Lines 537 535 -2
===========================================
- Hits 535 533 -2
Misses 2 2
Continue to review full report at Codecov.
|
$oo = $this->mergeSeeds(['4'=>'four'], ['5'=>'five']); | ||
$this->assertEquals($oo, ['4'=>'four', '5'=>'five']); | ||
|
||
$oo = $this->mergeSeeds(['4'=>['four']], ['5'=>['five']]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is duplicated above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, the value is array, above value is string.
$oo = $this->mergeSeeds(['x'=>['four']], ['x'=>['five']]); | ||
$this->assertEquals($oo, ['x'=>['four']]); | ||
|
||
$oo = $this->mergeSeeds(['4'=>['four']], ['4'=>['five']]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why these don't fail, because we still have that is_numeric
/ is_int
issue: #65 not fixed, so when merging these keys '4'
it should merge these values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe me neitherr. in fact i added 'invalid' to that ticket, so when you have time create a proper case for it.
When DIContainerTrait was originally implemented, it had a special treatment for arrays, e.g:
Instead of replacing value of the $class property, the contents would be merged. Unfortunately this has a major impact on the way how "seeds" work, for example here:
If MyWidget already defines title property it won't be replaced with new seed instead it will be merged causing 'MyTitle' to be sent as constructor argument.
There are many cases where array merging is bad and only a single case where it's beneficial, so I'm making array injection consistent with other values and will provide a special treatment for the $class property merging inside views.
I have supplied a test-script which can be used to refactor View's
setDefaults
method in a test-script within this PR