Skip to content

Commit 785dea7

Browse files
committed
chore(cs): fix static analysis by improving stub
1 parent 0d98125 commit 785dea7

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/Codeception/Module/Yii2.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use yii\mail\BaseMessage;
2929
use yii\mail\MessageInterface;
3030
use yii\test\Fixture;
31-
use yii\web\Application;
3231
use yii\web\Application as WebApplication;
3332
use yii\web\IdentityInterface;
3433

@@ -647,11 +646,10 @@ public function haveRecord(string $model, $attributes = []): int|string|array
647646
*/
648647
$record = \Yii::createObject($model);
649648
$record->setAttributes($attributes, false);
650-
$res = $record->save(false);
651-
if (! $res) {
649+
if (! $record->save(false)) {
652650
$this->fail("Record $model was not saved: " . \yii\helpers\Json::encode($record->errors));
653651
}
654-
return $record->primaryKey;
652+
return $record->getPrimaryKey();
655653
}
656654

657655
/**

tests/Yii.stub

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,27 @@ namespace yii {
1717
namespace yii\base {
1818

1919
class Application {}
20+
21+
class Model {}
22+
}
23+
24+
namespace yii\db {
25+
class BaseActiveRecord extends \yii\base\Model {
26+
/**
27+
* @param bool $asArray
28+
* @return int|string|array<string, int|string>|null
29+
*/
30+
public function getPrimaryKey($asArray = false) {}
31+
32+
/**
33+
* @return bool
34+
* @param bool $runValidation
35+
* @param null|list<string> $attributeNames
36+
* @phpstan-assert-if-true (int|string|array<string, int|string>) $this->getPrimaryKey()
37+
*/
38+
public function save($runValidation = true, $attributeNames = null) {}
39+
40+
}
2041
}
2142

2243
namespace yii\web {

0 commit comments

Comments
 (0)