Skip to content

Commit 50fca59

Browse files
authored
Merge pull request #1 from adhocore/analysis-qJN11k
Apply fixes from StyleCI
2 parents 30f5b90 + 81501db commit 50fca59

File tree

4 files changed

+45
-46
lines changed

4 files changed

+45
-46
lines changed

src/Loader.php

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function load($file, $override = false, $mode = self::PUTENV)
4949
throw new \InvalidArgumentException('The .env file does not exist or is not readable');
5050
}
5151

52-
5352
// Get file contents, fix the comments, quote the values and parse as ini.
5453
$content = \preg_replace('/^\s*#/m', ';', \file_get_contents($file));
5554
$content = \preg_replace('/=([^"\r?\n].*)$/Um', '="$1"', $content);

src/Retriever.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class Retriever
1515
/**
1616
* Get the env variable by its key/name.
1717
*
18-
* @param string $key
19-
* @param mixed $default
20-
* @param int|null $filter PHP's filter constants. See http://php.net/filter_var
21-
* @param int|array $options Additional options to filter.
18+
* @param string $key
19+
* @param mixed $default
20+
* @param int|null $filter PHP's filter constants. See http://php.net/filter_var
21+
* @param int|array $options Additional options to filter.
2222
*
2323
* @return mixed
2424
*/

src/functions.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
/**
66
* Get the env variable by its key/name.
77
*
8-
* @param string $key
9-
* @param mixed $default
10-
* @param int|null $filter PHP's filter constants. See http://php.net/filter_var
11-
* @param int|array $options Additional options to filter.
8+
* @param string $key
9+
* @param mixed $default
10+
* @param int|null $filter PHP's filter constants. See http://php.net/filter_var
11+
* @param int|array $options Additional options to filter.
1212
*
1313
* @return mixed
1414
*/

tests/LoaderTest.php

+37-37
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ public function testLoadPutenv()
1414

1515
$loader->load(__DIR__ . '/stubs/test.env', false, 0);
1616

17-
$this->assertEquals('1', getenv('a'), 'Unquoted number');
18-
$this->assertEquals('2', getenv('b'), 'Quoted number');
19-
$this->assertEquals('$3#', getenv('c'), 'Unquoted string');
20-
$this->assertEquals('lol', getenv('d'), 'Quoted string');
21-
$this->assertEquals('', getenv('e'), 'Empty string');
22-
$this->assertEquals('"6"', getenv('f'), 'Escaped numeric string');
23-
$this->assertEquals('one_two', getenv('1_2'), 'Underscored string');
24-
$this->assertEquals('Apple Ball', getenv('A_B'), 'Multi word string');
17+
$this->assertEquals('1', getenv('a'), 'Unquoted number');
18+
$this->assertEquals('2', getenv('b'), 'Quoted number');
19+
$this->assertEquals('$3#', getenv('c'), 'Unquoted string');
20+
$this->assertEquals('lol', getenv('d'), 'Quoted string');
21+
$this->assertEquals('', getenv('e'), 'Empty string');
22+
$this->assertEquals('"6"', getenv('f'), 'Escaped numeric string');
23+
$this->assertEquals('one_two', getenv('1_2'), 'Underscored string');
24+
$this->assertEquals('Apple Ball', getenv('A_B'), 'Multi word string');
2525
$this->assertEquals("line 1\nline 2", getenv('MUL'), 'Multi line string');
2626

2727
$this->assertFalse(getenv('MuL'), 'Key should be case sensitive');
2828

2929
$this->assertArrayNotHasKey('a', $_SERVER, 'By default should not set to $_SERVER');
30-
$this->assertArrayNotHasKey('b', $_ENV, 'By default should not set to $_ENV');
30+
$this->assertArrayNotHasKey('b', $_ENV, 'By default should not set to $_ENV');
3131
}
3232

3333
public function testLoadGlobals()
@@ -39,14 +39,14 @@ public function testLoadGlobals()
3939
foreach (['SERVER', 'ENV'] as $name) {
4040
$source = $name === 'ENV' ? $_ENV : $_SERVER;
4141

42-
$this->assertEquals('1', $source['a'], 'Unquoted number');
43-
$this->assertEquals('2', $source['b'], 'Quoted number');
44-
$this->assertEquals('$3#', $source['c'], 'Unquoted string');
45-
$this->assertEquals('lol', $source['d'], 'Quoted string');
46-
$this->assertEquals('', $source['e'], 'Empty string');
47-
$this->assertEquals('"6"', $source['f'], 'Escaped numeric string');
48-
$this->assertEquals('one_two', $source['1_2'], 'Underscored string');
49-
$this->assertEquals('Apple Ball', $source['A_B'], 'Multi word string');
42+
$this->assertEquals('1', $source['a'], 'Unquoted number');
43+
$this->assertEquals('2', $source['b'], 'Quoted number');
44+
$this->assertEquals('$3#', $source['c'], 'Unquoted string');
45+
$this->assertEquals('lol', $source['d'], 'Quoted string');
46+
$this->assertEquals('', $source['e'], 'Empty string');
47+
$this->assertEquals('"6"', $source['f'], 'Escaped numeric string');
48+
$this->assertEquals('one_two', $source['1_2'], 'Underscored string');
49+
$this->assertEquals('Apple Ball', $source['A_B'], 'Multi word string');
5050
$this->assertEquals("line 1\nline 2", $source['MUL'], 'Multi line string');
5151

5252
$this->assertArrayNotHasKey('mUl', $source, 'Key should be case sensitive');
@@ -59,35 +59,35 @@ public function testLoadOverrideAll()
5959

6060
$loader->load(__DIR__ . '/stubs/override.env', true, Loader::ALL);
6161

62-
$this->assertNotEquals('1', getenv('a'), 'Unquoted number old');
63-
$this->assertNotEquals('2', getenv('b'), 'Quoted number old');
64-
$this->assertNotEquals('$3#', getenv('c'), 'Unquoted string old');
65-
$this->assertNotEquals('lol', getenv('d'), 'Quoted string old');
66-
$this->assertNotEquals('"6"', getenv('f'), 'Escaped numeric string old');
62+
$this->assertNotEquals('1', getenv('a'), 'Unquoted number old');
63+
$this->assertNotEquals('2', getenv('b'), 'Quoted number old');
64+
$this->assertNotEquals('$3#', getenv('c'), 'Unquoted string old');
65+
$this->assertNotEquals('lol', getenv('d'), 'Quoted string old');
66+
$this->assertNotEquals('"6"', getenv('f'), 'Escaped numeric string old');
6767
$this->assertNotEquals("line 1\nline 2", getenv('MUL'), 'Multi line string old');
6868

69-
$this->assertEquals('o1', getenv('a'), 'Unquoted number new');
70-
$this->assertEquals('o2', getenv('b'), 'Quoted number new');
71-
$this->assertEquals('o$3#', getenv('c'), 'Unquoted string new');
72-
$this->assertEquals('olol', getenv('d'), 'Quoted string new');
73-
$this->assertEquals('"o6"', getenv('f'), 'Escaped numeric string new');
69+
$this->assertEquals('o1', getenv('a'), 'Unquoted number new');
70+
$this->assertEquals('o2', getenv('b'), 'Quoted number new');
71+
$this->assertEquals('o$3#', getenv('c'), 'Unquoted string new');
72+
$this->assertEquals('olol', getenv('d'), 'Quoted string new');
73+
$this->assertEquals('"o6"', getenv('f'), 'Escaped numeric string new');
7474
$this->assertEquals("oline 1\nline 2", getenv('MUL'), 'Multi line string new');
7575

7676
foreach (['SERVER', 'ENV'] as $name) {
7777
$source = $name === 'ENV' ? $_ENV : $_SERVER;
7878

79-
$this->assertNotEquals('1', $source['a'], 'Unquoted number old');
80-
$this->assertNotEquals('2', $source['b'], 'Quoted number old');
81-
$this->assertNotEquals('$3#', $source['c'], 'Unquoted string old');
82-
$this->assertNotEquals('lol', $source['d'], 'Quoted string old');
83-
$this->assertNotEquals('"6"', $source['f'], 'Escaped numeric string old');
79+
$this->assertNotEquals('1', $source['a'], 'Unquoted number old');
80+
$this->assertNotEquals('2', $source['b'], 'Quoted number old');
81+
$this->assertNotEquals('$3#', $source['c'], 'Unquoted string old');
82+
$this->assertNotEquals('lol', $source['d'], 'Quoted string old');
83+
$this->assertNotEquals('"6"', $source['f'], 'Escaped numeric string old');
8484
$this->assertNotEquals("line 1\nline 2", $source['MUL'], 'Multi line string old');
8585

86-
$this->assertEquals('o1', $source['a'], 'Unquoted number new');
87-
$this->assertEquals('o2', $source['b'], 'Quoted number new');
88-
$this->assertEquals('o$3#', $source['c'], 'Unquoted string new');
89-
$this->assertEquals('olol', $source['d'], 'Quoted string new');
90-
$this->assertEquals('"o6"', $source['f'], 'Escaped numeric string new');
86+
$this->assertEquals('o1', $source['a'], 'Unquoted number new');
87+
$this->assertEquals('o2', $source['b'], 'Quoted number new');
88+
$this->assertEquals('o$3#', $source['c'], 'Unquoted string new');
89+
$this->assertEquals('olol', $source['d'], 'Quoted string new');
90+
$this->assertEquals('"o6"', $source['f'], 'Escaped numeric string new');
9191
$this->assertEquals("oline 1\nline 2", $source['MUL'], 'Multi line string new');
9292
}
9393
}

0 commit comments

Comments
 (0)