Skip to content

Commit

Permalink
Fixes for the static analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Dec 15, 2019
1 parent fdecd58 commit f61ce48
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": "^5.5.9 || ^7.0",
"phpoption/phpoption": "^1.7.1",
"phpoption/phpoption": "^1.7.2",
"symfony/polyfill-ctype": "^1.9"
},
"require-dev": {
Expand Down
5 changes: 0 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
parameters:
level: max
ignoreErrors:
- '#Method Dotenv\\Loader\\Parser::processChar\(\) should return Dotenv\\Result\\Result<array<int, bool\|int\|string>, string> but return statement is missing.#'
- '#Method Dotenv\\Repository\\AdapterRepository::getInternal\(\) should return string\|null but return statement is missing.#'
- '#Variable \$defaults might not be defined.#'
- '/^Parameter \#1 \$readers of class Dotenv\\Repository\\[a-zA-Z]*Repository[a-zA-Z]* constructor expects/'
- '/^Parameter \#2 \$writers of class Dotenv\\Repository\\[a-zA-Z]*Repository[a-zA-Z]* constructor expects/'
- '#Method Dotenv\\Repository\\AbstractRepository::offset[a-zA-Z\(\)\$ ]* typehint specified.#'
- '#Method Dotenv\\Loader\\Lines::getCharPairs\(\) should return array\(array\(string, string\|null\)\) but returns array\<int, mixed\>.#'
- '#Unable to resolve the template type S in call to method PhpOption\\Option<mixed>::flatMap\(\)#'
- '#Method Dotenv\\Loader\\Parser::processChar\(\) should return Dotenv\\Result\\Result<array<int, bool\|int\|string>, string> but returns Dotenv\\Result\\Result<array<int, [a-z\|\,]+>, mixed>.#'
- '#Parameter \#1 \$callable of method PhpOption\\Option<Dotenv\\Loader\\Value|null>::map\(\) expects callable\(Dotenv\\Loader\\Value\|null\): mixed, Closure\(Dotenv\\Loader\\Value\): mixed given.#'
- '#Parameter \#1 \$callable of method PhpOption\\Option<array\|null>::[a-z]+\(\) expects callable\(array\|null\): [a-z]+, Closure\(array\): mixed given.#'
- '#Method Dotenv\\Repository\\Adapter\\PutenvAdapter::get\(\) should return PhpOption\\Option<string> but returns PhpOption\\Option<bool\|string>.#'
- '#Method Dotenv\\Store\\File\\Reader::readFromFile\(\) should return PhpOption\\Option<string> but returns PhpOption\\Option<bool\|string>.#'
1 change: 1 addition & 0 deletions src/Loader/Lines.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private static function getCharPairs($line)
{
$chars = str_split($line);

/** @var array{array{string,string|null}} */
return array_map(null, $chars, array_slice($chars, 1));
}

Expand Down
3 changes: 3 additions & 0 deletions src/Loader/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Dotenv\Exception\InvalidFileException;
use Dotenv\Result\Error;
use Dotenv\Result\Success;
use RuntimeException;

class Parser
{
Expand Down Expand Up @@ -192,6 +193,8 @@ private static function processChar($state, $char)
}
case self::COMMENT_STATE:
return Success::create(['', false, self::COMMENT_STATE]);
default:
throw new RuntimeException('Parser entered invalid state.');
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Repository/AdapterRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ protected function getInternal($name)
return $result->get();
}
}

return null;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Store/File/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private static function readFromFile($filePath)
{
$content = @file_get_contents($filePath);

/** @var \PhpOption\Option<string> */
return Option::fromValue($content, false);
}
}

0 comments on commit f61ce48

Please sign in to comment.