Skip to content

Commit 4855e47

Browse files
committed
chore: Merge branch 'master' into remove-multi-session
2 parents 9d23f36 + 3f8ffe0 commit 4855e47

File tree

12 files changed

+63
-44
lines changed

12 files changed

+63
-44
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ jobs:
6262
-p "@semantic-release/release-notes-generator"
6363
-p conventional-changelog-conventionalcommits
6464
-p semantic-release
65-
-- semantic-release
65+
-- semantic-release --dry-run
6666
env:
67-
GITHUB_TOKEN: ${{ secrets.COLLECTHOR_FINE_GRAINED_RELEASE }}
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6868
permissions:
6969
packages: write
7070
contents: write

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"codeception/module-asserts": ">= 3.0",
3030
"codeception/module-filesystem": "> 3.0",
3131
"phpstan/phpstan": "^2",
32-
"rector/rector": "^2",
3332
"symplify/easy-coding-standard": "^12.5"
3433
},
3534
"autoload":{

ecs.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer;
1313
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
1414
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
15-
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
15+
use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer;
1616
use Symplify\EasyCodingStandard\Config\ECSConfig;
1717
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
1818

@@ -27,31 +27,33 @@
2727
]);
2828

2929
// A. full sets
30-
$ecsConfig->sets([SetList::PSR_12, SetList::SPACES]);
30+
$ecsConfig->sets([SetList::PSR_12, SetList::SPACES, SetList::STRICT, SetList::DOCBLOCK]);
3131

3232
$ecsConfig->rule(NotOperatorWithSuccessorSpaceFixer::class);
3333
$ecsConfig->rule(ArraySyntaxFixer::class);
3434
$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
35-
'annotations' => ['author', 'inheritdoc']
35+
'annotations' => ['author', 'inheritdoc', 'package']
3636
]);
3737
$ecsConfig->rule(NoBlankLinesAfterPhpdocFixer::class);
3838
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
3939
'allow_mixed' => true
4040
]);
4141
$ecsConfig->rule(NoEmptyPhpdocFixer::class);
4242
$ecsConfig->rule(NoUnusedImportsFixer::class);
43-
$ecsConfig->rule(DeclareStrictTypesFixer::class);
4443
$ecsConfig->ruleWithConfiguration(FinalInternalClassFixer::class, [
4544
'annotation_exclude' => ['@not-fix', '@internal'],
4645
'annotation_include' => [],
47-
'consider_absent_docblock_as_internal_class' => \true
46+
'consider_absent_docblock_as_internal_class' => true
4847
]);
4948
$ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [
5049
'forbiddenFunctions' => [
5150
'passthru' => null,
5251
'var_dump' => null,
5352
]
5453
]);
54+
$ecsConfig->rule(PhpdocIndentFixer::class);
55+
$ecsConfig->rule(\PhpCsFixer\Fixer\Phpdoc\AlignMultilineCommentFixer::class);
56+
5557
$ecsConfig->skip([
5658
ForbiddenFunctionsSniff::class => [
5759
'tests/**',

phpstan.neon

Lines changed: 3 additions & 0 deletions
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/Lib/Connector/Yii2.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,20 @@
1717
use Symfony\Component\BrowserKit\Request as BrowserkitRequest;
1818
use Symfony\Component\BrowserKit\Response;
1919
use Yii;
20-
use yii\base\Component;
2120
use yii\base\Event;
2221
use yii\base\ExitException;
2322
use yii\base\Security;
2423
use yii\base\UserException;
2524
use yii\mail\BaseMessage;
2625
use yii\web\Application;
2726
use yii\web\IdentityInterface;
28-
use yii\web\Request;
2927
use yii\web\Request as YiiRequest;
3028
use yii\web\Response as YiiResponse;
3129
use yii\web\User;
3230

3331
/**
3432
* @extends Client<BrowserkitRequest, Response>
33+
* @internal This class is not part of the public API
3534
*/
3635
final class Yii2 extends Client
3736
{
@@ -202,8 +201,8 @@ public function getInternalDomains(): array
202201
if ($urlManager->enablePrettyUrl) {
203202
foreach ($urlManager->rules as $rule) {
204203
/**
205-
* @var \yii\web\UrlRule $rule
206-
*/
204+
* @var \yii\web\UrlRule $rule
205+
*/
207206
if ($rule->host !== null) {
208207
$domains[] = $this->getDomainRegex($rule->host);
209208
}
@@ -404,8 +403,8 @@ protected function encodeCookies(
404403

405404
foreach ($response->getCookies() as $cookie) {
406405
/**
407-
* @var \yii\web\Cookie $cookie
408-
*/
406+
* @var \yii\web\Cookie $cookie
407+
*/
409408
$value = $cookie->value;
410409
// Expire = 1 means we're removing the cookie
411410
if ($cookie->expire !== 1 && isset($validationKey)) {

src/Codeception/Lib/Connector/Yii2/ConnectionWatcher.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use yii\db\Connection;
1212

1313
/**
14-
* Class ConnectionWatcher
1514
* This class will watch for new database connection and store a reference to the connection object.
1615
* @internal
1716
*/

src/Codeception/Lib/Connector/Yii2/FixturesStore.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ final class FixturesStore
1313

1414
/**
1515
* Expects fixtures config
16-
*
17-
* FixturesStore constructor.
1816
*/
1917
public function __construct(
2018
protected mixed $data

src/Codeception/Lib/Connector/Yii2/TransactionForcer.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
use yii\db\Transaction;
1010

1111
/**
12-
* Class TransactionForcer
1312
* This class adds support for forcing transactions as well as reusing PDO objects.
14-
*
15-
* @package Codeception\Lib\Connector\Yii2
1613
*/
1714
final class TransactionForcer extends ConnectionWatcher
1815
{
@@ -91,8 +88,8 @@ protected function connectionOpened(Connection $connection): void
9188
public function rollbackAll(): void
9289
{
9390
/**
94-
* @var Transaction $transaction
95-
*/
91+
* @var Transaction $transaction
92+
*/
9693
foreach ($this->transactions as $transaction) {
9794
if ($transaction->db->isActive) {
9895
$transaction->rollBack();

src/Codeception/Module/Yii2.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Codeception\Lib\Interfaces\ActiveRecord;
1616
use Codeception\Lib\Interfaces\PartedModule;
1717
use Codeception\TestInterface;
18+
use PHPUnit\Framework\Assert;
1819
use ReflectionClass;
1920
use RuntimeException;
2021
use Yii;
@@ -25,7 +26,7 @@
2526
use yii\mail\BaseMessage;
2627
use yii\mail\MessageInterface;
2728
use yii\test\Fixture;
28-
use yii\web\Application;
29+
use yii\web\Application as WebApplication;
2930
use yii\web\IdentityInterface;
3031

3132
/**
@@ -252,7 +253,7 @@ final class Yii2 extends Framework implements ActiveRecord, PartedModule
252253
private TransactionForcer $transactionForcer;
253254

254255
/**
255-
* @var array<mixed> The contents of $_SERVER upon initialization of this object.
256+
* @var array<mixed> The contents of upon initialization of this object.
256257
* This is only used to restore it upon object destruction.
257258
* It MUST not be used anywhere else.
258259
*/
@@ -625,34 +626,34 @@ public function grabFixture(string $name, null|string $index = null): Fixture|\y
625626
*
626627
* ``` php
627628
* <?php
628-
* $user_id = $I->haveRecord('app\models\User', array('name' => 'Davert'));
629+
* $user_id = $I->haveRecord(model: User::class, attributes: ['name' => 'Davert']);
629630
* ?>
630631
* ```
631632
*
632633
* @template T of \yii\db\ActiveRecord
633634
* @param class-string<T> $model
634-
* @param array<string, mixed> $attributes
635+
* @param array<string, mixed> $attributes
635636
* @part orm
637+
* @return int|string|array<string, int|string> The primary key
636638
*/
637-
public function haveRecord(string $model, $attributes = []): mixed
639+
public function haveRecord(string $model, $attributes = []): int|string|array
638640
{
639641
/**
640-
* @var T $record
641-
*/
642+
* @var T $record
643+
*/
642644
$record = \Yii::createObject($model);
643645
$record->setAttributes($attributes, false);
644-
$res = $record->save(false);
645-
if (! $res) {
646-
$this->fail("Record $model was not saved: " . \yii\helpers\Json::encode($record->errors));
646+
if (! $record->save(false)) {
647+
Assert::fail("Record $model was not saved: " . \yii\helpers\Json::encode($record->errors));
647648
}
648-
return $record->primaryKey;
649+
return $record->getPrimaryKey();
649650
}
650651

651652
/**
652653
* Checks that a record exists in the database.
653654
*
654655
* ```php
655-
* $I->seeRecord('app\models\User', array('name' => 'davert'));
656+
* $I->seeRecord(model: User::class, attributes: ['name' => 'davert']);
656657
* ```
657658
*
658659
* @param class-string<\yii\db\ActiveRecord> $model
@@ -663,7 +664,7 @@ public function seeRecord(string $model, array $attributes = []): void
663664
{
664665
$record = $this->findRecord($model, $attributes);
665666
if (! $record) {
666-
$this->fail("Couldn't find $model with " . json_encode($attributes));
667+
Assert::fail("Couldn't find $model with " . json_encode($attributes));
667668
}
668669
$this->debugSection($model, json_encode($record));
669670
}
@@ -672,7 +673,7 @@ public function seeRecord(string $model, array $attributes = []): void
672673
* Checks that a record does not exist in the database.
673674
*
674675
* ```php
675-
* $I->dontSeeRecord('app\models\User', array('name' => 'davert'));
676+
* $I->dontSeeRecord(User::class, attributes: ['name' => 'davert']);
676677
* ```
677678
*
678679
* @param class-string<\yii\db\ActiveRecord> $model
@@ -684,15 +685,15 @@ public function dontSeeRecord(string $model, array $attributes = []): void
684685
$record = $this->findRecord($model, $attributes);
685686
$this->debugSection($model, json_encode($record));
686687
if ($record) {
687-
$this->fail("Unexpectedly managed to find $model with " . json_encode($attributes));
688+
Assert::fail("Unexpectedly managed to find $model with " . json_encode($attributes));
688689
}
689690
}
690691

691692
/**
692693
* Retrieves a record from the database
693694
*
694695
* ```php
695-
* $category = $I->grabRecord('app\models\User', array('name' => 'davert'));
696+
* $category = $I->grabRecord(User::class, attributes: ['name' => 'davert']);
696697
* ```
697698
*
698699
* @param class-string<\yii\db\ActiveRecord> $model

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 {

tests/cases/simple/helpers/DummyUser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class DummyUser implements IdentityInterface
1818
public static function findIdentity($id)
1919
{
2020
return null;
21-
// TODO: Implement findIdentity() method.
21+
2222
}
2323

2424
/**
@@ -32,7 +32,7 @@ public static function findIdentity($id)
3232
*/
3333
public static function findIdentityByAccessToken($token, $type = null)
3434
{
35-
// TODO: Implement findIdentityByAccessToken() method.
35+
3636
}
3737

3838
/**
@@ -41,7 +41,7 @@ public static function findIdentityByAccessToken($token, $type = null)
4141
*/
4242
public function getId()
4343
{
44-
// TODO: Implement getId() method.
44+
4545
}
4646

4747
/**
@@ -58,7 +58,7 @@ public function getId()
5858
*/
5959
public function getAuthKey()
6060
{
61-
// TODO: Implement getAuthKey() method.
61+
6262
}
6363

6464
/**
@@ -71,6 +71,6 @@ public function getAuthKey()
7171
*/
7272
public function validateAuthKey($authKey)
7373
{
74-
// TODO: Implement validateAuthKey() method.
74+
7575
}
7676
}

tests/cases/sqlite/fixtures/TestFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function unload()
3131
foreach ($this->dbComponents as $name) {
3232
/** @var Connection $connection */
3333
$connection = \Yii::$app->get($name);
34-
if (in_array($this->tableName, $connection->getSchema()->getTableNames('', true))) {
34+
if (in_array($this->tableName, $connection->getSchema()->getTableNames('', true), true)) {
3535
$connection->createCommand()->dropTable($this->tableName)->execute();
3636
}
3737
}

0 commit comments

Comments
 (0)