Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
parameters:
ignoreErrors:
-
message: '#^Only booleans are allowed in a negated boolean, int\|false given\.$#'
identifier: booleanNot.exprNotBoolean
count: 1
path: src/Parser/Lexer.php

-
message: '#^Parameter \#1 \$pattern of function preg_match expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Parser/Lexer.php

-
message: '#^Cannot cast mixed to string\.$#'
identifier: cast.string
count: 1
path: src/Repository/Adapter/EnvConstAdapter.php

-
message: '#^Cannot cast mixed to string\.$#'
identifier: cast.string
count: 1
path: src/Repository/Adapter/ServerConstAdapter.php

-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
identifier: equal.notAllowed
count: 1
path: src/Util/Str.php
2 changes: 1 addition & 1 deletion src/Parser/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function lex(string $content)
$offset = 0;

while (isset($content[$offset])) {
if (!\preg_match($regex, $content, $matches, 0, $offset)) {
if (\preg_match($regex, $content, $matches, 0, $offset) !== 1) {
throw new \Error(\sprintf('Lexer encountered unexpected character [%s].', $content[$offset]));
}

Expand Down
25 changes: 13 additions & 12 deletions src/Repository/Adapter/EnvConstAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,23 @@ public static function create()
*/
public function read(string $name)
{
/** @var \PhpOption\Option<string> */
return Option::fromArraysValue($_ENV, $name)
/** @var \PhpOption\Option<scalar> */
$value = Option::fromArraysValue($_ENV, $name)
->filter(static function ($value) {
return \is_scalar($value);
})
->map(static function ($value) {
if ($value === false) {
return 'false';
}
});

if ($value === true) {
return 'true';
}
return $value->map(static function ($value) {
if ($value === false) {
return 'false';
}

return (string) $value;
});
if ($value === true) {
return 'true';
}

return (string) $value;
});
}

/**
Expand Down
25 changes: 13 additions & 12 deletions src/Repository/Adapter/ServerConstAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,23 @@ public static function create()
*/
public function read(string $name)
{
/** @var \PhpOption\Option<string> */
return Option::fromArraysValue($_SERVER, $name)
/** @var \PhpOption\Option<scalar> */
$value = Option::fromArraysValue($_SERVER, $name)
->filter(static function ($value) {
return \is_scalar($value);
})
->map(static function ($value) {
if ($value === false) {
return 'false';
}
});

if ($value === true) {
return 'true';
}
return $value->map(static function ($value) {
if ($value === false) {
return 'false';
}

return (string) $value;
});
if ($value === true) {
return 'true';
}

return (string) $value;
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Util/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function utf8(string $input, ?string $encoding = null)
* @see https://en.wikipedia.org/wiki/Byte_order_mark
* @see https://github.com/vlucas/phpdotenv/issues/500
*/
if (\substr($converted, 0, 3) == "\xEF\xBB\xBF") {
if (\substr($converted, 0, 3) === "\xEF\xBB\xBF") {
$converted = \substr($converted, 3);
}

Expand Down
Loading