Skip to content

Commit 6b5b43b

Browse files
committed
Fix stan errors
1 parent eb28eb6 commit 6b5b43b

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

phpstan.neon

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
parameters:
22
level: 7
3-
checkMissingIterableValueType: false
4-
checkGenericClassInNonGenericObjectType: false
53
treatPhpDocTypesAsCertain: false
64
bootstrapFiles:
75
- tests/bootstrap.php
86
paths:
97
- src
8+
ignoreErrors:
9+
-
10+
identifier: missingType.iterableValue
11+
-
12+
identifier: missingType.generics

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
<issueHandlers>
2020
<PropertyNotSetInConstructor errorLevel="info" />
2121
<MissingConstructor errorLevel="info" />
22+
<RiskyTruthyFalsyComparison errorLevel="info" />
2223
</issueHandlers>
2324
</psalm>

src/Command/I18nExtractCommand.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ public static function defaultName(): string
6363
public function execute(Arguments $args, ConsoleIo $io): ?int
6464
{
6565
$plugin = '';
66-
if ($args->getOption('exclude')) {
66+
if ($args->hasOption('exclude')) {
6767
$this->_exclude = explode(',', (string)$args->getOption('exclude'));
6868
}
69-
if ($args->getOption('files')) {
69+
if ($args->hasOption('files')) {
7070
$this->_files = explode(',', (string)$args->getOption('files'));
7171
}
72-
if ($args->getOption('paths')) {
72+
if ($args->hasOption('paths')) {
7373
$this->_paths = explode(',', (string)$args->getOption('paths'));
74-
} elseif ($args->getOption('plugin')) {
74+
} elseif ($args->hasOption('plugin')) {
7575
$plugin = Inflector::camelize((string)$args->getOption('plugin'));
7676
$this->_paths = [Plugin::classPath($plugin), Plugin::templatePath($plugin)];
7777
} else {
@@ -90,6 +90,10 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
9090
}
9191

9292
if ($args->hasOption('exclude-plugins') && $this->_isExtractingApp()) {
93+
/**
94+
* @phpstan-ignore-next-line
95+
* @psalm-suppress PropertyTypeCoercion
96+
*/
9397
$this->_exclude = array_merge($this->_exclude, App::path('plugins'));
9498
}
9599

@@ -206,7 +210,7 @@ protected function _saveMessages(Arguments $args, ConsoleIo $io): void
206210
});
207211

208212
$domains = null;
209-
if ($args->getOption('domains')) {
213+
if ($args->hasOption('domains')) {
210214
$domains = explode(',', (string)$args->getOption('domains'));
211215
}
212216

@@ -222,7 +226,7 @@ protected function _saveMessages(Arguments $args, ConsoleIo $io): void
222226
foreach ($translations as $msgid => $contexts) {
223227
foreach ($contexts as $context => $details) {
224228
$references = null;
225-
if (!$args->getOption('no-location')) {
229+
if (!(bool)$args->getOption('no-location')) {
226230
$files = $details['references'];
227231
$occurrences = [];
228232
foreach ($files as $file => $lines) {

src/Middleware/I18nMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function ignoreRequestCallback(Closure $callback)
138138
*/
139139
public function detectLanguage(ServerRequest $request, ?string $default = null): string
140140
{
141-
if (empty($default)) {
141+
if (!$default) {
142142
$lang = $this->_config['defaultLanguage'];
143143
} else {
144144
$lang = $default;

0 commit comments

Comments
 (0)