Add Config Reader for Java-style .properties files and strings #4824

Merged
merged 14 commits into from Jul 22, 2013

Conversation

Projects
None yet
7 participants
@mvargeson
Contributor

mvargeson commented Jul 13, 2013

This pull request adds a Config Reader for Java-style .properties files and strings with corresponding tests.

@coveralls

This comment has been minimized.

Show comment Hide comment
@coveralls

coveralls Jul 13, 2013

Coverage Status

Coverage remained the same when pulling 79b8276 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

Coverage Status

Coverage remained the same when pulling 79b8276 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

@samsonasik

View changes

library/Zend/Config/Reader/JavaProperties.php
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Config

This comment has been minimized.

Show comment Hide comment
@samsonasik

samsonasik Jul 13, 2013

Contributor

remove @Package

@samsonasik

View changes

tests/ZendTest/Config/Reader/JavaPropertiesTest.php
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Config

This comment has been minimized.

Show comment Hide comment
@samsonasik

samsonasik Jul 13, 2013

Contributor

remove @Package

@samsonasik

View changes

tests/ZendTest/Config/Reader/JavaPropertiesTest.php
+/**
+ * @category Zend
+ * @package Zend_Config
+ * @subpackage UnitTests

This comment has been minimized.

Show comment Hide comment
@samsonasik

samsonasik Jul 13, 2013

Contributor

remove @category @Package @subpackage

@samsonasik

samsonasik Jul 13, 2013

Contributor

remove @category @Package @subpackage

This comment has been minimized.

Show comment Hide comment
@mvargeson

mvargeson Jul 14, 2013

Contributor

Is the removal of these docblock tags required on all other unit tests (as this was based off another unit test)?

@mvargeson

mvargeson Jul 14, 2013

Contributor

Is the removal of these docblock tags required on all other unit tests (as this was based off another unit test)?

This comment has been minimized.

Show comment Hide comment
@samsonasik

samsonasik Jul 14, 2013

Contributor

Yes ;)

@samsonasik

samsonasik Jul 14, 2013

Contributor

Yes ;)

@coveralls

This comment has been minimized.

Show comment Hide comment
@coveralls

coveralls Jul 13, 2013

Coverage Status

Coverage remained the same when pulling d6deadf on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

Coverage Status

Coverage remained the same when pulling d6deadf on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

@coveralls

This comment has been minimized.

Show comment Hide comment
@coveralls

coveralls Jul 13, 2013

Coverage Status

Coverage remained the same when pulling d6deadf on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

Coverage Status

Coverage remained the same when pulling d6deadf on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

@coveralls

This comment has been minimized.

Show comment Hide comment
@coveralls

coveralls Jul 14, 2013

Coverage Status

Coverage remained the same when pulling 0d98f17 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

Coverage Status

Coverage remained the same when pulling 0d98f17 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

@DASPRiD

View changes

tests/ZendTest/Config/Reader/JavaPropertiesTest.php
+
+namespace ZendTest\Config\Reader;
+
+use Zend\Config\Reader\JavaProperties as JavaProperties;

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Jul 14, 2013

Member

Alias not required.

@DASPRiD

DASPRiD Jul 14, 2013

Member

Alias not required.

@DASPRiD

View changes

tests/ZendTest/Config/Reader/JavaPropertiesTest.php
+
+ $this->assertNotEmpty($arrayJavaProperties);
+ $this->assertEquals($arrayJavaProperties['single.line'], 'test');
+ $this->assertEquals($arrayJavaProperties['path'], '\test\with\slashes');

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Jul 14, 2013

Member

Those are actually backslashes, not slashes. So the test string is a bit confusing.

@DASPRiD

DASPRiD Jul 14, 2013

Member

Those are actually backslashes, not slashes. So the test string is a bit confusing.

@DASPRiD

View changes

tests/ZendTest/Config/Reader/JavaPropertiesTest.php
+ {
+ $JavaProperties = '@include:fail.properties';
+
+ $this->setExpectedException('Zend\Config\Exception\RuntimeException');

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Jul 14, 2013

Member

Please also test for the exception message.

@DASPRiD

DASPRiD Jul 14, 2013

Member

Please also test for the exception message.

@DASPRiD

View changes

library/Zend/Config/Reader/JavaProperties.php
+
+ // Check if ends with single '\' (indicating another line is expected)
+ if (strrpos($value, "\\") === strlen($value)-strlen("\\")) {
+ $value = substr($value,0,strlen($value)-1);

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Jul 14, 2013

Member

Spaces after comma and before and after minus.

@DASPRiD

DASPRiD Jul 14, 2013

Member

Spaces after comma and before and after minus.

@coveralls

This comment has been minimized.

Show comment Hide comment
@coveralls

coveralls Jul 14, 2013

Coverage Status

Coverage remained the same when pulling e139fe9 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

Coverage Status

Coverage remained the same when pulling e139fe9 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

@coveralls

This comment has been minimized.

Show comment Hide comment
@coveralls

coveralls Jul 14, 2013

Coverage Status

Coverage remained the same when pulling e139fe9 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

Coverage Status

Coverage remained the same when pulling e139fe9 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

@coveralls

This comment has been minimized.

Show comment Hide comment
@coveralls

coveralls Jul 14, 2013

Coverage Status

Coverage increased (+0%) when pulling 88d5b03 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

Coverage Status

Coverage increased (+0%) when pulling 88d5b03 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

@coveralls

This comment has been minimized.

Show comment Hide comment
@coveralls

coveralls Jul 14, 2013

Coverage Status

Coverage decreased (-0%) when pulling 88d5b03 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

Coverage Status

Coverage decreased (-0%) when pulling 88d5b03 on mvargeson:feature/config-reader-javaproperties into 40585a5 on zendframework:develop.

@jacobkiers

View changes

library/Zend/Config/Reader/JavaProperties.php
+ *
+ * @see ReaderInterface::fromString()
+ * @param string $string
+ * @return array|bool

This comment has been minimized.

Show comment Hide comment
@jacobkiers

jacobkiers Jul 19, 2013

Contributor

While reading this code, it seems to me that this ::fromString() method never returns a boolean. Therefore I would suggest removing that hint. I would also suggest adding an @throws line, since the ::process() method can throw an exception.

@jacobkiers

jacobkiers Jul 19, 2013

Contributor

While reading this code, it seems to me that this ::fromString() method never returns a boolean. Therefore I would suggest removing that hint. I would also suggest adding an @throws line, since the ::process() method can throw an exception.

@ghost ghost assigned weierophinney Jul 22, 2013

weierophinney added a commit that referenced this pull request Jul 22, 2013

Merge pull request #4824 from mvargeson/feature/config-reader-javapro…
…perties

Add Config Reader for Java-style .properties files and strings

weierophinney added a commit that referenced this pull request Jul 22, 2013

@weierophinney weierophinney merged commit 0559ac0 into zendframework:develop Jul 22, 2013

1 check passed

default The Travis CI build passed
Details
+ }
+
+ // Check if ends with single '\' (indicating another line is expected)
+ if (strrpos($value, "\\") === strlen($value) - strlen("\\")) {

This comment has been minimized.

Show comment Hide comment
@drdev

drdev Jul 23, 2013

Contributor

Maybe it's better to get strlen("\\") out of the cycle?

@drdev

drdev Jul 23, 2013

Contributor

Maybe it's better to get strlen("\\") out of the cycle?

This comment has been minimized.

Show comment Hide comment
@DASPRiD

DASPRiD Jul 23, 2013

Member

Like, replacing it with 1? I agree.

@DASPRiD

DASPRiD Jul 23, 2013

Member

Like, replacing it with 1? I agree.

weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015

Merge pull request zendframework/zendframework#4824 from mvargeson/fe…
…ature/config-reader-javaproperties

Add Config Reader for Java-style .properties files and strings

weierophinney added a commit to zendframework/zend-config that referenced this pull request May 15, 2015

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