Skip to content

Commit 8c62ccf

Browse files
Apply fixes from StyleCI (#388)
1 parent 40e8f66 commit 8c62ccf

File tree

11 files changed

+21
-27
lines changed

11 files changed

+21
-27
lines changed

src/Dotenv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Dotenv;
44

5+
use Dotenv\Exception\InvalidPathException;
56
use Dotenv\Loader\Loader;
67
use Dotenv\Loader\LoaderInterface;
78
use Dotenv\Repository\RepositoryBuilder;
89
use Dotenv\Repository\RepositoryInterface;
9-
use Dotenv\Exception\InvalidPathException;
1010
use PhpOption\Option;
1111

1212
class Dotenv

src/Loader/Parser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static function isValidName($name)
105105
private static function parseValue($value)
106106
{
107107
if ($value === null) {
108-
return null;
108+
return;
109109
}
110110

111111
if (trim($value) === '') {
@@ -141,7 +141,7 @@ private static function processChar($state, $char)
141141
return Success::create(['', false, self::DOUBLE_QUOTED_STATE]);
142142
} elseif ($char === '#') {
143143
return Success::create(['', false, self::COMMENT_STATE]);
144-
} elseif ($char === '$') {
144+
} elseif ($char === '$') {
145145
return Success::create([$char, true, self::UNQUOTED_STATE]);
146146
} else {
147147
return Success::create([$char, false, self::UNQUOTED_STATE]);
@@ -151,7 +151,7 @@ private static function processChar($state, $char)
151151
return Success::create(['', false, self::COMMENT_STATE]);
152152
} elseif (ctype_space($char)) {
153153
return Success::create(['', false, self::WHITESPACE_STATE]);
154-
} elseif ($char === '$') {
154+
} elseif ($char === '$') {
155155
return Success::create([$char, true, self::UNQUOTED_STATE]);
156156
} else {
157157
return Success::create([$char, false, self::UNQUOTED_STATE]);
@@ -178,7 +178,7 @@ private static function processChar($state, $char)
178178
} elseif ($char === '$') {
179179
return Success::create([$char, false, self::DOUBLE_QUOTED_STATE]);
180180
} elseif (in_array($char, ['f', 'n', 'r', 't', 'v'], true)) {
181-
return Success::create([stripcslashes('\\' . $char), false, self::DOUBLE_QUOTED_STATE]);
181+
return Success::create([stripcslashes('\\'.$char), false, self::DOUBLE_QUOTED_STATE]);
182182
} else {
183183
return Error::create('an unexpected escape sequence');
184184
}

src/Loader/Value.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function __construct($chars, array $vars)
3939
*/
4040
public static function blank()
4141
{
42-
return new Value('', []);
42+
return new self('', []);
4343
}
4444

4545
/**
@@ -52,7 +52,7 @@ public static function blank()
5252
*/
5353
public function append($char, $var)
5454
{
55-
return new Value(
55+
return new self(
5656
$this->chars.$char,
5757
$var ? array_merge($this->vars, [strlen($this->chars)]) : $this->vars
5858
);

src/Repository/AbstractRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function get($name)
5959
*
6060
* @return string|null
6161
*/
62-
protected abstract function getInternal($name);
62+
abstract protected function getInternal($name);
6363

6464
/**
6565
* Set an environment variable.
@@ -95,7 +95,7 @@ public function set($name, $value = null)
9595
*
9696
* @return void
9797
*/
98-
protected abstract function setInternal($name, $value = null);
98+
abstract protected function setInternal($name, $value = null);
9999

100100
/**
101101
* Clear an environment variable.
@@ -127,7 +127,7 @@ public function clear($name)
127127
*
128128
* @return void
129129
*/
130-
protected abstract function clearInternal($name);
130+
abstract protected function clearInternal($name);
131131

132132
/**
133133
* Tells whether environment variable has been defined.

src/Repository/AdapterRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AdapterRepository extends AbstractRepository
2323
*
2424
* @param \Dotenv\Repository\Adapter\ReaderInterface[] $readers
2525
* @param \Dotenv\Repository\Adapter\WriterInterface[] $writers
26-
* @param bool $immutable
26+
* @param bool $immutable
2727
*
2828
* @return void
2929
*/

src/Repository/RepositoryBuilder.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
namespace Dotenv\Repository;
44

5-
use Dotenv\Repository\Adapter\AvailabilityInterface;
6-
use Dotenv\Repository\Adapter\ReaderInterface;
7-
use Dotenv\Repository\Adapter\WriterInterface;
85
use Dotenv\Repository\Adapter\ApacheAdapter;
6+
use Dotenv\Repository\Adapter\AvailabilityInterface;
97
use Dotenv\Repository\Adapter\EnvConstAdapter;
108
use Dotenv\Repository\Adapter\PutenvAdapter;
119
use Dotenv\Repository\Adapter\ServerConstAdapter;
@@ -56,7 +54,7 @@ private function __construct(array $readers = null, array $writers = null, $immu
5654
*/
5755
public static function create()
5856
{
59-
return new RepositoryBuilder();
57+
return new self();
6058
}
6159

6260
/**
@@ -70,7 +68,7 @@ public function withReaders(array $readers = null)
7068
{
7169
$readers = $readers === null ? null : self::filterByAvailability($readers);
7270

73-
return new RepositoryBuilder($readers, $this->writers, $this->immutable);
71+
return new self($readers, $this->writers, $this->immutable);
7472
}
7573

7674
/**
@@ -84,7 +82,7 @@ public function withWriters(array $writers = null)
8482
{
8583
$writers = $writers === null ? null : self::filterByAvailability($writers);
8684

87-
return new RepositoryBuilder($this->readers, $writers, $this->immutable);
85+
return new self($this->readers, $writers, $this->immutable);
8886
}
8987

9088
/**
@@ -94,7 +92,7 @@ public function withWriters(array $writers = null)
9492
*/
9593
public function immutable()
9694
{
97-
return new RepositoryBuilder($this->readers, $this->writers, true);
95+
return new self($this->readers, $this->writers, true);
9896
}
9997

10098
/**

src/Validator.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ function ($value) {
4646
'is missing'
4747
);
4848
}
49-
5049
}
5150

5251
/**
@@ -147,15 +146,14 @@ function ($value) use ($choices) {
147146
public function allowedRegexValues($regex)
148147
{
149148
return $this->assertCallback(
150-
function ($value) use ($regex)
151-
{
149+
function ($value) use ($regex) {
152150
if ($value === null) {
153151
return true;
154152
}
155153

156154
return Regex::match($regex, $value)->success()->getOrElse(0) === 1;
157155
},
158-
sprintf('does not match "%s"' , $regex)
156+
sprintf('does not match "%s"', $regex)
159157
);
160158
}
161159

tests/Dotenv/DotenvTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function testDotenvTriesPathsToLoad()
5151
$this->assertCount(4, $dotenv->load());
5252
}
5353

54-
5554
public function testDotenvSkipsLoadingIfFileIsMissing()
5655
{
5756
$dotenv = Dotenv::createImmutable(__DIR__);
@@ -236,7 +235,7 @@ public function testMutlilineLoading()
236235
$dotenv->load();
237236
$this->assertSame("test\n test\"test\"\n test", getenv('TEST'));
238237
$this->assertSame("test\ntest", getenv('TEST_ND'));
239-
$this->assertSame("test\\ntest", getenv('TEST_NS'));
238+
$this->assertSame('test\\ntest', getenv('TEST_NS'));
240239

241240
$this->assertSame('https://vision.googleapis.com/v1/images:annotate?key=', getenv('TEST_EQD'));
242241
$this->assertSame('https://vision.googleapis.com/v1/images:annotate?key=', getenv('TEST_EQS'));

tests/Dotenv/LinesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testProcessQuotes()
3030

3131
$expected = [
3232
"TEST=\"test\n test\\\"test\\\"\n test\"",
33-
"TEST_ND=\"test\\ntest\"",
33+
'TEST_ND="test\\ntest"',
3434
'TEST_NS=\'test\\ntest\'',
3535
'TEST_EQD="https://vision.googleapis.com/v1/images:annotate?key="',
3636
'TEST_EQS=\'https://vision.googleapis.com/v1/images:annotate?key=\'',

tests/Dotenv/LoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3+
use Dotenv\Loader\Loader;
34
use Dotenv\Repository\Adapter\ArrayAdapter;
45
use Dotenv\Repository\Adapter\EnvConstAdapter;
56
use Dotenv\Repository\Adapter\ServerConstAdapter;
67
use Dotenv\Repository\RepositoryBuilder;
7-
use Dotenv\Loader\Loader;
88
use PHPUnit\Framework\TestCase;
99

1010
class LoaderTest extends TestCase

0 commit comments

Comments
 (0)