Skip to content

Commit 344c37f

Browse files
authored
[11x.] Improved typehints for InteractsWithDatabase (#54748)
* InteractsWithDatabase typehints * InteractsWithDatabase typehints for data * HasInDatabase typehints
1 parent 0054c26 commit 344c37f

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ trait InteractsWithDatabase
1919
/**
2020
* Assert that a given where condition exists in the database.
2121
*
22-
* @param \Illuminate\Database\Eloquent\Model|string $table
23-
* @param array $data
22+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
23+
* @param array<string, mixed> $data
2424
* @param string|null $connection
2525
* @return $this
2626
*/
@@ -43,8 +43,8 @@ protected function assertDatabaseHas($table, array $data = [], $connection = nul
4343
/**
4444
* Assert that a given where condition does not exist in the database.
4545
*
46-
* @param \Illuminate\Database\Eloquent\Model|string $table
47-
* @param array $data
46+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
47+
* @param array<string, mixed> $data
4848
* @param string|null $connection
4949
* @return $this
5050
*/
@@ -69,7 +69,7 @@ protected function assertDatabaseMissing($table, array $data = [], $connection =
6969
/**
7070
* Assert the count of table entries.
7171
*
72-
* @param \Illuminate\Database\Eloquent\Model|string $table
72+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
7373
* @param int $count
7474
* @param string|null $connection
7575
* @return $this
@@ -86,7 +86,7 @@ protected function assertDatabaseCount($table, int $count, $connection = null)
8686
/**
8787
* Assert that the given table has no entries.
8888
*
89-
* @param \Illuminate\Database\Eloquent\Model|string $table
89+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
9090
* @param string|null $connection
9191
* @return $this
9292
*/
@@ -102,8 +102,8 @@ protected function assertDatabaseEmpty($table, $connection = null)
102102
/**
103103
* Assert the given record has been "soft deleted".
104104
*
105-
* @param \Illuminate\Database\Eloquent\Model|string $table
106-
* @param array $data
105+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
106+
* @param array<string, mixed> $data
107107
* @param string|null $connection
108108
* @param string|null $deletedAtColumn
109109
* @return $this
@@ -134,8 +134,8 @@ protected function assertSoftDeleted($table, array $data = [], $connection = nul
134134
/**
135135
* Assert the given record has not been "soft deleted".
136136
*
137-
* @param \Illuminate\Database\Eloquent\Model|string $table
138-
* @param array $data
137+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
138+
* @param array<string, mixed> $data
139139
* @param string|null $connection
140140
* @param string|null $deletedAtColumn
141141
* @return $this
@@ -166,7 +166,7 @@ protected function assertNotSoftDeleted($table, array $data = [], $connection =
166166
/**
167167
* Assert the given model exists in the database.
168168
*
169-
* @param \Illuminate\Database\Eloquent\Model $model
169+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $model
170170
* @return $this
171171
*/
172172
protected function assertModelExists($model)
@@ -177,7 +177,7 @@ protected function assertModelExists($model)
177177
/**
178178
* Assert the given model does not exist in the database.
179179
*
180-
* @param \Illuminate\Database\Eloquent\Model $model
180+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $model
181181
* @return $this
182182
*/
183183
protected function assertModelMissing($model)
@@ -255,7 +255,7 @@ public function castAsJson($value, $connection = null)
255255
* Get the database connection.
256256
*
257257
* @param string|null $connection
258-
* @param string|null $table
258+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
259259
* @return \Illuminate\Database\Connection
260260
*/
261261
protected function getConnection($connection = null, $table = null)
@@ -270,7 +270,7 @@ protected function getConnection($connection = null, $table = null)
270270
/**
271271
* Get the table name from the given model or string.
272272
*
273-
* @param \Illuminate\Database\Eloquent\Model|string $table
273+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
274274
* @return string
275275
*/
276276
protected function getTable($table)
@@ -285,7 +285,7 @@ protected function getTable($table)
285285
/**
286286
* Get the table connection specified in the given model.
287287
*
288-
* @param \Illuminate\Database\Eloquent\Model|string $table
288+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
289289
* @return string|null
290290
*/
291291
protected function getTableConnection($table)
@@ -300,7 +300,7 @@ protected function getTableConnection($table)
300300
/**
301301
* Get the table column name used for soft deletes.
302302
*
303-
* @param string $table
303+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
304304
* @param string $defaultColumnName
305305
* @return string
306306
*/
@@ -312,7 +312,7 @@ protected function getDeletedAtColumn($table, $defaultColumnName = 'deleted_at')
312312
/**
313313
* Get the model entity from the given model or string.
314314
*
315-
* @param \Illuminate\Database\Eloquent\Model|string $table
315+
* @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table
316316
* @return \Illuminate\Database\Eloquent\Model|null
317317
*/
318318
protected function newModelFor($table)
@@ -323,7 +323,7 @@ protected function newModelFor($table)
323323
/**
324324
* Seed a given database connection.
325325
*
326-
* @param array|string $class
326+
* @param list<string>|class-string<\Illuminate\Database\Seeder>|string $class
327327
* @return $this
328328
*/
329329
public function seed($class = 'Database\\Seeders\\DatabaseSeeder')

src/Illuminate/Testing/Constraints/HasInDatabase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ class HasInDatabase extends Constraint
2525
/**
2626
* The data that will be used to narrow the search in the database table.
2727
*
28-
* @var array
28+
* @var array<string, mixed>
2929
*/
3030
protected $data;
3131

3232
/**
3333
* Create a new constraint instance.
3434
*
3535
* @param \Illuminate\Database\Connection $database
36-
* @param array $data
36+
* @param array<string, mixed> $data
3737
* @return void
3838
*/
3939
public function __construct(Connection $database, array $data)

0 commit comments

Comments
 (0)