Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit e0df00b

Browse files
committed
Merge branch 'hotfix/60' into develop
Forward port #60
2 parents af00163 + 625354b commit e0df00b

File tree

7 files changed

+29
-23
lines changed

7 files changed

+29
-23
lines changed

docs/book/reader.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ loading configuration data from a JSON file.
192192

193193
Consider the following JSON configuration file:
194194

195-
```javascript
195+
```json
196196
{
197197
"webhost" : "www.example.com",
198198
"database" : {
@@ -224,7 +224,7 @@ specific JSON section or element. This is provided using the special syntax
224224
`@include`. Suppose we have a JSON file that contains only the database
225225
configuration:
226226

227-
```javascript
227+
```json
228228
{
229229
"database" : {
230230
"adapter" : "pdo_mysql",
@@ -240,7 +240,7 @@ configuration:
240240

241241
Now let's include it via another configuration file:
242242

243-
```javascript
243+
```json
244244
{
245245
"webhost" : "www.example.com",
246246
"@include" : "database.json"

docs/book/writer.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ echo $writer->toString($config);
154154

155155
The result of this code is the following XML string:
156156

157-
```markup
157+
```xml
158158
<?xml version="1.0" encoding="UTF-8"?>
159159
<zend-config>
160160
<production>
@@ -203,22 +203,22 @@ The result of this code is the following PHP script:
203203

204204
```php
205205
<?php
206-
return array (
206+
return [
207207
'production' =>
208-
array (
208+
[
209209
'webhost' => 'www.example.com',
210210
'database' =>
211-
array (
211+
[
212212
'params' =>
213-
array (
213+
[
214214
'host' => 'localhost',
215215
'username' => 'production',
216216
'password' => 'secret',
217217
'dbname' => 'dbproduction',
218-
),
219-
),
220-
),
221-
);
218+
],
219+
],
220+
],
221+
];
222222
```
223223

224224
You can use the method `toFile()` to save the PHP script to a file.
@@ -251,7 +251,7 @@ echo $writer->toString($config);
251251

252252
The result of this code is the following JSON string:
253253

254-
```javascript
254+
```json
255255
{
256256
"webhost": "www.example.com",
257257
"database": {

src/AbstractConfigFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,6 @@ protected function match($requestedName)
192192
return $matches[1];
193193
}
194194
}
195-
return;
195+
return null;
196196
}
197197
}

src/Processor/Constant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function doProcess($value, array $replacements)
116116
return parent::doProcess($value, $replacements);
117117
}
118118

119-
$class = substr($value, 0, strlen($value) - 7);
119+
$class = substr($value, 0, -7);
120120
if (class_exists($class)) {
121121
return $class;
122122
}

src/Reader/Ini.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ protected function processKey($key, $value, array &$config)
191191
if (strpos($key, $this->nestSeparator) !== false) {
192192
$pieces = explode($this->nestSeparator, $key, 2);
193193

194-
if (! strlen($pieces[0]) || ! strlen($pieces[1])) {
194+
if ($pieces[0] === '' || $pieces[1] === '') {
195195
throw new Exception\RuntimeException(sprintf('Invalid key "%s"', $key));
196-
} elseif (! isset($config[$pieces[0]])) {
196+
}
197+
198+
if (! isset($config[$pieces[0]])) {
197199
if ($pieces[0] === '0' && ! empty($config)) {
198200
$config = [$pieces[0] => $config];
199201
} else {

src/Reader/JavaProperties.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected function parse($string)
138138
$delimLength = strlen($delimiter);
139139
$result = [];
140140
$lines = explode("\n", $string);
141-
$key = "";
141+
$key = '';
142142
$isWaitingOtherLine = false;
143143
foreach ($lines as $i => $line) {
144144
// Ignore empty lines and commented lines
@@ -159,7 +159,7 @@ protected function parse($string)
159159

160160
// Check if ends with single '\' (indicating another line is expected)
161161
if (strrpos($value, "\\") === strlen($value) - strlen("\\")) {
162-
$value = substr($value, 0, strlen($value) - 1);
162+
$value = substr($value, 0, -1);
163163
$isWaitingOtherLine = true;
164164
} else {
165165
$isWaitingOtherLine = false;

src/Writer/Ini.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,17 @@ protected function prepareValue($value)
143143
{
144144
if (is_int($value) || is_float($value)) {
145145
return $value;
146-
} elseif (is_bool($value)) {
146+
}
147+
148+
if (is_bool($value)) {
147149
return ($value ? 'true' : 'false');
148-
} elseif (false === strpos($value, '"')) {
150+
}
151+
152+
if (false === strpos($value, '"')) {
149153
return '"' . $value . '"';
150-
} else {
151-
throw new Exception\RuntimeException('Value can not contain double quotes');
152154
}
155+
156+
throw new Exception\RuntimeException('Value can not contain double quotes');
153157
}
154158

155159
/**

0 commit comments

Comments
 (0)