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

Projects
None yet
2 participants
@yuloh
Contributor

yuloh 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.

@mnapoli

This comment has been minimized.

Member

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 mnapoli added the enhancement label May 22, 2017

@mnapoli

This comment has been minimized.

Member

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

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

This comment has been minimized.

Member

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.

@yuloh

This comment has been minimized.

Contributor

yuloh commented Jun 4, 2017

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment