Skip to content

Commit 4164f4c

Browse files
committed
refactor: workaround for PHPStan errors
------ ------------------------------------------------------------------------------------- Line app/Libraries/Blog.php ------ ------------------------------------------------------------------------------------- 253 Negated boolean expression is always true. 💡 Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your phpstan.neon.dist. 255 Negated boolean expression is always false. 262 Negated boolean expression is always true. 269 Unreachable statement - code above always terminates. ------ -------------------------------------------------------------------------------------
1 parent 277316d commit 4164f4c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

app/Libraries/Blog.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ protected function readPost(string $folder, string $filename)
250250

251251
foreach ($contents as $line) {
252252
if (trim($line) === '---') {
253-
$inFrontMatter = ! $inFrontMatter;
253+
$inFrontMatter = $inFrontMatter ? false : true;
254+
254255
if (! $inFrontMatter) {
255256
$inBody = true;
256257
}
@@ -267,6 +268,7 @@ protected function readPost(string $folder, string $filename)
267268

268269
$body[] = trim($line);
269270
}
271+
270272
$post->body = implode("\n", $body);
271273

272274
// Convert body using Markdown

rector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999

100100
// May be uninitialized on purpose
101101
AddDefaultValueForUndefinedVariableRector::class,
102+
103+
// PHPStan will report false positive errors
104+
UnnecessaryTernaryExpressionRector::class => [
105+
__DIR__ . '/app/Libraries/Blog.php',
106+
],
102107
]);
103108

104109
// auto import fully qualified class names

0 commit comments

Comments
 (0)