Skip to content
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

[WIP] Recursively resolve array definitions #490

Merged
merged 1 commit into from Jun 4, 2017

Conversation

@matt-allan
Copy link
Contributor

@matt-allan matt-allan commented May 22, 2017

Hello,

I was using PHP-DI and noticed that array definitions are only resolved at the first level of the array. For example:

return [
    's3.config' => [
        'version'                  => 'latest',
        'region'                   => DI\env('S3_REGION'), // this resolves
        'bucket'                   => 'stuff',
        'credentials'              => [
            'key'    => DI\env('S3_KEY'),
            'secret' => DI\env('S3_SECRET'),  // these don't
        ],
    ],
    // ...
];

To make this work I changed the ArrayResolver to recurse and added a test.

It looks like ArrayDefinition::__toString would need to change too if this added. I'm not too sure of what the format should be.

@matt-allan matt-allan force-pushed the matt-allan:nested-array-definitions branch from 84f1d3a to 5181758 May 22, 2017
@mnapoli
Copy link
Member

@mnapoli mnapoli commented May 22, 2017

Thanks, the reason it wasn't done before is because of the possible performance impact. I think I will need to measure this (I have benchmarks in the repository).

@mnapoli mnapoli added this to the 6.0 milestone May 22, 2017
@mnapoli
Copy link
Member

@mnapoli mnapoli commented May 28, 2017

A quick update: I think the subject of performances may be gone if I succeed with #494. So I will be keeping this pull request around until I can adapt that to the new architecture. I'll let you know, it might take me some time to complete #494

@mnapoli mnapoli merged commit 5181758 into PHP-DI:master Jun 4, 2017
4 checks passed
4 checks passed
Scrutinizer No new issues
Details
continuous-integration/styleci/pr The StyleCI analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.4%) to 81.395%
Details
@mnapoli
Copy link
Member

@mnapoli mnapoli commented Jun 4, 2017

Thanks! I've merged manually and apply the same behavior to the compiled container.

I've also opened #498 to apply that kind of logic everywhere.

@matt-allan
Copy link
Contributor Author

@matt-allan matt-allan commented Jun 4, 2017

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants