Skip to content

PHPORM-146: Add override attribute everywhere #3412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Bus/MongoBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public function prune(DateTimeInterface $before): int
}

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

/** Prune all the cancelled entries older than the given date. */
#[Override]
public function pruneCancelled(DateTimeInterface $before): int
{
$result = $this->collection->deleteMany(
Expand Down
1 change: 1 addition & 0 deletions src/Cache/MongoLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function __construct(
/**
* Attempt to acquire the lock.
*/
#[Override]
public function acquire(): bool
{
// The lock can be acquired if: it doesn't exist, it has expired,
Expand Down
4 changes: 4 additions & 0 deletions src/CommandSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use MongoDB\Driver\Monitoring\CommandStartedEvent;
use MongoDB\Driver\Monitoring\CommandSubscriber as CommandSubscriberInterface;
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
use Override;

use function get_object_vars;
use function in_array;
Expand All @@ -21,16 +22,19 @@ public function __construct(private Connection $connection)
{
}

#[Override]
public function commandStarted(CommandStartedEvent $event): void
{
$this->commands[$event->getOperationId()] = $event;
}

#[Override]
public function commandFailed(CommandFailedEvent $event): void
{
$this->logQuery($event);
}

#[Override]
public function commandSucceeded(CommandSucceededEvent $event): void
{
$this->logQuery($event);
Expand Down
11 changes: 11 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use MongoDB\Driver\ReadPreference;
use MongoDB\Laravel\Concerns\ManagesTransactions;
use OutOfBoundsException;
use Override;
use Throwable;

use function filter_var;
Expand Down Expand Up @@ -95,6 +96,7 @@ public function __construct(array $config)
*
* @return Query\Builder
*/
#[Override]
public function table($table, $as = null)
{
$query = new Query\Builder($this, $this->getQueryGrammar(), $this->getPostProcessor());
Expand All @@ -115,6 +117,7 @@ public function getCollection($name): Collection
}

/** @inheritdoc */
#[Override]
public function getSchemaBuilder()
{
return new Schema\Builder($this);
Expand Down Expand Up @@ -172,6 +175,8 @@ public function getClient(): ?Client
return $this->connection;
}

/** @inheritdoc */
#[Override]
public function enableQueryLog()
{
parent::enableQueryLog();
Expand All @@ -182,6 +187,7 @@ public function enableQueryLog()
}
}

#[Override]
public function disableQueryLog()
{
parent::disableQueryLog();
Expand All @@ -192,6 +198,7 @@ public function disableQueryLog()
}
}

#[Override]
protected function withFreshQueryLog($callback)
{
try {
Expand Down Expand Up @@ -340,6 +347,7 @@ protected function getDsn(array $config): string
}

/** @inheritdoc */
#[Override]
public function getDriverName()
{
return 'mongodb';
Expand All @@ -352,19 +360,22 @@ public function getDriverTitle()
}

/** @inheritdoc */
#[Override]
protected function getDefaultPostProcessor()
{
return new Query\Processor();
}

/** @inheritdoc */
#[Override]
protected function getDefaultQueryGrammar()
{
// Argument added in Laravel 12
return new Query\Grammar($this);
}

/** @inheritdoc */
#[Override]
protected function getDefaultSchemaGrammar()
{
// Argument added in Laravel 12
Expand Down
14 changes: 11 additions & 3 deletions src/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use MongoDB\Laravel\Helpers\QueriesRelationships;
use MongoDB\Laravel\Query\AggregationBuilder;
use MongoDB\Model\BSONDocument;
use Override;

use function array_key_exists;
use function array_map;
Expand Down Expand Up @@ -127,7 +128,12 @@ public function vectorSearch(
return $this->model->hydrate($results->all());
}

/** @inheritdoc */
/**
* @param array $options
*
* @inheritdoc
*/
#[Override]
public function update(array $values, array $options = [])
{
// Intercept operations on embedded models and delegate logic
Expand Down Expand Up @@ -270,6 +276,7 @@ public function raw($value = null)
return $results;
}

#[Override]
public function firstOrCreate(array $attributes = [], array $values = [])
{
$instance = (clone $this)->where($attributes)->first();
Expand All @@ -285,6 +292,7 @@ public function firstOrCreate(array $attributes = [], array $values = [])
return $this->createOrFirst($attributes, $values);
}

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

/** @inheritdoc */
#[Override]
protected function ensureOrderForCursorPagination($shouldReverse = false)
{
if (empty($this->query->orders)) {
Expand Down
4 changes: 4 additions & 0 deletions src/MongoDBBusServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
use MongoDB\Laravel\Bus\MongoBatchRepository;
use Override;

use function sprintf;

Expand All @@ -18,6 +19,7 @@ class MongoDBBusServiceProvider extends ServiceProvider implements DeferrablePro
/**
* Register the service provider.
*/
#[Override]
public function register()
{
$this->app->singleton(MongoBatchRepository::class, function (Container $app) {
Expand Down Expand Up @@ -46,6 +48,8 @@ public function register()
});
}

/** @inheritdoc */
#[Override]
public function provides()
{
return [
Expand Down
2 changes: 2 additions & 0 deletions src/MongoDBServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use MongoDB\Laravel\Queue\MongoConnector;
use MongoDB\Laravel\Scout\ScoutEngine;
use MongoDB\Laravel\Session\MongoDbSessionHandler;
use Override;
use RuntimeException;

use function assert;
Expand All @@ -47,6 +48,7 @@ public function boot()
/**
* Register the service provider.
*/
#[Override]
public function register()
{
// Add database driver.
Expand Down
Loading
Loading