Skip to content

Commit 117117e

Browse files
committed
fix(sa): use Assert::fail so that phpstan understand code doesn't continue
1 parent 785dea7 commit 117117e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

phpstan.neon

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ parameters:
1717
checkMaybeUndefinedVariables: true
1818
treatPhpDocTypesAsCertain: false
1919
ignoreErrors:
20+
- identifier: return.type
21+
path: tests/_support/_generated/FunctionalTesterActions.php
22+
message: "# but returns mixed.$#"
2023
# If you want to ignore missing generics errors in the future, you can add:
2124
# - identifier: missingType.generics
2225
stubFiles:

src/Codeception/Module/Yii2.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Codeception\Lib\Interfaces\MultiSession;
1717
use Codeception\Lib\Interfaces\PartedModule;
1818
use Codeception\TestInterface;
19+
use PHPUnit\Framework\Assert;
1920
use ReflectionClass;
2021
use RuntimeException;
2122
use Symfony\Component\BrowserKit\CookieJar;
@@ -647,7 +648,7 @@ public function haveRecord(string $model, $attributes = []): int|string|array
647648
$record = \Yii::createObject($model);
648649
$record->setAttributes($attributes, false);
649650
if (! $record->save(false)) {
650-
$this->fail("Record $model was not saved: " . \yii\helpers\Json::encode($record->errors));
651+
Assert::fail("Record $model was not saved: " . \yii\helpers\Json::encode($record->errors));
651652
}
652653
return $record->getPrimaryKey();
653654
}
@@ -667,7 +668,7 @@ public function seeRecord(string $model, array $attributes = []): void
667668
{
668669
$record = $this->findRecord($model, $attributes);
669670
if (! $record) {
670-
$this->fail("Couldn't find $model with " . json_encode($attributes));
671+
Assert::fail("Couldn't find $model with " . json_encode($attributes));
671672
}
672673
$this->debugSection($model, json_encode($record));
673674
}
@@ -688,7 +689,7 @@ public function dontSeeRecord(string $model, array $attributes = []): void
688689
$record = $this->findRecord($model, $attributes);
689690
$this->debugSection($model, json_encode($record));
690691
if ($record) {
691-
$this->fail("Unexpectedly managed to find $model with " . json_encode($attributes));
692+
Assert::fail("Unexpectedly managed to find $model with " . json_encode($attributes));
692693
}
693694
}
694695

0 commit comments

Comments
 (0)