matomo-org / component-ini

Read and write INI configurations.
GNU Lesser General Public License v3.0
50 stars 25 forks source link

Also propagate the comments #5

Open tetrode opened 7 years ago

tetrode commented 7 years ago

Adding the possibility to also propagate the comments when writing the ini file. Works as follows:

$ini = 'piwik.ini'; $reader = new \Piwik\Ini\IniReader(); $config = $reader->readFile($ini); $comments = $reader->readComments($ini); $writer = new \Piwik\Ini\IniWriter(); $writer->writeToFile('piwik-new.ini', $config, '', $comments);

Things that do not work:

1 pre-section comments disappear: ; section comment [MySection] ; option comment myOption = 1

becomes [MySection] ; option comment myOption = 1

2 Individual array comments disappear: [MySection] ; comment a ar[] = "a" ; comment b ar[] = "b" ; comment c ar[] = "c"

becomes [MySection] ; comment a ar[] = "a" ar[] = "b" ar[] = "c"

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-11.7%) to 70.673% when pulling a37cd9f9db04cd814e30f36f5d683ff03a7849ec on tetrode:patch-1 into bd2711ba4d5e20e4ca09b6829dc2831576b59dc3 on piwik:master.

mattab commented 7 years ago

Thanks for the PR @tetrode

Could you please add some unit/integration tests, to make sure your feature will not break in the future?