Skip to content

Commit 94a16a3

Browse files
authored
Fixed implicitly nullable params (#6616)
1 parent 7e2eb33 commit 94a16a3

12 files changed

+27
-27
lines changed

src/Migrations/MigrationCreator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(protected Filesystem $files)
3636
*
3737
* @throws Exception
3838
*/
39-
public function create(string $name, string $path, string $table = null, bool $create = false): string
39+
public function create(string $name, string $path, ?string $table = null, bool $create = false): string
4040
{
4141
$this->ensureMigrationDoesntAlreadyExist($name, $path);
4242

src/Model/Builder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public function withoutGlobalScope($scope)
261261
*
262262
* @return $this
263263
*/
264-
public function withoutGlobalScopes(array $scopes = null)
264+
public function withoutGlobalScopes(?array $scopes = null)
265265
{
266266
if (! is_array($scopes)) {
267267
$scopes = array_keys($this->scopes);
@@ -559,7 +559,7 @@ public function firstOrFail($columns = ['*'])
559559
* @param array|Closure $columns
560560
* @return \Hyperf\Database\Model\Model|mixed|static
561561
*/
562-
public function firstOr($columns = ['*'], Closure $callback = null)
562+
public function firstOr($columns = ['*'], ?Closure $callback = null)
563563
{
564564
if ($columns instanceof Closure) {
565565
$callback = $columns;

src/Model/Concerns/HasAttributes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ public function syncOriginalAttributes($attributes): static
542542
/**
543543
* Sync the changed attributes.
544544
*/
545-
public function syncChanges(array $columns = null): static
545+
public function syncChanges(?array $columns = null): static
546546
{
547547
$changes = $this->getDirty();
548548

src/Model/Concerns/HasGlobalScopes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ trait HasGlobalScopes
2626
*
2727
* @throws InvalidArgumentException
2828
*/
29-
public static function addGlobalScope($scope, Closure $implementation = null)
29+
public static function addGlobalScope($scope, ?Closure $implementation = null)
3030
{
3131
if (is_string($scope) && ! is_null($implementation)) {
3232
return GlobalScope::$container[static::class][$scope] = $implementation;

src/Model/Concerns/QueriesRelationships.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ trait QueriesRelationships
3232
* @param string $boolean
3333
* @return \Hyperf\Database\Model\Builder|static
3434
*/
35-
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
35+
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', ?Closure $callback = null)
3636
{
3737
if (is_string($relation)) {
3838
if (str_contains($relation, '.')) {
@@ -94,7 +94,7 @@ public function orHas($relation, $operator = '>=', $count = 1)
9494
* @param string $boolean
9595
* @return \Hyperf\Database\Model\Builder|static
9696
*/
97-
public function doesntHave($relation, $boolean = 'and', Closure $callback = null)
97+
public function doesntHave($relation, $boolean = 'and', ?Closure $callback = null)
9898
{
9999
return $this->has($relation, '<', 1, $boolean, $callback);
100100
}
@@ -118,7 +118,7 @@ public function orDoesntHave($relation)
118118
* @param int $count
119119
* @return \Hyperf\Database\Model\Builder|static
120120
*/
121-
public function whereHas($relation, Closure $callback = null, $operator = '>=', $count = 1)
121+
public function whereHas($relation, ?Closure $callback = null, $operator = '>=', $count = 1)
122122
{
123123
return $this->has($relation, $operator, $count, 'and', $callback);
124124
}
@@ -132,7 +132,7 @@ public function whereHas($relation, Closure $callback = null, $operator = '>=',
132132
* @param int $count
133133
* @return \Hyperf\Database\Model\Builder|static
134134
*/
135-
public function orWhereHas($relation, Closure $callback = null, $operator = '>=', $count = 1)
135+
public function orWhereHas($relation, ?Closure $callback = null, $operator = '>=', $count = 1)
136136
{
137137
return $this->has($relation, $operator, $count, 'or', $callback);
138138
}
@@ -143,7 +143,7 @@ public function orWhereHas($relation, Closure $callback = null, $operator = '>='
143143
* @param string $relation
144144
* @return \Hyperf\Database\Model\Builder|static
145145
*/
146-
public function whereDoesntHave($relation, Closure $callback = null)
146+
public function whereDoesntHave($relation, ?Closure $callback = null)
147147
{
148148
return $this->doesntHave($relation, 'and', $callback);
149149
}
@@ -155,7 +155,7 @@ public function whereDoesntHave($relation, Closure $callback = null)
155155
* @param Closure $callback
156156
* @return \Hyperf\Database\Model\Builder|static
157157
*/
158-
public function orWhereDoesntHave($relation, Closure $callback = null)
158+
public function orWhereDoesntHave($relation, ?Closure $callback = null)
159159
{
160160
return $this->doesntHave($relation, 'or', $callback);
161161
}
@@ -328,7 +328,7 @@ public function mergeConstraintsFrom(Builder $from)
328328
* @param int $count
329329
* @return $this
330330
*/
331-
public function whereHasMorph($relation, $types, Closure $callback = null, $operator = '>=', $count = 1)
331+
public function whereHasMorph($relation, $types, ?Closure $callback = null, $operator = '>=', $count = 1)
332332
{
333333
return $this->hasMorph($relation, $types, $operator, $count, 'and', $callback);
334334
}
@@ -340,7 +340,7 @@ public function whereHasMorph($relation, $types, Closure $callback = null, $oper
340340
* @param Closure $callback
341341
* @return $this
342342
*/
343-
public function orWhereHasMorph(string $relation, $types, Closure $callback = null, string $operator = '>=', int $count = 1)
343+
public function orWhereHasMorph(string $relation, $types, ?Closure $callback = null, string $operator = '>=', int $count = 1)
344344
{
345345
return $this->hasMorph($relation, $types, $operator, $count, 'or', $callback);
346346
}
@@ -351,7 +351,7 @@ public function orWhereHasMorph(string $relation, $types, Closure $callback = nu
351351
* @param array|string $types
352352
* @return $this
353353
*/
354-
public function whereDoesntHaveMorph(string $relation, $types, Closure $callback = null)
354+
public function whereDoesntHaveMorph(string $relation, $types, ?Closure $callback = null)
355355
{
356356
return $this->doesntHaveMorph($relation, $types, 'and', $callback);
357357
}
@@ -363,7 +363,7 @@ public function whereDoesntHaveMorph(string $relation, $types, Closure $callback
363363
* @param Closure $callback
364364
* @return $this
365365
*/
366-
public function orWhereDoesntHaveMorph(string $relation, $types, Closure $callback = null)
366+
public function orWhereDoesntHaveMorph(string $relation, $types, ?Closure $callback = null)
367367
{
368368
return $this->doesntHaveMorph($relation, $types, 'or', $callback);
369369
}
@@ -378,7 +378,7 @@ public function orWhereDoesntHaveMorph(string $relation, $types, Closure $callba
378378
* @param string $boolean
379379
* @return $this
380380
*/
381-
public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
381+
public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boolean = 'and', ?Closure $callback = null)
382382
{
383383
$relation = $this->getRelationWithoutConstraints($relation);
384384

@@ -417,7 +417,7 @@ public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boole
417417
* @param string $boolean
418418
* @return $this
419419
*/
420-
public function doesntHaveMorph(string $relation, $types, $boolean = 'and', Closure $callback = null)
420+
public function doesntHaveMorph(string $relation, $types, $boolean = 'and', ?Closure $callback = null)
421421
{
422422
return $this->hasMorph($relation, $types, '<', 1, $boolean, $callback);
423423
}

src/Model/Model.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ public function refresh()
884884
*
885885
* @return static
886886
*/
887-
public function replicate(array $except = null)
887+
public function replicate(?array $except = null)
888888
{
889889
$defaults = [
890890
$this->getKeyName(),

src/Model/Relations/BelongsToMany.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ public function get($columns = ['*'])
544544
/**
545545
* Get a paginator for the "select" statement.
546546
*/
547-
public function paginate(int $perPage = null, array $columns = ['*'], string $pageName = 'page', ?int $page = null): LengthAwarePaginatorInterface
547+
public function paginate(?int $perPage = null, array $columns = ['*'], string $pageName = 'page', ?int $page = null): LengthAwarePaginatorInterface
548548
{
549549
$this->query->addSelect($this->shouldSelect($columns));
550550

src/Model/Relations/HasManyThrough.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public function get($columns = ['*'])
330330
/**
331331
* Get a paginator for the "select" statement.
332332
*/
333-
public function paginate(int $perPage = null, array $columns = ['*'], string $pageName = 'page', ?int $page = null): LengthAwarePaginatorInterface
333+
public function paginate(?int $perPage = null, array $columns = ['*'], string $pageName = 'page', ?int $page = null): LengthAwarePaginatorInterface
334334
{
335335
$this->query->addSelect($this->shouldSelect($columns));
336336

@@ -547,7 +547,7 @@ public function getSecondLocalKeyName()
547547
/**
548548
* Set the join clause on the query.
549549
*/
550-
protected function performJoin(Builder $query = null)
550+
protected function performJoin(?Builder $query = null)
551551
{
552552
$query = $query ?: $this->query;
553553

src/Model/Relations/Relation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public function relatedUpdatedAt()
313313
* @param bool $merge
314314
* @return array
315315
*/
316-
public static function morphMap(array $map = null, $merge = true)
316+
public static function morphMap(?array $map = null, $merge = true)
317317
{
318318
$map = static::buildMorphMapFromModels($map);
319319

@@ -382,7 +382,7 @@ protected function whereInMethod(Model $model, $key)
382382
* @param null|string[] $models
383383
* @return null|array
384384
*/
385-
protected static function buildMorphMapFromModels(array $models = null)
385+
protected static function buildMorphMapFromModels(?array $models = null)
386386
{
387387
if (is_null($models) || Arr::isAssoc($models)) {
388388
return $models;

src/Query/Builder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ class Builder
256256
*/
257257
public function __construct(
258258
ConnectionInterface $connection,
259-
Grammar $grammar = null,
260-
Processor $processor = null
259+
?Grammar $grammar = null,
260+
?Processor $processor = null
261261
) {
262262
$this->connection = $connection;
263263
$this->grammar = $grammar ?: $connection->getQueryGrammar();

src/Schema/Blueprint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Blueprint
9898
* @param string $table
9999
* @param string $prefix
100100
*/
101-
public function __construct($table, Closure $callback = null, $prefix = '')
101+
public function __construct($table, ?Closure $callback = null, $prefix = '')
102102
{
103103
$this->table = $table;
104104
$this->prefix = $prefix;

src/Schema/Builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ protected function build(Blueprint $blueprint)
302302
* @param string $table
303303
* @return \Hyperf\Database\Schema\Blueprint
304304
*/
305-
protected function createBlueprint($table, Closure $callback = null)
305+
protected function createBlueprint($table, ?Closure $callback = null)
306306
{
307307
$prefix = $this->connection->getConfig('prefix_indexes')
308308
? $this->connection->getConfig('prefix')

0 commit comments

Comments
 (0)