-
Notifications
You must be signed in to change notification settings - Fork 38
Implemented option to process INI sections or not #58
Implemented option to process INI sections or not #58
Conversation
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 think it is nice feature. I like the changes that we are keeping BC and that you've provided the documentation.
We are missing test for fromString
method, we should add them as well.
I was checking the php docs and I have found there also 3rd parameter, so maybe we should add it here as well (probably as separate PR later on if we want to have it).
See my small comments in the PR. In general: nice job 👍
This PR in fact breaks ini reader. By setting flag to false, top level keys are then processed as sections and since sections are discarded by php function, reader added functionality no longer works. |
I had to dig through code and I see that sections are not treated differently to regular keys anymore, extending section functionality is gone. The only case that is affected is when sections using delimited format: [section.with.subkeys]
key=value is equivalent to Result with section names like that would be very different from result with sections not processed and merged by |
I am not able to follow. How should the corresponding array to the following INI look like? And how does this PR change the current behavior of the Ini Reader? [section.with.subkeys]
key=value |
Here is how it is handled by reader: $ php -a
Interactive shell
php > require "vendor/autoload.php";
php > $ini = <<<ECS
<<< > [environments.production]
<<< > env='production'
<<< > production_key='foo'
<<< >
<<< > [environments.staging]
<<< > env='staging'
<<< > staging_key='bar'
<<< > ECS;
php > $reader = new Zend\Config\Reader\Ini();
php > print_r($reader->fromString($ini));
Array
(
[environments] => Array
(
[production] => Array
(
[env] => production
[production_key] => foo
)
[staging] => Array
(
[env] => staging
[staging_key] => bar
)
)
) |
I rebased to current develop and added tests for the nesting in section names. Sorry, I dropped your latest commit in doing so. |
@arueckauer thank you |
My pleasure! Thank you for a thorough check and the feedback. |
By default the INI reader is processing sections. It is not possible to merge sections, which is the default behavior of
parse_ini_file()
.This PR introduces the protected property
$processSections
with a public getter and setter. It enables users to tell the reader not to process sections by setting$processSections
tofalse
. The default behavior of the reader does not change.docs/book/reader.md
in the INI sectiondevelop
branch, and submit against that branch. CheckCHANGELOG.md
entry for the new feature.