Skip to content

Commit f61ce48

Browse files
Fixes for the static analyzer
1 parent fdecd58 commit f61ce48

File tree

6 files changed

+8
-6
lines changed

6 files changed

+8
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": "^5.5.9 || ^7.0",
20-
"phpoption/phpoption": "^1.7.1",
20+
"phpoption/phpoption": "^1.7.2",
2121
"symfony/polyfill-ctype": "^1.9"
2222
},
2323
"require-dev": {

phpstan.neon.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
parameters:
22
level: max
33
ignoreErrors:
4-
- '#Method Dotenv\\Loader\\Parser::processChar\(\) should return Dotenv\\Result\\Result<array<int, bool\|int\|string>, string> but return statement is missing.#'
5-
- '#Method Dotenv\\Repository\\AdapterRepository::getInternal\(\) should return string\|null but return statement is missing.#'
64
- '#Variable \$defaults might not be defined.#'
75
- '/^Parameter \#1 \$readers of class Dotenv\\Repository\\[a-zA-Z]*Repository[a-zA-Z]* constructor expects/'
86
- '/^Parameter \#2 \$writers of class Dotenv\\Repository\\[a-zA-Z]*Repository[a-zA-Z]* constructor expects/'
97
- '#Method Dotenv\\Repository\\AbstractRepository::offset[a-zA-Z\(\)\$ ]* typehint specified.#'
10-
- '#Method Dotenv\\Loader\\Lines::getCharPairs\(\) should return array\(array\(string, string\|null\)\) but returns array\<int, mixed\>.#'
118
- '#Unable to resolve the template type S in call to method PhpOption\\Option<mixed>::flatMap\(\)#'
129
- '#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>.#'
1310
- '#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.#'
1411
- '#Parameter \#1 \$callable of method PhpOption\\Option<array\|null>::[a-z]+\(\) expects callable\(array\|null\): [a-z]+, Closure\(array\): mixed given.#'
15-
- '#Method Dotenv\\Repository\\Adapter\\PutenvAdapter::get\(\) should return PhpOption\\Option<string> but returns PhpOption\\Option<bool\|string>.#'
16-
- '#Method Dotenv\\Store\\File\\Reader::readFromFile\(\) should return PhpOption\\Option<string> but returns PhpOption\\Option<bool\|string>.#'

src/Loader/Lines.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ private static function getCharPairs($line)
111111
{
112112
$chars = str_split($line);
113113

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

src/Loader/Parser.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Dotenv\Exception\InvalidFileException;
66
use Dotenv\Result\Error;
77
use Dotenv\Result\Success;
8+
use RuntimeException;
89

910
class Parser
1011
{
@@ -192,6 +193,8 @@ private static function processChar($state, $char)
192193
}
193194
case self::COMMENT_STATE:
194195
return Success::create(['', false, self::COMMENT_STATE]);
196+
default:
197+
throw new RuntimeException('Parser entered invalid state.');
195198
}
196199
}
197200

src/Repository/AdapterRepository.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ protected function getInternal($name)
5151
return $result->get();
5252
}
5353
}
54+
55+
return null;
5456
}
5557

5658
/**

src/Store/File/Reader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private static function readFromFile($filePath)
4646
{
4747
$content = @file_get_contents($filePath);
4848

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

0 commit comments

Comments
 (0)