Skip to content

Commit

Permalink
Apply fixes from StyleCI (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored Nov 30, 2019
1 parent 40e8f66 commit 8c62ccf
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Loader/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private static function isValidName($name)
private static function parseValue($value)
{
if ($value === null) {
return null;
return;
}

if (trim($value) === '') {
Expand Down Expand Up @@ -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]);
Expand All @@ -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]);
Expand All @@ -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');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Loader/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private function __construct($chars, array $vars)
*/
public static function blank()
{
return new Value('', []);
return new self('', []);
}

/**
Expand All @@ -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
);
Expand Down
6 changes: 3 additions & 3 deletions src/Repository/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/AdapterRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
12 changes: 5 additions & 7 deletions src/Repository/RepositoryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,7 +54,7 @@ private function __construct(array $readers = null, array $writers = null, $immu
*/
public static function create()
{
return new RepositoryBuilder();
return new self();
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function ($value) {
'is missing'
);
}

}

/**
Expand Down Expand Up @@ -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)
);
}

Expand Down
3 changes: 1 addition & 2 deletions tests/Dotenv/DotenvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function testDotenvTriesPathsToLoad()
$this->assertCount(4, $dotenv->load());
}


public function testDotenvSkipsLoadingIfFileIsMissing()
{
$dotenv = Dotenv::createImmutable(__DIR__);
Expand Down Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Dotenv/LinesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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=\'',
Expand Down
2 changes: 1 addition & 1 deletion tests/Dotenv/LoaderTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

use Dotenv\Loader\Loader;
use Dotenv\Repository\Adapter\ArrayAdapter;
use Dotenv\Repository\Adapter\EnvConstAdapter;
use Dotenv\Repository\Adapter\ServerConstAdapter;
use Dotenv\Repository\RepositoryBuilder;
use Dotenv\Loader\Loader;
use PHPUnit\Framework\TestCase;

class LoaderTest extends TestCase
Expand Down
1 change: 0 additions & 1 deletion tests/Dotenv/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<?php

use Dotenv\Dotenv;
use Dotenv\Loader\Loader;
use Dotenv\Repository\Adapter\ArrayAdapter;
use Dotenv\Repository\RepositoryBuilder;
use PHPUnit\Framework\TestCase;
Expand Down

0 comments on commit 8c62ccf

Please sign in to comment.