Skip to content

Commit 36b57f8

Browse files
committed
fixed CS
1 parent 8be647a commit 36b57f8

File tree

1 file changed

+100
-100
lines changed

1 file changed

+100
-100
lines changed

Tests/DotenvTest.php

Lines changed: 100 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ public function testParseWithFormatError($data, $error)
3434

3535
public function getEnvDataWithFormatErrors()
3636
{
37-
$tests = array(
38-
array('FOO=BAR BAZ', "A value containing spaces must be surrounded by quotes in \".env\" at line 1.\n...FOO=BAR BAZ...\n ^ line 1 offset 11"),
39-
array('FOO BAR=BAR', "Whitespace are not supported after the variable name in \".env\" at line 1.\n...FOO BAR=BAR...\n ^ line 1 offset 3"),
40-
array('FOO', "Missing = in the environment variable declaration in \".env\" at line 1.\n...FOO...\n ^ line 1 offset 3"),
41-
array('FOO="foo', "Missing quote to end the value in \".env\" at line 1.\n...FOO=\"foo...\n ^ line 1 offset 8"),
42-
array('FOO=\'foo', "Missing quote to end the value in \".env\" at line 1.\n...FOO='foo...\n ^ line 1 offset 8"),
43-
array('FOO=\'foo'."\n", "Missing quote to end the value in \".env\" at line 1.\n...FOO='foo\\n...\n ^ line 1 offset 8"),
44-
array('export FOO', "Unable to unset an environment variable in \".env\" at line 1.\n...export FOO...\n ^ line 1 offset 10"),
45-
array('FOO=${FOO', "Unclosed braces on variable expansion in \".env\" at line 1.\n...FOO=\${FOO...\n ^ line 1 offset 9"),
46-
array('FOO= BAR', "Whitespace are not supported before the value in \".env\" at line 1.\n...FOO= BAR...\n ^ line 1 offset 4"),
47-
array('Стасян', "Invalid character in variable name in \".env\" at line 1.\n...Стасян...\n ^ line 1 offset 0"),
48-
array('FOO!', "Missing = in the environment variable declaration in \".env\" at line 1.\n...FOO!...\n ^ line 1 offset 3"),
49-
array('FOO=$(echo foo', "Missing closing parenthesis. in \".env\" at line 1.\n...FOO=$(echo foo...\n ^ line 1 offset 14"),
50-
array('FOO=$(echo foo'."\n", "Missing closing parenthesis. in \".env\" at line 1.\n...FOO=$(echo foo\\n...\n ^ line 1 offset 14"),
51-
);
37+
$tests = [
38+
['FOO=BAR BAZ', "A value containing spaces must be surrounded by quotes in \".env\" at line 1.\n...FOO=BAR BAZ...\n ^ line 1 offset 11"],
39+
['FOO BAR=BAR', "Whitespace are not supported after the variable name in \".env\" at line 1.\n...FOO BAR=BAR...\n ^ line 1 offset 3"],
40+
['FOO', "Missing = in the environment variable declaration in \".env\" at line 1.\n...FOO...\n ^ line 1 offset 3"],
41+
['FOO="foo', "Missing quote to end the value in \".env\" at line 1.\n...FOO=\"foo...\n ^ line 1 offset 8"],
42+
['FOO=\'foo', "Missing quote to end the value in \".env\" at line 1.\n...FOO='foo...\n ^ line 1 offset 8"],
43+
['FOO=\'foo'."\n", "Missing quote to end the value in \".env\" at line 1.\n...FOO='foo\\n...\n ^ line 1 offset 8"],
44+
['export FOO', "Unable to unset an environment variable in \".env\" at line 1.\n...export FOO...\n ^ line 1 offset 10"],
45+
['FOO=${FOO', "Unclosed braces on variable expansion in \".env\" at line 1.\n...FOO=\${FOO...\n ^ line 1 offset 9"],
46+
['FOO= BAR', "Whitespace are not supported before the value in \".env\" at line 1.\n...FOO= BAR...\n ^ line 1 offset 4"],
47+
['Стасян', "Invalid character in variable name in \".env\" at line 1.\n...Стасян...\n ^ line 1 offset 0"],
48+
['FOO!', "Missing = in the environment variable declaration in \".env\" at line 1.\n...FOO!...\n ^ line 1 offset 3"],
49+
['FOO=$(echo foo', "Missing closing parenthesis. in \".env\" at line 1.\n...FOO=$(echo foo...\n ^ line 1 offset 14"],
50+
['FOO=$(echo foo'."\n", "Missing closing parenthesis. in \".env\" at line 1.\n...FOO=$(echo foo\\n...\n ^ line 1 offset 14"],
51+
];
5252

5353
if ('\\' !== \DIRECTORY_SEPARATOR) {
54-
$tests[] = array('FOO=$((1dd2))', "Issue expanding a command (%s\n) in \".env\" at line 1.\n...FOO=$((1dd2))...\n ^ line 1 offset 13");
54+
$tests[] = ['FOO=$((1dd2))', "Issue expanding a command (%s\n) in \".env\" at line 1.\n...FOO=$((1dd2))...\n ^ line 1 offset 13"];
5555
}
5656

5757
return $tests;
@@ -72,105 +72,105 @@ public function getEnvData()
7272
$_ENV['REMOTE'] = 'remote';
7373
$_SERVER['SERVERVAR'] = 'servervar';
7474

75-
$tests = array(
75+
$tests = [
7676
// backslashes
77-
array('FOO=foo\\\\bar', array('FOO' => 'foo\\bar')),
78-
array("FOO='foo\\\\bar'", array('FOO' => 'foo\\\\bar')),
79-
array('FOO="foo\\\\bar"', array('FOO' => 'foo\\bar')),
77+
['FOO=foo\\\\bar', ['FOO' => 'foo\\bar']],
78+
["FOO='foo\\\\bar'", ['FOO' => 'foo\\\\bar']],
79+
['FOO="foo\\\\bar"', ['FOO' => 'foo\\bar']],
8080

8181
// escaped backslash in front of variable
82-
array("BAR=bar\nFOO=foo\\\\\$BAR", array('BAR' => 'bar', 'FOO' => 'foo\\bar')),
83-
array("BAR=bar\nFOO='foo\\\\\$BAR'", array('BAR' => 'bar', 'FOO' => 'foo\\\\$BAR')),
84-
array("BAR=bar\nFOO=\"foo\\\\\$BAR\"", array('BAR' => 'bar', 'FOO' => 'foo\\bar')),
82+
["BAR=bar\nFOO=foo\\\\\$BAR", ['BAR' => 'bar', 'FOO' => 'foo\\bar']],
83+
["BAR=bar\nFOO='foo\\\\\$BAR'", ['BAR' => 'bar', 'FOO' => 'foo\\\\$BAR']],
84+
["BAR=bar\nFOO=\"foo\\\\\$BAR\"", ['BAR' => 'bar', 'FOO' => 'foo\\bar']],
8585

86-
array('FOO=foo\\\\\\$BAR', array('FOO' => 'foo\\$BAR')),
87-
array('FOO=\'foo\\\\\\$BAR\'', array('FOO' => 'foo\\\\\\$BAR')),
88-
array('FOO="foo\\\\\\$BAR"', array('FOO' => 'foo\\$BAR')),
86+
['FOO=foo\\\\\\$BAR', ['FOO' => 'foo\\$BAR']],
87+
['FOO=\'foo\\\\\\$BAR\'', ['FOO' => 'foo\\\\\\$BAR']],
88+
['FOO="foo\\\\\\$BAR"', ['FOO' => 'foo\\$BAR']],
8989

9090
// spaces
91-
array('FOO=bar', array('FOO' => 'bar')),
92-
array(' FOO=bar ', array('FOO' => 'bar')),
93-
array('FOO=', array('FOO' => '')),
94-
array("FOO=\n\n\nBAR=bar", array('FOO' => '', 'BAR' => 'bar')),
95-
array('FOO= ', array('FOO' => '')),
96-
array("FOO=\nBAR=bar", array('FOO' => '', 'BAR' => 'bar')),
91+
['FOO=bar', ['FOO' => 'bar']],
92+
[' FOO=bar ', ['FOO' => 'bar']],
93+
['FOO=', ['FOO' => '']],
94+
["FOO=\n\n\nBAR=bar", ['FOO' => '', 'BAR' => 'bar']],
95+
['FOO= ', ['FOO' => '']],
96+
["FOO=\nBAR=bar", ['FOO' => '', 'BAR' => 'bar']],
9797

9898
// newlines
99-
array("\n\nFOO=bar\r\n\n", array('FOO' => 'bar')),
100-
array("FOO=bar\r\nBAR=foo", array('FOO' => 'bar', 'BAR' => 'foo')),
101-
array("FOO=bar\rBAR=foo", array('FOO' => 'bar', 'BAR' => 'foo')),
102-
array("FOO=bar\nBAR=foo", array('FOO' => 'bar', 'BAR' => 'foo')),
99+
["\n\nFOO=bar\r\n\n", ['FOO' => 'bar']],
100+
["FOO=bar\r\nBAR=foo", ['FOO' => 'bar', 'BAR' => 'foo']],
101+
["FOO=bar\rBAR=foo", ['FOO' => 'bar', 'BAR' => 'foo']],
102+
["FOO=bar\nBAR=foo", ['FOO' => 'bar', 'BAR' => 'foo']],
103103

104104
// quotes
105-
array("FOO=\"bar\"\n", array('FOO' => 'bar')),
106-
array("FOO=\"bar'foo\"\n", array('FOO' => 'bar\'foo')),
107-
array("FOO='bar'\n", array('FOO' => 'bar')),
108-
array("FOO='bar\"foo'\n", array('FOO' => 'bar"foo')),
109-
array("FOO=\"bar\\\"foo\"\n", array('FOO' => 'bar"foo')),
110-
array('FOO="bar\nfoo"', array('FOO' => "bar\nfoo")),
111-
array('FOO="bar\rfoo"', array('FOO' => "bar\rfoo")),
112-
array('FOO=\'bar\nfoo\'', array('FOO' => 'bar\nfoo')),
113-
array('FOO=\'bar\rfoo\'', array('FOO' => 'bar\rfoo')),
114-
array('FOO=" FOO "', array('FOO' => ' FOO ')),
115-
array('FOO=" "', array('FOO' => ' ')),
116-
array('PATH="c:\\\\"', array('PATH' => 'c:\\')),
117-
array("FOO=\"bar\nfoo\"", array('FOO' => "bar\nfoo")),
118-
array('FOO=BAR\\"', array('FOO' => 'BAR"')),
119-
array("FOO=BAR\\'BAZ", array('FOO' => "BAR'BAZ")),
120-
array('FOO=\\"BAR', array('FOO' => '"BAR')),
105+
["FOO=\"bar\"\n", ['FOO' => 'bar']],
106+
["FOO=\"bar'foo\"\n", ['FOO' => 'bar\'foo']],
107+
["FOO='bar'\n", ['FOO' => 'bar']],
108+
["FOO='bar\"foo'\n", ['FOO' => 'bar"foo']],
109+
["FOO=\"bar\\\"foo\"\n", ['FOO' => 'bar"foo']],
110+
['FOO="bar\nfoo"', ['FOO' => "bar\nfoo"]],
111+
['FOO="bar\rfoo"', ['FOO' => "bar\rfoo"]],
112+
['FOO=\'bar\nfoo\'', ['FOO' => 'bar\nfoo']],
113+
['FOO=\'bar\rfoo\'', ['FOO' => 'bar\rfoo']],
114+
['FOO=" FOO "', ['FOO' => ' FOO ']],
115+
['FOO=" "', ['FOO' => ' ']],
116+
['PATH="c:\\\\"', ['PATH' => 'c:\\']],
117+
["FOO=\"bar\nfoo\"", ['FOO' => "bar\nfoo"]],
118+
['FOO=BAR\\"', ['FOO' => 'BAR"']],
119+
["FOO=BAR\\'BAZ", ['FOO' => "BAR'BAZ"]],
120+
['FOO=\\"BAR', ['FOO' => '"BAR']],
121121

122122
// concatenated values
123-
array("FOO='bar''foo'\n", array('FOO' => 'barfoo')),
124-
array("FOO='bar '' baz'", array('FOO' => 'bar baz')),
125-
array("FOO=bar\nBAR='baz'\"\$FOO\"", array('FOO' => 'bar', 'BAR' => 'bazbar')),
126-
array("FOO='bar '\\'' baz'", array('FOO' => "bar ' baz")),
123+
["FOO='bar''foo'\n", ['FOO' => 'barfoo']],
124+
["FOO='bar '' baz'", ['FOO' => 'bar baz']],
125+
["FOO=bar\nBAR='baz'\"\$FOO\"", ['FOO' => 'bar', 'BAR' => 'bazbar']],
126+
["FOO='bar '\\'' baz'", ['FOO' => "bar ' baz"]],
127127

128128
// comments
129-
array("#FOO=bar\nBAR=foo", array('BAR' => 'foo')),
130-
array("#FOO=bar # Comment\nBAR=foo", array('BAR' => 'foo')),
131-
array("FOO='bar foo' # Comment", array('FOO' => 'bar foo')),
132-
array("FOO='bar#foo' # Comment", array('FOO' => 'bar#foo')),
133-
array("# Comment\r\nFOO=bar\n# Comment\nBAR=foo", array('FOO' => 'bar', 'BAR' => 'foo')),
134-
array("FOO=bar # Another comment\nBAR=foo", array('FOO' => 'bar', 'BAR' => 'foo')),
135-
array("FOO=\n\n# comment\nBAR=bar", array('FOO' => '', 'BAR' => 'bar')),
136-
array('FOO=NOT#COMMENT', array('FOO' => 'NOT#COMMENT')),
137-
array('FOO= # Comment', array('FOO' => '')),
129+
["#FOO=bar\nBAR=foo", ['BAR' => 'foo']],
130+
["#FOO=bar # Comment\nBAR=foo", ['BAR' => 'foo']],
131+
["FOO='bar foo' # Comment", ['FOO' => 'bar foo']],
132+
["FOO='bar#foo' # Comment", ['FOO' => 'bar#foo']],
133+
["# Comment\r\nFOO=bar\n# Comment\nBAR=foo", ['FOO' => 'bar', 'BAR' => 'foo']],
134+
["FOO=bar # Another comment\nBAR=foo", ['FOO' => 'bar', 'BAR' => 'foo']],
135+
["FOO=\n\n# comment\nBAR=bar", ['FOO' => '', 'BAR' => 'bar']],
136+
['FOO=NOT#COMMENT', ['FOO' => 'NOT#COMMENT']],
137+
['FOO= # Comment', ['FOO' => '']],
138138

139139
// edge cases (no conversions, only strings as values)
140-
array('FOO=0', array('FOO' => '0')),
141-
array('FOO=false', array('FOO' => 'false')),
142-
array('FOO=null', array('FOO' => 'null')),
140+
['FOO=0', ['FOO' => '0']],
141+
['FOO=false', ['FOO' => 'false']],
142+
['FOO=null', ['FOO' => 'null']],
143143

144144
// export
145-
array('export FOO=bar', array('FOO' => 'bar')),
146-
array(' export FOO=bar', array('FOO' => 'bar')),
145+
['export FOO=bar', ['FOO' => 'bar']],
146+
[' export FOO=bar', ['FOO' => 'bar']],
147147

148148
// variable expansion
149-
array("FOO=BAR\nBAR=\$FOO", array('FOO' => 'BAR', 'BAR' => 'BAR')),
150-
array("FOO=BAR\nBAR=\"\$FOO\"", array('FOO' => 'BAR', 'BAR' => 'BAR')),
151-
array("FOO=BAR\nBAR='\$FOO'", array('FOO' => 'BAR', 'BAR' => '$FOO')),
152-
array("FOO_BAR9=BAR\nBAR=\$FOO_BAR9", array('FOO_BAR9' => 'BAR', 'BAR' => 'BAR')),
153-
array("FOO=BAR\nBAR=\${FOO}Z", array('FOO' => 'BAR', 'BAR' => 'BARZ')),
154-
array("FOO=BAR\nBAR=\$FOO}", array('FOO' => 'BAR', 'BAR' => 'BAR}')),
155-
array("FOO=BAR\nBAR=\\\$FOO", array('FOO' => 'BAR', 'BAR' => '$FOO')),
156-
array('FOO=" \\$ "', array('FOO' => ' $ ')),
157-
array('FOO=" $ "', array('FOO' => ' $ ')),
158-
array('BAR=$LOCAL', array('BAR' => 'local')),
159-
array('BAR=$REMOTE', array('BAR' => 'remote')),
160-
array('BAR=$SERVERVAR', array('BAR' => 'servervar')),
161-
array('FOO=$NOTDEFINED', array('FOO' => '')),
162-
);
149+
["FOO=BAR\nBAR=\$FOO", ['FOO' => 'BAR', 'BAR' => 'BAR']],
150+
["FOO=BAR\nBAR=\"\$FOO\"", ['FOO' => 'BAR', 'BAR' => 'BAR']],
151+
["FOO=BAR\nBAR='\$FOO'", ['FOO' => 'BAR', 'BAR' => '$FOO']],
152+
["FOO_BAR9=BAR\nBAR=\$FOO_BAR9", ['FOO_BAR9' => 'BAR', 'BAR' => 'BAR']],
153+
["FOO=BAR\nBAR=\${FOO}Z", ['FOO' => 'BAR', 'BAR' => 'BARZ']],
154+
["FOO=BAR\nBAR=\$FOO}", ['FOO' => 'BAR', 'BAR' => 'BAR}']],
155+
["FOO=BAR\nBAR=\\\$FOO", ['FOO' => 'BAR', 'BAR' => '$FOO']],
156+
['FOO=" \\$ "', ['FOO' => ' $ ']],
157+
['FOO=" $ "', ['FOO' => ' $ ']],
158+
['BAR=$LOCAL', ['BAR' => 'local']],
159+
['BAR=$REMOTE', ['BAR' => 'remote']],
160+
['BAR=$SERVERVAR', ['BAR' => 'servervar']],
161+
['FOO=$NOTDEFINED', ['FOO' => '']],
162+
];
163163

164164
if ('\\' !== \DIRECTORY_SEPARATOR) {
165-
$tests = array_merge($tests, array(
165+
$tests = array_merge($tests, [
166166
// command expansion
167-
array('FOO=$(echo foo)', array('FOO' => 'foo')),
168-
array('FOO=$((1+2))', array('FOO' => '3')),
169-
array('FOO=FOO$((1+2))BAR', array('FOO' => 'FOO3BAR')),
170-
array('FOO=$(echo "$(echo "$(echo "$(echo foo)")")")', array('FOO' => 'foo')),
171-
array("FOO=$(echo \"Quotes won't be a problem\")", array('FOO' => 'Quotes won\'t be a problem')),
172-
array("FOO=bar\nBAR=$(echo \"FOO is \$FOO\")", array('FOO' => 'bar', 'BAR' => 'FOO is bar')),
173-
));
167+
['FOO=$(echo foo)', ['FOO' => 'foo']],
168+
['FOO=$((1+2))', ['FOO' => '3']],
169+
['FOO=FOO$((1+2))BAR', ['FOO' => 'FOO3BAR']],
170+
['FOO=$(echo "$(echo "$(echo "$(echo foo)")")")', ['FOO' => 'foo']],
171+
["FOO=$(echo \"Quotes won't be a problem\")", ['FOO' => 'Quotes won\'t be a problem']],
172+
["FOO=bar\nBAR=$(echo \"FOO is \$FOO\")", ['FOO' => 'bar', 'BAR' => 'FOO is bar']],
173+
]);
174174
}
175175

176176
return $tests;
@@ -319,7 +319,7 @@ public function testServerSuperglobalIsNotOverriden()
319319
$originalValue = $_SERVER['argc'];
320320

321321
$dotenv = new Dotenv();
322-
$dotenv->populate(array('argc' => 'new_value'));
322+
$dotenv->populate(['argc' => 'new_value']);
323323

324324
$this->assertSame($originalValue, $_SERVER['argc']);
325325
}
@@ -330,7 +330,7 @@ public function testEnvVarIsNotOverriden()
330330
$_SERVER['TEST_ENV_VAR'] = 'original_value';
331331

332332
$dotenv = new Dotenv();
333-
$dotenv->populate(array('TEST_ENV_VAR' => 'new_value'));
333+
$dotenv->populate(['TEST_ENV_VAR' => 'new_value']);
334334

335335
$this->assertSame('original_value', getenv('TEST_ENV_VAR'));
336336
}
@@ -340,7 +340,7 @@ public function testHttpVarIsPartiallyOverriden()
340340
$_SERVER['HTTP_TEST_ENV_VAR'] = 'http_value';
341341

342342
$dotenv = new Dotenv();
343-
$dotenv->populate(array('HTTP_TEST_ENV_VAR' => 'env_value'));
343+
$dotenv->populate(['HTTP_TEST_ENV_VAR' => 'env_value']);
344344

345345
$this->assertSame('env_value', getenv('HTTP_TEST_ENV_VAR'));
346346
$this->assertSame('env_value', $_ENV['HTTP_TEST_ENV_VAR']);
@@ -352,7 +352,7 @@ public function testEnvVarIsOverriden()
352352
putenv('TEST_ENV_VAR_OVERRIDEN=original_value');
353353

354354
$dotenv = new Dotenv();
355-
$dotenv->populate(array('TEST_ENV_VAR_OVERRIDEN' => 'new_value'), true);
355+
$dotenv->populate(['TEST_ENV_VAR_OVERRIDEN' => 'new_value'], true);
356356

357357
$this->assertSame('new_value', getenv('TEST_ENV_VAR_OVERRIDEN'));
358358
$this->assertSame('new_value', $_ENV['TEST_ENV_VAR_OVERRIDEN']);
@@ -374,7 +374,7 @@ public function testMemorizingLoadedVarsNamesInSpecialVar()
374374
putenv('DATABASE_URL');
375375

376376
$dotenv = new Dotenv();
377-
$dotenv->populate(array('APP_DEBUG' => '1', 'DATABASE_URL' => 'mysql://root@localhost/db'));
377+
$dotenv->populate(['APP_DEBUG' => '1', 'DATABASE_URL' => 'mysql://root@localhost/db']);
378378

379379
$this->assertSame('APP_DEBUG,DATABASE_URL', getenv('SYMFONY_DOTENV_VARS'));
380380

@@ -391,8 +391,8 @@ public function testMemorizingLoadedVarsNamesInSpecialVar()
391391
putenv('DATABASE_URL');
392392

393393
$dotenv = new Dotenv();
394-
$dotenv->populate(array('APP_DEBUG' => '0', 'DATABASE_URL' => 'mysql://root@localhost/db'));
395-
$dotenv->populate(array('DATABASE_URL' => 'sqlite:///somedb.sqlite'));
394+
$dotenv->populate(['APP_DEBUG' => '0', 'DATABASE_URL' => 'mysql://root@localhost/db']);
395+
$dotenv->populate(['DATABASE_URL' => 'sqlite:///somedb.sqlite']);
396396

397397
$this->assertSame('APP_ENV,DATABASE_URL', getenv('SYMFONY_DOTENV_VARS'));
398398
}
@@ -407,7 +407,7 @@ public function testOverridingEnvVarsWithNamesMemorizedInSpecialVar()
407407
putenv('DOCUMENT_ROOT=/var/www');
408408

409409
$dotenv = new Dotenv();
410-
$dotenv->populate(array('FOO' => 'foo1', 'BAR' => 'bar1', 'BAZ' => 'baz1', 'DOCUMENT_ROOT' => '/boot'));
410+
$dotenv->populate(['FOO' => 'foo1', 'BAR' => 'bar1', 'BAZ' => 'baz1', 'DOCUMENT_ROOT' => '/boot']);
411411

412412
$this->assertSame('foo1', getenv('FOO'));
413413
$this->assertSame('bar1', getenv('BAR'));

0 commit comments

Comments
 (0)