Skip to content

Commit dd31cc5

Browse files
authored
Rename getAR*() methods to getAr*() (#440)
1 parent 7b74a7b commit dd31cc5

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

src/AbstractActiveRecord.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public function link(string $relationName, ActiveRecordInterface $arClass, array
432432
if (is_array($via)) {
433433
[$viaName, $viaRelation] = $via;
434434
/** @psalm-var ActiveQueryInterface $viaRelation */
435-
$viaClass = $viaRelation->getARInstance();
435+
$viaClass = $viaRelation->getArInstance();
436436
// unset $viaName so that it can be reloaded to reflect the change.
437437
/** @psalm-var string $viaName */
438438
unset($this->related[$viaName]);
@@ -825,7 +825,7 @@ public function unlink(string $relationName, ActiveRecordInterface $arClass, boo
825825
if (is_array($viaRelation)) {
826826
[$viaName, $viaRelation] = $viaRelation;
827827
/** @psalm-var ActiveQueryInterface $viaRelation */
828-
$viaClass = $viaRelation->getARInstance();
828+
$viaClass = $viaRelation->getArInstance();
829829
/** @psalm-var string $viaName */
830830
unset($this->related[$viaName]);
831831
}
@@ -941,7 +941,7 @@ public function unlinkAll(string $relationName, bool $delete = false): void
941941
if (is_array($viaRelation)) {
942942
[$viaName, $viaRelation] = $viaRelation;
943943
/** @psalm-var ActiveQueryInterface $viaRelation */
944-
$viaClass = $viaRelation->getARInstance();
944+
$viaClass = $viaRelation->getArInstance();
945945
/** @psalm-var string $viaName */
946946
unset($this->related[$viaName]);
947947
} else {
@@ -984,7 +984,7 @@ public function unlinkAll(string $relationName, bool $delete = false): void
984984
}
985985
}
986986
} else {
987-
$relatedModel = $relation->getARInstance();
987+
$relatedModel = $relation->getArInstance();
988988

989989
$link = $relation->getLink();
990990
if (!$delete && count($link) === 1 && is_array($this->get($b = reset($link)))) {

src/ActiveQuery.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class ActiveQuery extends Query implements ActiveQueryInterface
120120
final public function __construct(
121121
protected string|ActiveRecordInterface|Closure $arClass
122122
) {
123-
parent::__construct($this->getARInstance()->db());
123+
parent::__construct($this->getArInstance()->db());
124124
}
125125

126126
public function each(): DataReaderInterface
@@ -273,7 +273,7 @@ public function populate(array $rows): array
273273
*/
274274
private function removeDuplicatedRows(array $rows): array
275275
{
276-
$instance = $this->getARInstance();
276+
$instance = $this->getArInstance();
277277
$pks = $instance->primaryKey();
278278

279279
if (empty($pks)) {
@@ -416,7 +416,7 @@ public function buildJoinWith(): void
416416

417417
$this->join = [];
418418

419-
$arClass = $this->getARInstance();
419+
$arClass = $this->getArInstance();
420420

421421
foreach ($this->joinWith as [$with, $eagerLoading, $joinType]) {
422422
$this->joinWithRelations($arClass, $with, $joinType);
@@ -517,7 +517,7 @@ private function joinWithRelations(ActiveRecordInterface $arClass, array $with,
517517
}
518518

519519
if ($relation instanceof ActiveQueryInterface) {
520-
$primaryModel = $relation->getARInstance();
520+
$primaryModel = $relation->getArInstance();
521521
$parent = $relation;
522522
}
523523

@@ -779,7 +779,7 @@ public function getTablesUsedInFrom(): array
779779

780780
protected function getPrimaryTableName(): string
781781
{
782-
return $this->getARInstance()->tableName();
782+
return $this->getArInstance()->tableName();
783783
}
784784

785785
public function getOn(): array|string|null
@@ -800,7 +800,7 @@ public function getSql(): string|null
800800
return $this->sql;
801801
}
802802

803-
public function getARClass(): string|ActiveRecordInterface|Closure
803+
public function getArClass(): string|ActiveRecordInterface|Closure
804804
{
805805
return $this->arClass;
806806
}
@@ -809,7 +809,7 @@ public function findByPk(array|float|int|string $values): array|ActiveRecordInte
809809
{
810810
$values = (array) $values;
811811

812-
$arInstance = $this->getARInstance();
812+
$arInstance = $this->getArInstance();
813813
$primaryKey = $arInstance->primaryKey();
814814

815815
if (empty($primaryKey)) {
@@ -845,7 +845,7 @@ public function sql(string|null $value): static
845845
return $this;
846846
}
847847

848-
public function getARInstance(): ActiveRecordInterface
848+
public function getArInstance(): ActiveRecordInterface
849849
{
850850
if ($this->arClass instanceof ActiveRecordInterface) {
851851
return clone $this->arClass;

src/ActiveQueryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public function getSql(): string|null;
317317
*
318318
* @psalm-return ARClass
319319
*/
320-
public function getARClass(): string|ActiveRecordInterface|Closure;
320+
public function getArClass(): string|ActiveRecordInterface|Closure;
321321

322322
public function on(array|string|null $value): static;
323323

@@ -455,7 +455,7 @@ public function getLink(): array;
455455
* @throws NotInstantiableException
456456
* @return ActiveRecordInterface The model instance associated with this query.
457457
*/
458-
public function getARInstance(): ActiveRecordInterface;
458+
public function getArInstance(): ActiveRecordInterface;
459459

460460
/**
461461
* @return bool Whether this query represents a relation to more than one record.

src/ActiveQueryTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function createModels(array $rows): array
129129
$models = [];
130130

131131
foreach ($rows as $row) {
132-
$arClass = $this->getARInstance();
132+
$arClass = $this->getArInstance();
133133
$arClass->populateRecord($row);
134134

135135
$models[] = $arClass;
@@ -159,7 +159,7 @@ public function findWith(array $with, array &$models): void
159159
$primaryModel = reset($models);
160160

161161
if (!$primaryModel instanceof ActiveRecordInterface) {
162-
$primaryModel = $this->getARInstance();
162+
$primaryModel = $this->getArInstance();
163163
}
164164

165165
$relations = $this->normalizeRelations($primaryModel, $with);

src/ActiveRelationTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private function addInverseRelations(array &$result): void
223223
$relatedModel->populateRelation($this->inverseOf, $primaryModel);
224224
}
225225
} else {
226-
$inverseRelation = $this->getARInstance()->relationQuery($this->inverseOf);
226+
$inverseRelation = $this->getArInstance()->relationQuery($this->inverseOf);
227227
$primaryModel = $inverseRelation->getMultiple() ? [$this->primaryModel] : $this->primaryModel;
228228

229229
/** @var array $relatedModel */
@@ -338,7 +338,7 @@ private function populateInverseRelation(
338338

339339
/** @var ActiveQuery $relation */
340340
$relation = is_array($model)
341-
? $this->getARInstance()->relationQuery($name)
341+
? $this->getArInstance()->relationQuery($name)
342342
: $model->relationQuery($name);
343343

344344
$link = $relation->getLink();
@@ -492,7 +492,7 @@ private function prefixKeyColumns(array $columnNames): array
492492
{
493493
if (!empty($this->join) || !empty($this->joinWith)) {
494494
if (empty($this->from)) {
495-
$alias = $this->getARInstance()->tableName();
495+
$alias = $this->getArInstance()->tableName();
496496
} else {
497497
$alias = array_key_first($this->from);
498498

@@ -570,7 +570,7 @@ protected function filterByModels(array $models): void
570570
/** @var string $propertyName */
571571
$propertyName = array_key_first($this->link);
572572

573-
match ($this->getARInstance()->columnType($propertyName)) {
573+
match ($this->getArInstance()->columnType($propertyName)) {
574574
ColumnType::ARRAY => $this->andWhere(new ArrayOverlapsCondition($columnName, $values)),
575575
ColumnType::JSON => $this->andWhere(new JsonOverlapsCondition($columnName, $values)),
576576
default => $this->andWhere(new InCondition($columnName, 'IN', $values)),

tests/ActiveQueryTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testOptions(): void
4040
$customerQuery = new ActiveQuery(Customer::class);
4141

4242
$query = $customerQuery->on(['a' => 'b'])->joinWith('profile');
43-
$this->assertEquals(Customer::class, $query->getARClass());
43+
$this->assertEquals(Customer::class, $query->getArClass());
4444
$this->assertEquals(['a' => 'b'], $query->getOn());
4545
$this->assertEquals([[['profile'], true, 'LEFT JOIN']], $query->getJoinWith());
4646
$customerQuery->resetJoinWith();
@@ -2499,29 +2499,29 @@ public function testEqual(): void
24992499
$this->assertFalse($customerA->equals($customerB));
25002500
}
25012501

2502-
public function testARClassAsString(): void
2502+
public function testArClassAsString(): void
25032503
{
25042504
$query = new ActiveQuery(Customer::class);
25052505

2506-
$this->assertSame(Customer::class, $query->getARClass());
2507-
$this->assertInstanceOf(Customer::class, $query->getARInstance());
2506+
$this->assertSame(Customer::class, $query->getArClass());
2507+
$this->assertInstanceOf(Customer::class, $query->getArInstance());
25082508
}
25092509

2510-
public function testARClassAsInstance(): void
2510+
public function testArClassAsInstance(): void
25112511
{
25122512
$customer = new Customer();
25132513
$query = new ActiveQuery($customer);
25142514

2515-
$this->assertSame($customer, $query->getARClass());
2516-
$this->assertInstanceOf(Customer::class, $query->getARInstance());
2515+
$this->assertSame($customer, $query->getArClass());
2516+
$this->assertInstanceOf(Customer::class, $query->getArInstance());
25172517
}
25182518

2519-
public function testARClassAsClosure(): void
2519+
public function testArClassAsClosure(): void
25202520
{
25212521
$closure = fn (): Customer => new Customer();
25222522
$query = new ActiveQuery($closure);
25232523

2524-
$this->assertSame($closure, $query->getARClass());
2525-
$this->assertInstanceOf(Customer::class, $query->getARInstance());
2524+
$this->assertSame($closure, $query->getArClass());
2525+
$this->assertInstanceOf(Customer::class, $query->getArInstance());
25262526
}
25272527
}

0 commit comments

Comments
 (0)