Skip to content

Commit 0745336

Browse files
authored
Explicitly mark nullable parameters (#413)
1 parent ec399f9 commit 0745336

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

src/AbstractActiveRecord.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ public function updateProperties(array $properties): int
720720
* For example, to increment all customers' age by 1:
721721
*
722722
* ```php
723-
* $customer = new Customer($db);
723+
* $customer = new Customer();
724724
* $customer->updateAllCounters(['age' => 1]);
725725
* ```
726726
*
@@ -765,7 +765,7 @@ public function updateAllCounters(array $counters, array|string $condition = '',
765765
* An example usage is as follows:
766766
*
767767
* ```php
768-
* $post = new Post($db);
768+
* $post = new Post();
769769
* $post->updateCounters(['view_count' => 1]);
770770
* ```
771771
*
@@ -1012,7 +1012,7 @@ public function unlinkAll(string $relationName, bool $delete = false): void
10121012
private function setRelationDependencies(
10131013
string $name,
10141014
ActiveQueryInterface $relation,
1015-
string $viaRelationName = null
1015+
string|null $viaRelationName = null
10161016
): void {
10171017
$via = $relation->getVia();
10181018

src/ActiveQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ public function orOnCondition(array|string $condition, array $params = []): stat
731731
return $this;
732732
}
733733

734-
public function viaTable(string $tableName, array $link, callable $callable = null): static
734+
public function viaTable(string $tableName, array $link, callable|null $callable = null): static
735735
{
736736
$arClass = $this->primaryModel ?? $this->arClass;
737737

src/ActiveQueryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function with(array|string ...$with): static;
102102
* @param callable|null $callable A PHP callback for customizing the relation associated with the junction table.
103103
* Its signature should be `function($query)`, where `$query` is the query to be customized.
104104
*/
105-
public function via(string $relationName, callable $callable = null): static;
105+
public function via(string $relationName, callable|null $callable = null): static;
106106

107107
/**
108108
* @return array|string|null the join condition to be used when this query is used in a relational context.
@@ -276,7 +276,7 @@ public function orOnCondition(array|string $condition, array $params = []): stat
276276
*
277277
* @see via()
278278
*/
279-
public function viaTable(string $tableName, array $link, callable $callable = null): static;
279+
public function viaTable(string $tableName, array $link, callable|null $callable = null): static;
280280

281281
/**
282282
* Define an alias for the table defined in {@see arClass}.

src/ActiveRecord.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
* Below is an example showing some typical usage of ActiveRecord:
6464
*
6565
* ```php
66-
* $user = new User($db);
66+
* $user = new User();
6767
* $user->name = 'Qiang';
6868
* $user->save(); // a new row is inserted into user table
6969
*
@@ -145,7 +145,7 @@ public function getTableSchema(): TableSchemaInterface
145145
*
146146
* ```php
147147
* // class Customer extends ActiveRecord
148-
* $customer = new Customer($db);
148+
* $customer = new Customer();
149149
* $customer->loadDefaultValues();
150150
* ```
151151
*
@@ -244,7 +244,7 @@ protected function propertyValuesInternal(): array
244244
return get_object_vars($this);
245245
}
246246

247-
protected function insertInternal(array $propertyNames = null): bool
247+
protected function insertInternal(array|null $propertyNames = null): bool
248248
{
249249
$values = $this->newValues($propertyNames);
250250
$primaryKeys = $this->db()->createCommand()->insertWithReturningPks($this->getTableName(), $values);

src/ActiveRecordInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function delete(): int;
5454
* For example, to delete all customers whose status is 3:
5555
*
5656
* ```php
57-
* $customer = new Customer($db);
57+
* $customer = new Customer();
5858
* $customer->deleteAll('status = 3');
5959
* ```
6060
*
@@ -228,7 +228,7 @@ public function hasProperty(string $name): bool;
228228
* For example, to insert a customer record:
229229
*
230230
* ```php
231-
* $customer = new Customer($db);
231+
* $customer = new Customer();
232232
* $customer->name = $name;
233233
* $customer->email = $email;
234234
* $customer->insert();

src/ActiveRelationTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function __clone()
102102
*
103103
* @return static the relation object itself.
104104
*/
105-
public function via(string $relationName, callable $callable = null): static
105+
public function via(string $relationName, callable|null $callable = null): static
106106
{
107107
if ($this->primaryModel === null) {
108108
throw new InvalidConfigException('Setting via is only supported for relational queries.');
@@ -385,8 +385,8 @@ private function populateRelationFromBuckets(
385385

386386
private function buildBuckets(
387387
array $models,
388-
array $viaModels = null,
389-
self $viaQuery = null
388+
array|null $viaModels = null,
389+
self|null $viaQuery = null
390390
): array {
391391
if ($viaModels !== null) {
392392
$map = [];

0 commit comments

Comments
 (0)