Closed arueckauer closed 5 years ago
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 $config['section']['with']['subkeys']['key'] = 'value';
Result with section names like that would be very different from result with sections not processed and merged by parse_ini_*()
function.
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.