Skip to content

Commit f876a35

Browse files
committed
Add #[Override] attribute to Schema namespace classes
1 parent ff1657c commit f876a35

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

src/Schema/Blueprint.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Database\Schema\Blueprint as BaseBlueprint;
88
use MongoDB\Collection;
99
use MongoDB\Laravel\Connection;
10+
use Override;
1011

1112
use function array_flip;
1213
use function array_merge;
@@ -38,6 +39,7 @@ class Blueprint extends BaseBlueprint
3839
protected $columns = [];
3940

4041
/** @inheritdoc */
42+
#[Override]
4143
public function index($columns = null, $name = null, $algorithm = null, $options = [])
4244
{
4345
$columns = $this->fluent($columns);
@@ -64,12 +66,14 @@ public function index($columns = null, $name = null, $algorithm = null, $options
6466
}
6567

6668
/** @inheritdoc */
69+
#[Override]
6770
public function primary($columns = null, $name = null, $algorithm = null, $options = [])
6871
{
6972
return $this->unique($columns, $name, $algorithm, $options);
7073
}
7174

7275
/** @inheritdoc */
76+
#[Override]
7377
public function dropIndex($index = null)
7478
{
7579
$index = $this->transformColumns($index);
@@ -170,6 +174,7 @@ protected function transformColumns($indexOrColumns)
170174
}
171175

172176
/** @inheritdoc */
177+
#[Override]
173178
public function unique($columns = null, $name = null, $algorithm = null, $options = [])
174179
{
175180
$columns = $this->fluent($columns);
@@ -251,6 +256,7 @@ public function expire($columns, $seconds)
251256
*
252257
* @return void
253258
*/
259+
#[Override]
254260
public function create($options = [])
255261
{
256262
$collection = $this->collection->getCollectionName();
@@ -262,6 +268,7 @@ public function create($options = [])
262268
}
263269

264270
/** @inheritdoc */
271+
#[Override]
265272
public function drop()
266273
{
267274
$this->collection->drop();
@@ -270,6 +277,7 @@ public function drop()
270277
}
271278

272279
/** @inheritdoc */
280+
#[Override]
273281
public function renameColumn($from, $to)
274282
{
275283
$this->collection->updateMany([$from => ['$exists' => true]], ['$rename' => [$from => $to]]);
@@ -278,6 +286,7 @@ public function renameColumn($from, $to)
278286
}
279287

280288
/** @inheritdoc */
289+
#[Override]
281290
public function addColumn($type, $name, array $parameters = [])
282291
{
283292
$this->fluent($name);

src/Schema/Builder.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
use Closure;
88
use MongoDB\Collection;
9-
use MongoDB\Database;
109
use MongoDB\Driver\Exception\ServerException;
1110
use MongoDB\Laravel\Connection;
1211
use MongoDB\Model\CollectionInfo;
1312
use MongoDB\Model\IndexInfo;
13+
use Override;
1414

1515
use function array_column;
1616
use function array_fill_keys;
@@ -99,12 +99,14 @@ public function hasCollection($name)
9999
}
100100

101101
/** @inheritdoc */
102+
#[Override]
102103
public function hasTable($table)
103104
{
104105
return $this->hasCollection($table);
105106
}
106107

107108
/** @inheritdoc */
109+
#[Override]
108110
public function table($table, Closure $callback)
109111
{
110112
$blueprint = $this->createBlueprint($table);
@@ -115,6 +117,7 @@ public function table($table, Closure $callback)
115117
}
116118

117119
/** @inheritdoc */
120+
#[Override]
118121
public function create($table, ?Closure $callback = null, array $options = [])
119122
{
120123
$blueprint = $this->createBlueprint($table);
@@ -127,6 +130,7 @@ public function create($table, ?Closure $callback = null, array $options = [])
127130
}
128131

129132
/** @inheritdoc */
133+
#[Override]
130134
public function dropIfExists($table)
131135
{
132136
if ($this->hasCollection($table)) {
@@ -135,6 +139,7 @@ public function dropIfExists($table)
135139
}
136140

137141
/** @inheritdoc */
142+
#[Override]
138143
public function drop($table)
139144
{
140145
$blueprint = $this->createBlueprint($table);
@@ -151,18 +156,29 @@ public function drop($table)
151156
* one by one. The database will be automatically recreated when a new connection
152157
* writes to it.
153158
*/
159+
#[Override]
154160
public function dropAllTables()
155161
{
156162
$this->connection->getDatabase()->drop();
157163
}
158164

159-
/** @param string|null $schema Database name */
165+
/**
166+
* @param string|null $schema Database name
167+
*
168+
* @inheritdoc
169+
*/
170+
#[Override]
160171
public function getTables($schema = null)
161172
{
162173
return $this->getCollectionRows('collection', $schema);
163174
}
164175

165-
/** @param string|null $schema Database name */
176+
/**
177+
* @param string|null $schema Database name
178+
*
179+
* @inheritdoc
180+
*/
181+
#[Override]
166182
public function getViews($schema = null)
167183
{
168184
return $this->getCollectionRows('view', $schema);
@@ -174,6 +190,7 @@ public function getViews($schema = null)
174190
*
175191
* @return array
176192
*/
193+
#[Override]
177194
public function getTableListing($schema = null, $schemaQualified = false)
178195
{
179196
$collections = [];
@@ -197,6 +214,7 @@ public function getTableListing($schema = null, $schemaQualified = false)
197214
return $collections;
198215
}
199216

217+
#[Override]
200218
public function getColumns($table)
201219
{
202220
$db = null;
@@ -255,6 +273,7 @@ public function getColumns($table)
255273
return $columns;
256274
}
257275

276+
#[Override]
258277
public function getIndexes($table)
259278
{
260279
$collection = $this->connection->getDatabase()->selectCollection($table);
@@ -309,12 +328,18 @@ public function getIndexes($table)
309328
return $indexList;
310329
}
311330

331+
#[Override]
312332
public function getForeignKeys($table)
313333
{
314334
return [];
315335
}
316336

317-
/** @inheritdoc */
337+
/**
338+
* @return Blueprint
339+
*
340+
* @inheritdoc
341+
*/
342+
#[Override]
318343
protected function createBlueprint($table, ?Closure $callback = null)
319344
{
320345
return new Blueprint($this->connection, $table);

0 commit comments

Comments
 (0)