Skip to content

Commit a838327

Browse files
authored
Cleanup (#498)
1 parent bff37bc commit a838327

16 files changed

Lines changed: 44 additions & 90 deletions

src/AbstractActiveRecord.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -750,9 +750,7 @@ public function unlink(string $relationName, ActiveRecordInterface $linkedModel,
750750
if ($viaRelation !== null) {
751751
if (is_array($viaRelation)) {
752752
[$viaName, $viaRelation] = $viaRelation;
753-
/** @psalm-var ActiveQueryInterface $viaRelation */
754753
$viaModel = $viaRelation->getModel();
755-
/** @psalm-var string $viaName */
756754
unset($this->related[$viaName]);
757755
}
758756

@@ -761,7 +759,6 @@ public function unlink(string $relationName, ActiveRecordInterface $linkedModel,
761759

762760
if ($viaRelation instanceof ActiveQueryInterface) {
763761
$from = $viaRelation->getFrom();
764-
/** @psalm-var mixed $viaTable */
765762
$viaTable = reset($from);
766763

767764
foreach ($viaRelation->getLink() as $a => $b) {
@@ -807,9 +804,8 @@ public function unlink(string $relationName, ActiveRecordInterface $linkedModel,
807804
}
808805
} elseif ($linkedModel->isPrimaryKey(array_keys($relation->getLink()))) {
809806
foreach ($relation->getLink() as $a => $b) {
810-
/** @psalm-var mixed $values */
811807
$values = $this->get($b);
812-
/** relation via array valued property */
808+
// relation via array valued property
813809
if (is_array($values)) {
814810
if (($key = array_search($linkedModel->get($a), $values)) !== false) {
815811
unset($values[$key]);
@@ -863,13 +859,10 @@ public function unlinkAll(string $relationName, bool $delete = false): void
863859
if ($viaRelation !== null) {
864860
if (is_array($viaRelation)) {
865861
[$viaName, $viaRelation] = $viaRelation;
866-
/** @psalm-var ActiveQueryInterface $viaRelation */
867862
$viaModel = $viaRelation->getModel();
868-
/** @psalm-var string $viaName */
869863
unset($this->related[$viaName]);
870864
} else {
871865
$from = $viaRelation->getFrom();
872-
/** @psalm-var mixed $viaTable */
873866
$viaTable = reset($from);
874867
}
875868

@@ -879,7 +872,6 @@ public function unlinkAll(string $relationName, bool $delete = false): void
879872
if ($viaRelation instanceof ActiveQueryInterface) {
880873
foreach ($viaRelation->getLink() as $a => $b) {
881874
$nulls[$a] = null;
882-
/** @psalm-var mixed */
883875
$condition[$a] = $this->get($b);
884876
}
885877

@@ -920,7 +912,6 @@ public function unlinkAll(string $relationName, bool $delete = false): void
920912

921913
foreach ($relation->getLink() as $a => $b) {
922914
$nulls[$a] = null;
923-
/** @psalm-var mixed */
924915
$condition[$a] = $this->get($b);
925916
}
926917

@@ -967,10 +958,6 @@ private function setRelationDependencies(
967958
} elseif ($via instanceof ActiveQueryInterface) {
968959
$this->setRelationDependencies($name, $via);
969960
} else {
970-
/**
971-
* @psalm-var string|null $viaRelationName
972-
* @psalm-var ActiveQueryInterface $viaQuery
973-
*/
974961
[$viaRelationName, $viaQuery] = $via;
975962
$this->setRelationDependencies($name, $viaQuery, $viaRelationName);
976963
}

src/Internal/RelationPopulator.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ private static function populateInternal(ActiveQueryInterface $query, string $na
9090
*/
9191
$indexBy = $query->getIndexBy();
9292
$query->indexBy(null);
93-
/** @psalm-var array<ActiveRecordInterface|array> $models */
9493
$models = $query->all();
9594

9695
self::populateInverseRelation($query, $models, $primaryModels);
@@ -192,7 +191,6 @@ private static function populateRelationFromBuckets(
192191
if ($model instanceof ActiveRecordInterface) {
193192
$model->populateRelation($name, $value);
194193
} else {
195-
/** @var array $model */
196194
$model[$name] = $value;
197195
}
198196
}

tests/ActiveQueryFindTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public function testFindEagerViaTable(): void
102102
}
103103

104104
/**
105-
* {@see https://github.com/yiisoft/yii2/issues/10201}
106-
* {@see https://github.com/yiisoft/yii2/issues/9047}
105+
* @see https://github.com/yiisoft/yii2/issues/10201
106+
* @see https://github.com/yiisoft/yii2/issues/9047
107107
*/
108108
public function testFindCompositeRelationWithJoin(): void
109109
{
@@ -464,12 +464,11 @@ public function testFindNestedRelation(): void
464464
/**
465465
* Ensure ActiveRelationTrait does preserve order of items on find via().
466466
*
467-
* {@see https://github.com/yiisoft/yii2/issues/1310.}
467+
* @see https://github.com/yiisoft/yii2/issues/1310
468468
*/
469469
public function testFindEagerViaRelationPreserveOrder(): void
470470
{
471-
$orderQuery = Order::query();
472-
$orders = $orderQuery->with('itemsInOrder1')->orderBy('created_at')->all();
471+
$orders = Order::query()->with('itemsInOrder1')->orderBy('created_at')->all();
473472
$this->assertCount(3, $orders);
474473

475474
$order = $orders[0];

tests/ActiveQueryTest.php

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use InvalidArgumentException;
99
use LogicException;
1010
use PHPUnit\Framework\Attributes\DataProvider;
11-
use Throwable;
1211
use Yiisoft\ActiveRecord\ActiveQuery;
1312
use Yiisoft\ActiveRecord\ActiveQueryInterface;
1413
use Yiisoft\ActiveRecord\Internal\ArArrayHelper;
@@ -370,7 +369,7 @@ public function testJoinWithRelationChildParams(): void
370369
}
371370

372371
/**
373-
* {@see https://github.com/yiisoft/yii2/issues/5341}
372+
* @see https://github.com/yiisoft/yii2/issues/5341
374373
*
375374
* Issue: Plan 1 -- * Account * -- * User
376375
* Our Tests: Category 1 -- * Item * -- * Order
@@ -460,7 +459,7 @@ public function testDeeplyNestedTableRelation(): void
460459
}
461460

462461
/**
463-
* {@see https://github.com/yiisoft/yii2/issues/5341}
462+
* @see https://github.com/yiisoft/yii2/issues/5341
464463
*
465464
* Issue: Plan 1 -- * Account * -- * User
466465
* Our Tests: Category 1 -- * Item * -- * Order
@@ -674,7 +673,7 @@ public function testJoinWith(): void
674673
$orders = $query->all();
675674
$this->assertCount(3, $orders);
676675

677-
/** {@see https://github.com/yiisoft/yii2/issues/2880} */
676+
/** @see https://github.com/yiisoft/yii2/issues/2880 */
678677
$query = Order::query()->findByPk(1);
679678
$customer = $query->getCustomerQuery()->joinWith(
680679
[
@@ -751,11 +750,9 @@ public function testJoinWithAndScope(): void
751750
}
752751

753752
/**
754-
* @depends testJoinWith
755-
*
756753
* This query will do the same join twice, ensure duplicated JOIN gets removed.
757754
*
758-
* {@see https://github.com/yiisoft/yii2/pull/2650}
755+
* @see https://github.com/yiisoft/yii2/pull/2650
759756
*/
760757
public function testJoinWithVia(): void
761758
{
@@ -783,16 +780,11 @@ public static function aliasMethodProvider(): array
783780
}
784781

785782
/**
786-
* @depends testJoinWith
787-
*
788783
* Tests the alias syntax for joinWith: 'alias' => 'relation'.
789784
*
790-
* @dataProvider aliasMethodProvider
791-
*
792785
* @param string $aliasMethod whether alias is specified explicitly or using the query syntax {{@tablename}}
793-
*
794-
* @throws Exception|InvalidConfigException|Throwable
795786
*/
787+
#[DataProvider('aliasMethodProvider')]
796788
public function testJoinWithAlias(string $aliasMethod): void
797789
{
798790
$orders = [];
@@ -1480,15 +1472,15 @@ public function testIssues(): void
14801472
{
14811473
$this->reloadFixtureAfterTest();
14821474

1483-
/** {@see https://github.com/yiisoft/yii2/issues/4938} */
1475+
/** @see https://github.com/yiisoft/yii2/issues/4938 */
14841476
$categoryQuery = Category::query();
14851477
$category = $categoryQuery->findByPk(2);
14861478
$this->assertInstanceOf(Category::class, $category);
14871479
$this->assertEquals(3, $category->getItemsQuery()->count());
14881480
$this->assertEquals(1, $category->getLimitedItemsQuery()->count());
14891481
$this->assertEquals(1, $category->getLimitedItemsQuery()->distinct(true)->count());
14901482

1491-
/** {@see https://github.com/yiisoft/yii2/issues/3197} */
1483+
/** @see https://github.com/yiisoft/yii2/issues/3197 */
14921484
$orderQuery = Order::query();
14931485
$orders = $orderQuery->with('orderItems')->orderBy('id')->all();
14941486
$this->assertCount(3, $orders);
@@ -1509,7 +1501,7 @@ public function testIssues(): void
15091501
$this->assertCount(3, $orders[1]->getOrderItems());
15101502
$this->assertCount(1, $orders[2]->getOrderItems());
15111503

1512-
/** {@see https://github.com/yiisoft/yii2/issues/8149} */
1504+
/** @see https://github.com/yiisoft/yii2/issues/8149 */
15131505
$arClass = new Customer();
15141506

15151507
$arClass->setName('test');
@@ -1698,7 +1690,7 @@ public function testEmulateExecution(): void
16981690
}
16991691

17001692
/**
1701-
* {@see https://github.com/yiisoft/yii2/issues/12213}
1693+
* @see https://github.com/yiisoft/yii2/issues/12213
17021694
*/
17031695
public function testUnlinkAllOnCondition(): void
17041696
{
@@ -1730,7 +1722,7 @@ public function testUnlinkAllOnCondition(): void
17301722
}
17311723

17321724
/**
1733-
* {@see https://github.com/yiisoft/yii2/issues/12213}
1725+
* @see https://github.com/yiisoft/yii2/issues/12213
17341726
*/
17351727
public function testUnlinkAllOnConditionViaTable(): void
17361728
{
@@ -1760,7 +1752,7 @@ public function testUnlinkAllOnConditionViaTable(): void
17601752
}
17611753

17621754
/**
1763-
* {@see https://github.com/yiisoft/yii2/pull/13891}
1755+
* @see https://github.com/yiisoft/yii2/pull/13891
17641756
*/
17651757
public function testIndexByAfterLoadingRelations(): void
17661758
{
@@ -1826,12 +1818,9 @@ public static function tableNameProvider(): array
18261818
/**
18271819
* Test whether conditions are quoted correctly in conditions where joinWith is used.
18281820
*
1829-
* {@see https://github.com/yiisoft/yii2/issues/11088}
1830-
*
1831-
* @dataProvider tableNameProvider
1832-
*
1833-
* @throws Exception|InvalidConfigException
1821+
* @see https://github.com/yiisoft/yii2/issues/11088
18341822
*/
1823+
#[DataProvider('tableNameProvider')]
18351824
public function testRelationWhereParams(string $orderTableName, string $orderItemTableName): void
18361825
{
18371826
$driverName = $this->db()->getDriverName();
@@ -2072,7 +2061,7 @@ public function testUpdateProperties(): void
20722061
/**
20732062
* Ensure no ambiguous column error occurs if ActiveQuery adds a JOIN.
20742063
*
2075-
* {@see https://github.com/yiisoft/yii2/issues/13757}
2064+
* @see https://github.com/yiisoft/yii2/issues/13757
20762065
*/
20772066
public function testAmbiguousColumnFindOne(): void
20782067
{
@@ -2510,7 +2499,7 @@ public function testDelete(): void
25102499
}
25112500

25122501
/**
2513-
* {@see https://github.com/yiisoft/yii2/issues/17089}
2502+
* @see https://github.com/yiisoft/yii2/issues/17089
25142503
*/
25152504
public function testViaWithCallable(): void
25162505
{

tests/ActiveRecordTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function testStoreEmpty(): void
121121

122122
$this->assertTrue($record->refresh());
123123

124-
/** {@see https://github.com/yiisoft/yii2/commit/34945b0b69011bc7cab684c7f7095d837892a0d4#commitcomment-4458225} */
124+
/** @see https://github.com/yiisoft/yii2/commit/34945b0b69011bc7cab684c7f7095d837892a0d4#commitcomment-4458225 */
125125
$this->assertSame($record->var1, $record->var2);
126126
$this->assertSame($record->var2, $record->var3);
127127
}
@@ -673,7 +673,7 @@ public function testPropertyAccess(): void
673673
unset($arClass->name);
674674
$this->assertNull($arClass->name);
675675

676-
/** {@see https://github.com/yiisoft/yii2-gii/issues/190} */
676+
/** @see https://github.com/yiisoft/yii2-gii/issues/190 */
677677
$baseModel = new Customer();
678678
$this->assertFalse($baseModel->hasProperty('unExistingColumn'));
679679

@@ -761,10 +761,9 @@ public static function providerForUnlinkDelete(): array
761761
}
762762

763763
/**
764-
* @dataProvider providerForUnlinkDelete
765-
*
766764
* @see https://github.com/yiisoft/yii2/issues/17174
767765
*/
766+
#[DataProvider('providerForUnlinkDelete')]
768767
public function testUnlinkWithViaOnCondition($delete, $count): void
769768
{
770769
$this->reloadFixtureAfterTest();

tests/Driver/Mysql/ActiveRecordTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function testExplicitPkOnAutoIncrement(): void
8282
}
8383

8484
/**
85-
* {@see https://github.com/yiisoft/yii2/issues/15482}
85+
* @see https://github.com/yiisoft/yii2/issues/15482
8686
*/
8787
public function testEagerLoadingUsingStringIdentifiers(): void
8888
{

tests/Driver/Mysql/MagicActiveRecordTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testExplicitPkOnAutoIncrement(): void
3636
}
3737

3838
/**
39-
* {@see https://github.com/yiisoft/yii2/issues/15482}
39+
* @see https://github.com/yiisoft/yii2/issues/15482
4040
*/
4141
public function testEagerLoadingUsingStringIdentifiers(): void
4242
{

tests/Driver/Oracle/ActiveQueryTest.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44

55
namespace Yiisoft\ActiveRecord\Tests\Driver\Oracle;
66

7-
use Throwable;
7+
use PHPUnit\Framework\Attributes\DataProvider;
88
use Yiisoft\ActiveRecord\ActiveQuery;
99
use Yiisoft\ActiveRecord\ActiveQueryInterface;
1010
use Yiisoft\ActiveRecord\Tests\Driver\Oracle\Stubs\Order;
1111
use Yiisoft\ActiveRecord\Tests\Support\OracleHelper;
1212
use Yiisoft\Db\Connection\ConnectionInterface;
13-
use Yiisoft\Db\Exception\Exception;
14-
use Yiisoft\Db\Exception\InvalidConfigException;
1513

1614
final class ActiveQueryTest extends \Yiisoft\ActiveRecord\Tests\ActiveQueryTest
1715
{
@@ -21,16 +19,11 @@ protected static function createConnection(): ConnectionInterface
2119
}
2220

2321
/**
24-
* @depends testJoinWith
25-
*
2622
* Tests the alias syntax for joinWith: 'alias' => 'relation'.
2723
*
28-
* @dataProvider aliasMethodProvider
29-
*
3024
* @param string $aliasMethod whether alias is specified explicitly or using the query syntax {{@tablename}}
31-
*
32-
* @throws Exception|InvalidConfigException|Throwable
3325
*/
26+
#[DataProvider('aliasMethodProvider')]
3427
public function testJoinWithAlias(string $aliasMethod): void
3528
{
3629
$orders = [];

tests/Driver/Pgsql/ActiveRecordTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Yiisoft\ActiveRecord\Tests\Driver\Pgsql;
66

7+
use PHPUnit\Framework\Attributes\DataProvider;
78
use Yiisoft\ActiveRecord\Internal\ArArrayHelper;
89
use Yiisoft\ActiveRecord\Tests\Driver\Pgsql\Stubs\Item;
910
use Yiisoft\ActiveRecord\Tests\Driver\Pgsql\Stubs\Promotion;
@@ -115,7 +116,7 @@ public function testExplicitPkOnAutoIncrement(): void
115116
}
116117

117118
/**
118-
* {@see https://github.com/yiisoft/yii2/issues/15482}
119+
* @see https://github.com/yiisoft/yii2/issues/15482
119120
*/
120121
public function testEagerLoadingUsingStringIdentifiers(): void
121122
{
@@ -157,7 +158,7 @@ public function testBooleanValues(): void
157158
}
158159

159160
/**
160-
* {@see https://github.com/yiisoft/yii2/issues/4672}
161+
* @see https://github.com/yiisoft/yii2/issues/4672
161162
*/
162163
public function testBooleanValues2(): void
163164
{
@@ -299,9 +300,7 @@ public static function arrayValuesProvider(): array
299300
];
300301
}
301302

302-
/**
303-
* @dataProvider arrayValuesProvider
304-
*/
303+
#[DataProvider('arrayValuesProvider')]
305304
public function testArrayValues($properties): void
306305
{
307306
$this->reloadFixtureAfterTest();

0 commit comments

Comments
 (0)