Skip to content

Commit

Permalink
Add explicit nullable type declaration (#50922)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jubeki authored Apr 4, 2024
1 parent 2f5898e commit e2ffa5a
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Capsule/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Manager
* @param \Illuminate\Container\Container|null $container
* @return void
*/
public function __construct(Container $container = null)
public function __construct(?Container $container = null)
{
$this->setupContainer($container ?: new Container);

Expand Down
6 changes: 3 additions & 3 deletions Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function withoutGlobalScope($scope)
* @param array|null $scopes
* @return $this
*/
public function withoutGlobalScopes(array $scopes = null)
public function withoutGlobalScopes(?array $scopes = null)
{
if (! is_array($scopes)) {
$scopes = array_keys($this->scopes);
Expand Down Expand Up @@ -524,7 +524,7 @@ public function findOrNew($id, $columns = ['*'])
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static[]|static|mixed
*/
public function findOr($id, $columns = ['*'], Closure $callback = null)
public function findOr($id, $columns = ['*'], ?Closure $callback = null)
{
if ($columns instanceof Closure) {
$callback = $columns;
Expand Down Expand Up @@ -627,7 +627,7 @@ public function firstOrFail($columns = ['*'])
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Model|static|mixed
*/
public function firstOr($columns = ['*'], Closure $callback = null)
public function firstOr($columns = ['*'], ?Closure $callback = null)
{
if ($columns instanceof Closure) {
$callback = $columns;
Expand Down
4 changes: 2 additions & 2 deletions Eloquent/Casts/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Attribute
* @param callable|null $set
* @return void
*/
public function __construct(callable $get = null, callable $set = null)
public function __construct(?callable $get = null, ?callable $set = null)
{
$this->get = $get;
$this->set = $set;
Expand All @@ -52,7 +52,7 @@ public function __construct(callable $get = null, callable $set = null)
* @param callable|null $set
* @return static
*/
public static function make(callable $get = null, callable $set = null): static
public static function make(?callable $get = null, ?callable $set = null): static
{
return new static($get, $set);
}
Expand Down
26 changes: 13 additions & 13 deletions Eloquent/Concerns/QueriesRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait QueriesRelationships
*
* @throws \RuntimeException
*/
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', ?Closure $callback = null)
{
if (is_string($relation)) {
if (str_contains($relation, '.')) {
Expand Down Expand Up @@ -122,7 +122,7 @@ public function orHas($relation, $operator = '>=', $count = 1)
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function doesntHave($relation, $boolean = 'and', Closure $callback = null)
public function doesntHave($relation, $boolean = 'and', ?Closure $callback = null)
{
return $this->has($relation, '<', 1, $boolean, $callback);
}
Expand All @@ -147,7 +147,7 @@ public function orDoesntHave($relation)
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function whereHas($relation, Closure $callback = null, $operator = '>=', $count = 1)
public function whereHas($relation, ?Closure $callback = null, $operator = '>=', $count = 1)
{
return $this->has($relation, $operator, $count, 'and', $callback);
}
Expand All @@ -163,7 +163,7 @@ public function whereHas($relation, Closure $callback = null, $operator = '>=',
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function withWhereHas($relation, Closure $callback = null, $operator = '>=', $count = 1)
public function withWhereHas($relation, ?Closure $callback = null, $operator = '>=', $count = 1)
{
return $this->whereHas(Str::before($relation, ':'), $callback, $operator, $count)
->with($callback ? [$relation => fn ($query) => $callback($query)] : $relation);
Expand All @@ -178,7 +178,7 @@ public function withWhereHas($relation, Closure $callback = null, $operator = '>
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function orWhereHas($relation, Closure $callback = null, $operator = '>=', $count = 1)
public function orWhereHas($relation, ?Closure $callback = null, $operator = '>=', $count = 1)
{
return $this->has($relation, $operator, $count, 'or', $callback);
}
Expand All @@ -190,7 +190,7 @@ public function orWhereHas($relation, Closure $callback = null, $operator = '>='
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function whereDoesntHave($relation, Closure $callback = null)
public function whereDoesntHave($relation, ?Closure $callback = null)
{
return $this->doesntHave($relation, 'and', $callback);
}
Expand All @@ -202,7 +202,7 @@ public function whereDoesntHave($relation, Closure $callback = null)
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function orWhereDoesntHave($relation, Closure $callback = null)
public function orWhereDoesntHave($relation, ?Closure $callback = null)
{
return $this->doesntHave($relation, 'or', $callback);
}
Expand All @@ -218,7 +218,7 @@ public function orWhereDoesntHave($relation, Closure $callback = null)
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boolean = 'and', ?Closure $callback = null)
{
if (is_string($relation)) {
$relation = $this->getRelationWithoutConstraints($relation);
Expand Down Expand Up @@ -301,7 +301,7 @@ public function orHasMorph($relation, $types, $operator = '>=', $count = 1)
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function doesntHaveMorph($relation, $types, $boolean = 'and', Closure $callback = null)
public function doesntHaveMorph($relation, $types, $boolean = 'and', ?Closure $callback = null)
{
return $this->hasMorph($relation, $types, '<', 1, $boolean, $callback);
}
Expand All @@ -328,7 +328,7 @@ public function orDoesntHaveMorph($relation, $types)
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function whereHasMorph($relation, $types, Closure $callback = null, $operator = '>=', $count = 1)
public function whereHasMorph($relation, $types, ?Closure $callback = null, $operator = '>=', $count = 1)
{
return $this->hasMorph($relation, $types, $operator, $count, 'and', $callback);
}
Expand All @@ -343,7 +343,7 @@ public function whereHasMorph($relation, $types, Closure $callback = null, $oper
* @param int $count
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function orWhereHasMorph($relation, $types, Closure $callback = null, $operator = '>=', $count = 1)
public function orWhereHasMorph($relation, $types, ?Closure $callback = null, $operator = '>=', $count = 1)
{
return $this->hasMorph($relation, $types, $operator, $count, 'or', $callback);
}
Expand All @@ -356,7 +356,7 @@ public function orWhereHasMorph($relation, $types, Closure $callback = null, $op
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function whereDoesntHaveMorph($relation, $types, Closure $callback = null)
public function whereDoesntHaveMorph($relation, $types, ?Closure $callback = null)
{
return $this->doesntHaveMorph($relation, $types, 'and', $callback);
}
Expand All @@ -369,7 +369,7 @@ public function whereDoesntHaveMorph($relation, $types, Closure $callback = null
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function orWhereDoesntHaveMorph($relation, $types, Closure $callback = null)
public function orWhereDoesntHaveMorph($relation, $types, ?Closure $callback = null)
{
return $this->doesntHaveMorph($relation, $types, 'or', $callback);
}
Expand Down
4 changes: 2 additions & 2 deletions Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ public function refresh()
* @param array|null $except
* @return static
*/
public function replicate(array $except = null)
public function replicate(?array $except = null)
{
$defaults = array_values(array_filter([
$this->getKeyName(),
Expand Down Expand Up @@ -1750,7 +1750,7 @@ public function replicate(array $except = null)
* @param array|null $except
* @return static
*/
public function replicateQuietly(array $except = null)
public function replicateQuietly(?array $except = null)
{
return static::withoutEvents(fn () => $this->replicate($except));
}
Expand Down
4 changes: 2 additions & 2 deletions Eloquent/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ public function findOrFail($id, $columns = ['*'])
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|mixed
*/
public function findOr($id, $columns = ['*'], Closure $callback = null)
public function findOr($id, $columns = ['*'], ?Closure $callback = null)
{
if ($columns instanceof Closure) {
$callback = $columns;
Expand Down Expand Up @@ -828,7 +828,7 @@ public function firstOrFail($columns = ['*'])
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Model|static|mixed
*/
public function firstOr($columns = ['*'], Closure $callback = null)
public function firstOr($columns = ['*'], ?Closure $callback = null)
{
if ($columns instanceof Closure) {
$callback = $columns;
Expand Down
6 changes: 3 additions & 3 deletions Eloquent/Relations/HasManyThrough.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function addConstraints()
* @param \Illuminate\Database\Eloquent\Builder|null $query
* @return void
*/
protected function performJoin(Builder $query = null)
protected function performJoin(?Builder $query = null)
{
$query = $query ?: $this->query;

Expand Down Expand Up @@ -364,7 +364,7 @@ public function firstOrFail($columns = ['*'])
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Model|static|mixed
*/
public function firstOr($columns = ['*'], Closure $callback = null)
public function firstOr($columns = ['*'], ?Closure $callback = null)
{
if ($columns instanceof Closure) {
$callback = $columns;
Expand Down Expand Up @@ -451,7 +451,7 @@ public function findOrFail($id, $columns = ['*'])
* @param \Closure|null $callback
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|mixed
*/
public function findOr($id, $columns = ['*'], Closure $callback = null)
public function findOr($id, $columns = ['*'], ?Closure $callback = null)
{
if ($columns instanceof Closure) {
$callback = $columns;
Expand Down
4 changes: 2 additions & 2 deletions Eloquent/Relations/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public static function enforceMorphMap(array $map, $merge = true)
* @param bool $merge
* @return array
*/
public static function morphMap(array $map = null, $merge = true)
public static function morphMap(?array $map = null, $merge = true)
{
$map = static::buildMorphMapFromModels($map);

Expand All @@ -479,7 +479,7 @@ public static function morphMap(array $map = null, $merge = true)
* @param string[]|null $models
* @return array|null
*/
protected static function buildMorphMapFromModels(array $models = null)
protected static function buildMorphMapFromModels(?array $models = null)
{
if (is_null($models) || ! array_is_list($models)) {
return $models;
Expand Down
2 changes: 1 addition & 1 deletion MariaDbConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function getDefaultSchemaGrammar()
* @param callable|null $processFactory
* @return \Illuminate\Database\Schema\MariaDbSchemaState
*/
public function getSchemaState(Filesystem $files = null, callable $processFactory = null)
public function getSchemaState(?Filesystem $files = null, ?callable $processFactory = null)
{
return new MariaDbSchemaState($this, $files, $processFactory);
}
Expand Down
2 changes: 1 addition & 1 deletion Migrations/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Migrator
public function __construct(MigrationRepositoryInterface $repository,
Resolver $resolver,
Filesystem $files,
Dispatcher $dispatcher = null)
?Dispatcher $dispatcher = null)
{
$this->files = $files;
$this->events = $dispatcher;
Expand Down
2 changes: 1 addition & 1 deletion MySqlConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function getDefaultSchemaGrammar()
* @param callable|null $processFactory
* @return \Illuminate\Database\Schema\MySqlSchemaState
*/
public function getSchemaState(Filesystem $files = null, callable $processFactory = null)
public function getSchemaState(?Filesystem $files = null, ?callable $processFactory = null)
{
return new MySqlSchemaState($this, $files, $processFactory);
}
Expand Down
2 changes: 1 addition & 1 deletion PostgresConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function getDefaultSchemaGrammar()
* @param callable|null $processFactory
* @return \Illuminate\Database\Schema\PostgresSchemaState
*/
public function getSchemaState(Filesystem $files = null, callable $processFactory = null)
public function getSchemaState(?Filesystem $files = null, ?callable $processFactory = null)
{
return new PostgresSchemaState($this, $files, $processFactory);
}
Expand Down
6 changes: 3 additions & 3 deletions Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ class Builder implements BuilderContract
* @return void
*/
public function __construct(ConnectionInterface $connection,
Grammar $grammar = null,
Processor $processor = null)
?Grammar $grammar = null,
?Processor $processor = null)
{
$this->connection = $connection;
$this->grammar = $grammar ?: $connection->getQueryGrammar();
Expand Down Expand Up @@ -2814,7 +2814,7 @@ public function find($id, $columns = ['*'])
* @param \Closure|null $callback
* @return mixed|static
*/
public function findOr($id, $columns = ['*'], Closure $callback = null)
public function findOr($id, $columns = ['*'], ?Closure $callback = null)
{
if ($columns instanceof Closure) {
$callback = $columns;
Expand Down
2 changes: 1 addition & 1 deletion SQLiteConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function getDefaultSchemaGrammar()
*
* @throws \RuntimeException
*/
public function getSchemaState(Filesystem $files = null, callable $processFactory = null)
public function getSchemaState(?Filesystem $files = null, ?callable $processFactory = null)
{
return new SqliteSchemaState($this, $files, $processFactory);
}
Expand Down
2 changes: 1 addition & 1 deletion Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Blueprint
* @param string $prefix
* @return void
*/
public function __construct($table, Closure $callback = null, $prefix = '')
public function __construct($table, ?Closure $callback = null, $prefix = '')
{
$this->table = $table;
$this->prefix = $prefix;
Expand Down
2 changes: 1 addition & 1 deletion Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ protected function build(Blueprint $blueprint)
* @param \Closure|null $callback
* @return \Illuminate\Database\Schema\Blueprint
*/
protected function createBlueprint($table, Closure $callback = null)
protected function createBlueprint($table, ?Closure $callback = null)
{
$prefix = $this->connection->getConfig('prefix_indexes')
? $this->connection->getConfig('prefix')
Expand Down
2 changes: 1 addition & 1 deletion Schema/SchemaState.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class SchemaState
* @param callable|null $processFactory
* @return void
*/
public function __construct(Connection $connection, Filesystem $files = null, callable $processFactory = null)
public function __construct(Connection $connection, ?Filesystem $files = null, ?callable $processFactory = null)
{
$this->connection = $connection;

Expand Down
2 changes: 1 addition & 1 deletion SqlServerConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function getDefaultSchemaGrammar()
*
* @throws \RuntimeException
*/
public function getSchemaState(Filesystem $files = null, callable $processFactory = null)
public function getSchemaState(?Filesystem $files = null, ?callable $processFactory = null)
{
throw new RuntimeException('Schema dumping is not supported when using SQL Server.');
}
Expand Down

0 comments on commit e2ffa5a

Please sign in to comment.