Skip to content

Commit 61f8fdb

Browse files
GrahamCampbellStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent e931b4a commit 61f8fdb

File tree

6 files changed

+63
-62
lines changed

6 files changed

+63
-62
lines changed

src/Dotenv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function safeLoad()
6161
return $this->loadData();
6262
} catch (InvalidPathException $e) {
6363
// suppressing exception
64-
return array();
64+
return [];
6565
}
6666
}
6767

src/Loader.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Loader
3333
*
3434
* @var array
3535
*/
36-
public $variableNames = array();
36+
public $variableNames = [];
3737

3838
/**
3939
* Create a new loader instance.
@@ -53,6 +53,7 @@ public function __construct($filePath, $immutable = false)
5353
* Set immutable value.
5454
*
5555
* @param bool $immutable
56+
*
5657
* @return $this
5758
*/
5859
public function setImmutable($immutable = false)
@@ -126,7 +127,7 @@ protected function normaliseEnvironmentVariable($name, $value)
126127

127128
$value = $this->resolveNestedVariables($value);
128129

129-
return array($name, $value);
130+
return [$name, $value];
130131
}
131132

132133
/**
@@ -145,7 +146,7 @@ public function processFilters($name, $value)
145146
list($name, $value) = $this->sanitiseVariableName($name, $value);
146147
list($name, $value) = $this->sanitiseVariableValue($name, $value);
147148

148-
return array($name, $value);
149+
return [$name, $value];
149150
}
150151

151152
/**
@@ -209,7 +210,7 @@ protected function splitCompoundStringIntoParts($name, $value)
209210
list($name, $value) = array_map('trim', explode('=', $name, 2));
210211
}
211212

212-
return array($name, $value);
213+
return [$name, $value];
213214
}
214215

215216
/**
@@ -226,7 +227,7 @@ protected function sanitiseVariableValue($name, $value)
226227
{
227228
$value = trim($value);
228229
if (!$value) {
229-
return array($name, $value);
230+
return [$name, $value];
230231
}
231232

232233
if ($this->beginsWithAQuote($value)) { // value starts with a quote
@@ -264,7 +265,7 @@ protected function sanitiseVariableValue($name, $value)
264265
}
265266
}
266267

267-
return array($name, trim($value));
268+
return [$name, trim($value)];
268269
}
269270

270271
/**
@@ -308,9 +309,9 @@ function ($matchedPatterns) use ($loader) {
308309
*/
309310
protected function sanitiseVariableName($name, $value)
310311
{
311-
$name = trim(str_replace(array('export ', '\'', '"'), '', $name));
312+
$name = trim(str_replace(['export ', '\'', '"'], '', $name));
312313

313-
return array($name, $value);
314+
return [$name, $value];
314315
}
315316

316317
/**
@@ -341,6 +342,7 @@ public function getEnvironmentVariable($name)
341342
return $_SERVER[$name];
342343
default:
343344
$value = getenv($name);
345+
344346
return $value === false ? null : $value; // switch getenv default to null
345347
}
346348
}

src/Validator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function ($value) {
9090
return false;
9191
}
9292

93-
return (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== NULL);
93+
return filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null;
9494
},
9595
'is not a boolean'
9696
);
@@ -129,7 +129,7 @@ protected function assertCallback($callback, $message = 'failed callback asserti
129129
throw new InvalidCallbackException('The provided callback must be callable.');
130130
}
131131

132-
$variablesFailingAssertion = array();
132+
$variablesFailingAssertion = [];
133133
foreach ($this->variables as $variableName) {
134134
$variableValue = $this->loader->getEnvironmentVariable($variableName);
135135
if (call_user_func($callback, $variableValue) === false) {

tests/Dotenv/DotenvTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function testDotenvRequiredArrayEnvironmentVars()
129129
{
130130
$dotenv = new Dotenv($this->fixturesFolder);
131131
$dotenv->load();
132-
$dotenv->required(array('FOO', 'BAR'));
132+
$dotenv->required(['FOO', 'BAR']);
133133
$this->assertTrue(true); // anything wrong an exception will be thrown
134134
}
135135

@@ -153,7 +153,7 @@ public function testDotenvAllowedValues()
153153
{
154154
$dotenv = new Dotenv($this->fixturesFolder);
155155
$dotenv->load();
156-
$dotenv->required('FOO')->allowedValues(array('bar', 'baz'));
156+
$dotenv->required('FOO')->allowedValues(['bar', 'baz']);
157157
$this->assertTrue(true); // anything wrong an exception will be thrown
158158
}
159159

@@ -169,7 +169,7 @@ public function testDotenvProhibitedValues()
169169
{
170170
$dotenv = new Dotenv($this->fixturesFolder);
171171
$dotenv->load();
172-
$dotenv->required('FOO')->allowedValues(array('buzz'));
172+
$dotenv->required('FOO')->allowedValues(['buzz']);
173173
}
174174

175175
/**
@@ -182,7 +182,7 @@ public function testDotenvRequiredThrowsRuntimeException()
182182
$dotenv->load();
183183
$this->assertFalse(getenv('FOOX'));
184184
$this->assertFalse(getenv('NOPE'));
185-
$dotenv->required(array('FOOX', 'NOPE'));
185+
$dotenv->required(['FOOX', 'NOPE']);
186186
}
187187

188188
public function testDotenvNullFileArgumentUsesDefault()
@@ -264,25 +264,25 @@ public function testDotenvAssertions()
264264
$this->assertSame('0', getenv('ASSERTVAR4'));
265265
$this->assertSame('#foo', getenv('ASSERTVAR5'));
266266

267-
$dotenv->required(array(
267+
$dotenv->required([
268268
'ASSERTVAR1',
269269
'ASSERTVAR2',
270270
'ASSERTVAR3',
271271
'ASSERTVAR4',
272272
'ASSERTVAR5',
273-
));
273+
]);
274274

275-
$dotenv->required(array(
275+
$dotenv->required([
276276
'ASSERTVAR1',
277277
'ASSERTVAR4',
278278
'ASSERTVAR5',
279-
))->notEmpty();
279+
])->notEmpty();
280280

281-
$dotenv->required(array(
281+
$dotenv->required([
282282
'ASSERTVAR1',
283283
'ASSERTVAR4',
284284
'ASSERTVAR5',
285-
))->notEmpty()->allowedValues(array('0', 'val1', '#foo'));
285+
])->notEmpty()->allowedValues(['0', 'val1', '#foo']);
286286

287287
$this->assertTrue(true); // anything wrong an an exception will be thrown
288288
}
@@ -347,6 +347,6 @@ public function testGetEnvironmentVariablesList()
347347
$dotenv = new Dotenv($this->fixturesFolder);
348348
$dotenv->load();
349349
$this->assertTrue(is_array($dotenv->getEnvironmentVariableNames()));
350-
$this->assertSame(array('FOO', 'BAR', 'SPACED', 'NULL'), $dotenv->getEnvironmentVariableNames());
350+
$this->assertSame(['FOO', 'BAR', 'SPACED', 'NULL'], $dotenv->getEnvironmentVariableNames());
351351
}
352352
}

tests/Dotenv/LoaderTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class LoaderTest extends TestCase
1717

1818
public function setUp()
1919
{
20-
$folder = dirname(__DIR__) . '/fixtures/env';
20+
$folder = dirname(__DIR__).'/fixtures/env';
2121

2222
// Generate a new, random keyVal.
2323
$this->keyVal(true);
@@ -37,15 +37,15 @@ public function setUp()
3737
* key/value pairs.
3838
*
3939
* @param bool $reset
40-
* If true, a new pair will be generated. If false, the last returned pair
41-
* will be returned.
40+
* If true, a new pair will be generated. If false, the last returned pair
41+
* will be returned.
4242
*
4343
* @return array
4444
*/
4545
protected function keyVal($reset = false)
4646
{
4747
if (!isset($this->keyVal) || $reset) {
48-
$this->keyVal = array(uniqid() => uniqid());
48+
$this->keyVal = [uniqid() => uniqid()];
4949
}
5050

5151
return $this->keyVal;
@@ -99,7 +99,6 @@ public function testMutableLoaderClearsEnvironmentVars()
9999
$this->assertSame(false, isset($_SERVER[$this->key()]));
100100
$this->assertTrue(is_array($this->mutableLoader->variableNames));
101101
$this->assertFalse(empty($this->mutableLoader->variableNames));
102-
103102
}
104103

105104
public function testImmutableLoaderSetUnsetImmutable()

tests/Dotenv/ValidatorBooleanTest.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,37 @@ public function setUp()
1515
}
1616

1717
/**
18-
* List of valid boolean values in fixtures/env/booleans.env
18+
* List of valid boolean values in fixtures/env/booleans.env.
1919
*
2020
* @return array
2121
*/
2222
public function validBooleanValuesDataProvider()
2323
{
24-
return array(
25-
array('VALID_EXPLICIT_LOWERCASE_TRUE'),
26-
array('VALID_EXPLICIT_LOWERCASE_FALSE'),
27-
array('VALID_EXPLICIT_UPPERCASE_TRUE'),
28-
array('VALID_EXPLICIT_UPPERCASE_FALSE'),
29-
array('VALID_EXPLICIT_MIXEDCASE_TRUE'),
30-
array('VALID_EXPLICIT_MIXEDCASE_FALSE'),
24+
return [
25+
['VALID_EXPLICIT_LOWERCASE_TRUE'],
26+
['VALID_EXPLICIT_LOWERCASE_FALSE'],
27+
['VALID_EXPLICIT_UPPERCASE_TRUE'],
28+
['VALID_EXPLICIT_UPPERCASE_FALSE'],
29+
['VALID_EXPLICIT_MIXEDCASE_TRUE'],
30+
['VALID_EXPLICIT_MIXEDCASE_FALSE'],
3131

32-
array('VALID_NUMBER_TRUE'),
33-
array('VALID_NUMBER_FALSE'),
32+
['VALID_NUMBER_TRUE'],
33+
['VALID_NUMBER_FALSE'],
3434

35-
array('VALID_ONOFF_LOWERCASE_TRUE'),
36-
array('VALID_ONOFF_LOWERCASE_FALSE'),
37-
array('VALID_ONOFF_UPPERCASE_TRUE'),
38-
array('VALID_ONOFF_UPPERCASE_FALSE'),
39-
array('VALID_ONOFF_MIXEDCASE_TRUE'),
40-
array('VALID_ONOFF_MIXEDCASE_FALSE'),
35+
['VALID_ONOFF_LOWERCASE_TRUE'],
36+
['VALID_ONOFF_LOWERCASE_FALSE'],
37+
['VALID_ONOFF_UPPERCASE_TRUE'],
38+
['VALID_ONOFF_UPPERCASE_FALSE'],
39+
['VALID_ONOFF_MIXEDCASE_TRUE'],
40+
['VALID_ONOFF_MIXEDCASE_FALSE'],
4141

42-
array('VALID_YESNO_LOWERCASE_TRUE'),
43-
array('VALID_YESNO_LOWERCASE_FALSE'),
44-
array('VALID_YESNO_UPPERCASE_TRUE'),
45-
array('VALID_YESNO_UPPERCASE_FALSE'),
46-
array('VALID_YESNO_MIXEDCASE_TRUE'),
47-
array('VALID_YESNO_MIXEDCASE_FALSE'),
48-
);
42+
['VALID_YESNO_LOWERCASE_TRUE'],
43+
['VALID_YESNO_LOWERCASE_FALSE'],
44+
['VALID_YESNO_UPPERCASE_TRUE'],
45+
['VALID_YESNO_UPPERCASE_FALSE'],
46+
['VALID_YESNO_MIXEDCASE_TRUE'],
47+
['VALID_YESNO_MIXEDCASE_FALSE'],
48+
];
4949
}
5050

5151
/**
@@ -62,23 +62,23 @@ public function testCanValidateBooleans($boolean)
6262
}
6363

6464
/**
65-
* List of non-boolean values in fixtures/env/booleans.env
65+
* List of non-boolean values in fixtures/env/booleans.env.
6666
*
6767
* @return array
6868
*/
6969
public function invalidBooleanValuesDataProvider()
7070
{
71-
return array(
72-
array('INVALID_SOMETHING'),
73-
array('INVALID_EMPTY'),
74-
array('INVALID_EMPTY_STRING'),
75-
array('INVALID_NULL'),
76-
array('INVALID_NUMBER_POSITIVE'),
77-
array('INVALID_NUMBER_NEGATIVE'),
78-
array('INVALID_MINUS'),
79-
array('INVALID_TILDA'),
80-
array('INVALID_EXCLAMATION'),
81-
);
71+
return [
72+
['INVALID_SOMETHING'],
73+
['INVALID_EMPTY'],
74+
['INVALID_EMPTY_STRING'],
75+
['INVALID_NULL'],
76+
['INVALID_NUMBER_POSITIVE'],
77+
['INVALID_NUMBER_NEGATIVE'],
78+
['INVALID_MINUS'],
79+
['INVALID_TILDA'],
80+
['INVALID_EXCLAMATION'],
81+
];
8282
}
8383

8484
/**

0 commit comments

Comments
 (0)