Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 63da42c

Browse files
PHPORM-146: Add override attribute everywhere (#3412)
* Add `#[Override]` attributes to `Query\Builder` to keep track of the methods we're overriding on the base builder * Add `#[Override]` attribute to `MongoBatchRepository` * Add `#[Override]` attribute to `MongoLock` * Add attribute to Eloquent builder * Add `#[Override]` attribute to `MongoQueue` * Add `#[Override]` attribute to relationship classes * Add `#[Override]` attribute to `Schema` namespace classes * Add attribute to session handler * Add `#[Override]` attribute to Validation namespace * Add `#[Override]` attribute to `CommandSubscriber` * Add `#[Override] attribute to `Connection` * Add `#[Override]` attribute to `ServiceProvider` implementations
1 parent 08d21aa commit 63da42c

22 files changed

+208
-80
lines changed

‎src/Bus/MongoBatchRepository.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ public function prune(DateTimeInterface $before): int
216216
}
217217

218218
/** Prune all the unfinished entries older than the given date. */
219+
#[Override]
219220
public function pruneUnfinished(DateTimeInterface $before): int
220221
{
221222
$result = $this->collection->deleteMany(
@@ -229,6 +230,7 @@ public function pruneUnfinished(DateTimeInterface $before): int
229230
}
230231

231232
/** Prune all the cancelled entries older than the given date. */
233+
#[Override]
232234
public function pruneCancelled(DateTimeInterface $before): int
233235
{
234236
$result = $this->collection->deleteMany(

‎src/Cache/MongoLock.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function __construct(
4141
/**
4242
* Attempt to acquire the lock.
4343
*/
44+
#[Override]
4445
public function acquire(): bool
4546
{
4647
// The lock can be acquired if: it doesn't exist, it has expired,

‎src/CommandSubscriber.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use MongoDB\Driver\Monitoring\CommandStartedEvent;
88
use MongoDB\Driver\Monitoring\CommandSubscriber as CommandSubscriberInterface;
99
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
10+
use Override;
1011

1112
use function get_object_vars;
1213
use function in_array;
@@ -21,16 +22,19 @@ public function __construct(private Connection $connection)
2122
{
2223
}
2324

25+
#[Override]
2426
public function commandStarted(CommandStartedEvent $event): void
2527
{
2628
$this->commands[$event->getOperationId()] = $event;
2729
}
2830

31+
#[Override]
2932
public function commandFailed(CommandFailedEvent $event): void
3033
{
3134
$this->logQuery($event);
3235
}
3336

37+
#[Override]
3438
public function commandSucceeded(CommandSucceededEvent $event): void
3539
{
3640
$this->logQuery($event);

‎src/Connection.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use MongoDB\Driver\ReadPreference;
1717
use MongoDB\Laravel\Concerns\ManagesTransactions;
1818
use OutOfBoundsException;
19+
use Override;
1920
use Throwable;
2021

2122
use function filter_var;
@@ -95,6 +96,7 @@ public function __construct(array $config)
9596
*
9697
* @return Query\Builder
9798
*/
99+
#[Override]
98100
public function table($table, $as = null)
99101
{
100102
$query = new Query\Builder($this, $this->getQueryGrammar(), $this->getPostProcessor());
@@ -115,6 +117,7 @@ public function getCollection($name): Collection
115117
}
116118

117119
/** @inheritdoc */
120+
#[Override]
118121
public function getSchemaBuilder()
119122
{
120123
return new Schema\Builder($this);
@@ -172,6 +175,8 @@ public function getClient(): ?Client
172175
return $this->connection;
173176
}
174177

178+
/** @inheritdoc */
179+
#[Override]
175180
public function enableQueryLog()
176181
{
177182
parent::enableQueryLog();
@@ -182,6 +187,7 @@ public function enableQueryLog()
182187
}
183188
}
184189

190+
#[Override]
185191
public function disableQueryLog()
186192
{
187193
parent::disableQueryLog();
@@ -192,6 +198,7 @@ public function disableQueryLog()
192198
}
193199
}
194200

201+
#[Override]
195202
protected function withFreshQueryLog($callback)
196203
{
197204
try {
@@ -340,6 +347,7 @@ protected function getDsn(array $config): string
340347
}
341348

342349
/** @inheritdoc */
350+
#[Override]
343351
public function getDriverName()
344352
{
345353
return 'mongodb';
@@ -352,19 +360,22 @@ public function getDriverTitle()
352360
}
353361

354362
/** @inheritdoc */
363+
#[Override]
355364
protected function getDefaultPostProcessor()
356365
{
357366
return new Query\Processor();
358367
}
359368

360369
/** @inheritdoc */
370+
#[Override]
361371
protected function getDefaultQueryGrammar()
362372
{
363373
// Argument added in Laravel 12
364374
return new Query\Grammar($this);
365375
}
366376

367377
/** @inheritdoc */
378+
#[Override]
368379
protected function getDefaultSchemaGrammar()
369380
{
370381
// Argument added in Laravel 12

‎src/Eloquent/Builder.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use MongoDB\Laravel\Helpers\QueriesRelationships;
1919
use MongoDB\Laravel\Query\AggregationBuilder;
2020
use MongoDB\Model\BSONDocument;
21+
use Override;
2122

2223
use function array_key_exists;
2324
use function array_map;
@@ -127,7 +128,12 @@ public function vectorSearch(
127128
return $this->model->hydrate($results->all());
128129
}
129130

130-
/** @inheritdoc */
131+
/**
132+
* @param array $options
133+
*
134+
* @inheritdoc
135+
*/
136+
#[Override]
131137
public function update(array $values, array $options = [])
132138
{
133139
// Intercept operations on embedded models and delegate logic
@@ -270,6 +276,7 @@ public function raw($value = null)
270276
return $results;
271277
}
272278

279+
#[Override]
273280
public function firstOrCreate(array $attributes = [], array $values = [])
274281
{
275282
$instance = (clone $this)->where($attributes)->first();
@@ -285,6 +292,7 @@ public function firstOrCreate(array $attributes = [], array $values = [])
285292
return $this->createOrFirst($attributes, $values);
286293
}
287294

295+
#[Override]
288296
public function createOrFirst(array $attributes = [], array $values = [])
289297
{
290298
// The duplicate key error would abort the transaction. Using the regular firstOrCreate in that case.
@@ -308,9 +316,8 @@ public function createOrFirst(array $attributes = [], array $values = [])
308316
* TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e
309317
* will be reverted
310318
* Issue in laravel/frawework https://github.com/laravel/framework/issues/27791.
311-
*
312-
* @return array
313319
*/
320+
#[Override]
314321
protected function addUpdatedAtColumn(array $values)
315322
{
316323
if (! $this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) {
@@ -332,6 +339,7 @@ public function getConnection(): Connection
332339
}
333340

334341
/** @inheritdoc */
342+
#[Override]
335343
protected function ensureOrderForCursorPagination($shouldReverse = false)
336344
{
337345
if (empty($this->query->orders)) {

‎src/MongoDBBusServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Support\ServiceProvider;
1111
use InvalidArgumentException;
1212
use MongoDB\Laravel\Bus\MongoBatchRepository;
13+
use Override;
1314

1415
use function sprintf;
1516

@@ -18,6 +19,7 @@ class MongoDBBusServiceProvider extends ServiceProvider implements DeferrablePro
1819
/**
1920
* Register the service provider.
2021
*/
22+
#[Override]
2123
public function register()
2224
{
2325
$this->app->singleton(MongoBatchRepository::class, function (Container $app) {
@@ -46,6 +48,8 @@ public function register()
4648
});
4749
}
4850

51+
/** @inheritdoc */
52+
#[Override]
4953
public function provides()
5054
{
5155
return [

‎src/MongoDBServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use MongoDB\Laravel\Queue\MongoConnector;
2525
use MongoDB\Laravel\Scout\ScoutEngine;
2626
use MongoDB\Laravel\Session\MongoDbSessionHandler;
27+
use Override;
2728
use RuntimeException;
2829

2930
use function assert;
@@ -47,6 +48,7 @@ public function boot()
4748
/**
4849
* Register the service provider.
4950
*/
51+
#[Override]
5052
public function register()
5153
{
5254
// Add database driver.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /