diff --git a/src/Dotenv.php b/src/Dotenv.php index d3e1b2cd..93d2eb20 100644 --- a/src/Dotenv.php +++ b/src/Dotenv.php @@ -2,11 +2,11 @@ namespace Dotenv; +use Dotenv\Exception\InvalidPathException; use Dotenv\Loader\Loader; use Dotenv\Loader\LoaderInterface; use Dotenv\Repository\RepositoryBuilder; use Dotenv\Repository\RepositoryInterface; -use Dotenv\Exception\InvalidPathException; use PhpOption\Option; class Dotenv diff --git a/src/Loader/Parser.php b/src/Loader/Parser.php index 152e11fe..a6400073 100644 --- a/src/Loader/Parser.php +++ b/src/Loader/Parser.php @@ -105,7 +105,7 @@ private static function isValidName($name) private static function parseValue($value) { if ($value === null) { - return null; + return; } if (trim($value) === '') { @@ -141,7 +141,7 @@ private static function processChar($state, $char) return Success::create(['', false, self::DOUBLE_QUOTED_STATE]); } elseif ($char === '#') { return Success::create(['', false, self::COMMENT_STATE]); - } elseif ($char === '$') { + } elseif ($char === '$') { return Success::create([$char, true, self::UNQUOTED_STATE]); } else { return Success::create([$char, false, self::UNQUOTED_STATE]); @@ -151,7 +151,7 @@ private static function processChar($state, $char) return Success::create(['', false, self::COMMENT_STATE]); } elseif (ctype_space($char)) { return Success::create(['', false, self::WHITESPACE_STATE]); - } elseif ($char === '$') { + } elseif ($char === '$') { return Success::create([$char, true, self::UNQUOTED_STATE]); } else { return Success::create([$char, false, self::UNQUOTED_STATE]); @@ -178,7 +178,7 @@ private static function processChar($state, $char) } elseif ($char === '$') { return Success::create([$char, false, self::DOUBLE_QUOTED_STATE]); } elseif (in_array($char, ['f', 'n', 'r', 't', 'v'], true)) { - return Success::create([stripcslashes('\\' . $char), false, self::DOUBLE_QUOTED_STATE]); + return Success::create([stripcslashes('\\'.$char), false, self::DOUBLE_QUOTED_STATE]); } else { return Error::create('an unexpected escape sequence'); } diff --git a/src/Loader/Value.php b/src/Loader/Value.php index c72b2119..4c2280a1 100644 --- a/src/Loader/Value.php +++ b/src/Loader/Value.php @@ -39,7 +39,7 @@ private function __construct($chars, array $vars) */ public static function blank() { - return new Value('', []); + return new self('', []); } /** @@ -52,7 +52,7 @@ public static function blank() */ public function append($char, $var) { - return new Value( + return new self( $this->chars.$char, $var ? array_merge($this->vars, [strlen($this->chars)]) : $this->vars ); diff --git a/src/Repository/AbstractRepository.php b/src/Repository/AbstractRepository.php index 756b7fd4..688da9a1 100644 --- a/src/Repository/AbstractRepository.php +++ b/src/Repository/AbstractRepository.php @@ -59,7 +59,7 @@ public function get($name) * * @return string|null */ - protected abstract function getInternal($name); + abstract protected function getInternal($name); /** * Set an environment variable. @@ -95,7 +95,7 @@ public function set($name, $value = null) * * @return void */ - protected abstract function setInternal($name, $value = null); + abstract protected function setInternal($name, $value = null); /** * Clear an environment variable. @@ -127,7 +127,7 @@ public function clear($name) * * @return void */ - protected abstract function clearInternal($name); + abstract protected function clearInternal($name); /** * Tells whether environment variable has been defined. diff --git a/src/Repository/AdapterRepository.php b/src/Repository/AdapterRepository.php index e1ad3bb1..7d07e27f 100644 --- a/src/Repository/AdapterRepository.php +++ b/src/Repository/AdapterRepository.php @@ -23,7 +23,7 @@ class AdapterRepository extends AbstractRepository * * @param \Dotenv\Repository\Adapter\ReaderInterface[] $readers * @param \Dotenv\Repository\Adapter\WriterInterface[] $writers - * @param bool $immutable + * @param bool $immutable * * @return void */ diff --git a/src/Repository/RepositoryBuilder.php b/src/Repository/RepositoryBuilder.php index f5150aaa..66aeb8a3 100644 --- a/src/Repository/RepositoryBuilder.php +++ b/src/Repository/RepositoryBuilder.php @@ -2,10 +2,8 @@ namespace Dotenv\Repository; -use Dotenv\Repository\Adapter\AvailabilityInterface; -use Dotenv\Repository\Adapter\ReaderInterface; -use Dotenv\Repository\Adapter\WriterInterface; use Dotenv\Repository\Adapter\ApacheAdapter; +use Dotenv\Repository\Adapter\AvailabilityInterface; use Dotenv\Repository\Adapter\EnvConstAdapter; use Dotenv\Repository\Adapter\PutenvAdapter; use Dotenv\Repository\Adapter\ServerConstAdapter; @@ -56,7 +54,7 @@ private function __construct(array $readers = null, array $writers = null, $immu */ public static function create() { - return new RepositoryBuilder(); + return new self(); } /** @@ -70,7 +68,7 @@ public function withReaders(array $readers = null) { $readers = $readers === null ? null : self::filterByAvailability($readers); - return new RepositoryBuilder($readers, $this->writers, $this->immutable); + return new self($readers, $this->writers, $this->immutable); } /** @@ -84,7 +82,7 @@ public function withWriters(array $writers = null) { $writers = $writers === null ? null : self::filterByAvailability($writers); - return new RepositoryBuilder($this->readers, $writers, $this->immutable); + return new self($this->readers, $writers, $this->immutable); } /** @@ -94,7 +92,7 @@ public function withWriters(array $writers = null) */ public function immutable() { - return new RepositoryBuilder($this->readers, $this->writers, true); + return new self($this->readers, $this->writers, true); } /** diff --git a/src/Validator.php b/src/Validator.php index cf5a5ccf..9e04420d 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -46,7 +46,6 @@ function ($value) { 'is missing' ); } - } /** @@ -147,15 +146,14 @@ function ($value) use ($choices) { public function allowedRegexValues($regex) { return $this->assertCallback( - function ($value) use ($regex) - { + function ($value) use ($regex) { if ($value === null) { return true; } return Regex::match($regex, $value)->success()->getOrElse(0) === 1; }, - sprintf('does not match "%s"' , $regex) + sprintf('does not match "%s"', $regex) ); } diff --git a/tests/Dotenv/DotenvTest.php b/tests/Dotenv/DotenvTest.php index d77bfd6f..8646281e 100644 --- a/tests/Dotenv/DotenvTest.php +++ b/tests/Dotenv/DotenvTest.php @@ -51,7 +51,6 @@ public function testDotenvTriesPathsToLoad() $this->assertCount(4, $dotenv->load()); } - public function testDotenvSkipsLoadingIfFileIsMissing() { $dotenv = Dotenv::createImmutable(__DIR__); @@ -236,7 +235,7 @@ public function testMutlilineLoading() $dotenv->load(); $this->assertSame("test\n test\"test\"\n test", getenv('TEST')); $this->assertSame("test\ntest", getenv('TEST_ND')); - $this->assertSame("test\\ntest", getenv('TEST_NS')); + $this->assertSame('test\\ntest', getenv('TEST_NS')); $this->assertSame('https://vision.googleapis.com/v1/images:annotate?key=', getenv('TEST_EQD')); $this->assertSame('https://vision.googleapis.com/v1/images:annotate?key=', getenv('TEST_EQS')); diff --git a/tests/Dotenv/LinesTest.php b/tests/Dotenv/LinesTest.php index 04d69e5b..a348a45a 100644 --- a/tests/Dotenv/LinesTest.php +++ b/tests/Dotenv/LinesTest.php @@ -30,7 +30,7 @@ public function testProcessQuotes() $expected = [ "TEST=\"test\n test\\\"test\\\"\n test\"", - "TEST_ND=\"test\\ntest\"", + 'TEST_ND="test\\ntest"', 'TEST_NS=\'test\\ntest\'', 'TEST_EQD="https://vision.googleapis.com/v1/images:annotate?key="', 'TEST_EQS=\'https://vision.googleapis.com/v1/images:annotate?key=\'', diff --git a/tests/Dotenv/LoaderTest.php b/tests/Dotenv/LoaderTest.php index f9e66179..eea7ce12 100644 --- a/tests/Dotenv/LoaderTest.php +++ b/tests/Dotenv/LoaderTest.php @@ -1,10 +1,10 @@