Skip to content

Commit 099a3b6

Browse files
committed
Add #[Override] attributes to Query\Builder
to keep track of the methods we're overriding on the base builder
1 parent 6f9bc38 commit 099a3b6

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

src/Query/Builder.php

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,14 @@ public function hint($index)
243243
}
244244

245245
/** @inheritdoc */
246+
#[Override]
246247
public function find($id, $columns = [])
247248
{
248249
return $this->where('_id', '=', $this->convertKey($id))->first($columns);
249250
}
250251

251252
/** @inheritdoc */
253+
#[Override]
252254
public function value($column)
253255
{
254256
$result = (array) $this->first([$column]);
@@ -257,12 +259,14 @@ public function value($column)
257259
}
258260

259261
/** @inheritdoc */
262+
#[Override]
260263
public function get($columns = [])
261264
{
262265
return $this->getFresh($columns);
263266
}
264267

265268
/** @inheritdoc */
269+
#[Override]
266270
public function cursor($columns = [])
267271
{
268272
$result = $this->getFresh($columns, true);
@@ -579,6 +583,7 @@ public function generateCacheKey()
579583
}
580584

581585
/** @return ($function is null ? AggregationBuilder : mixed) */
586+
#[Override]
582587
public function aggregate($function = null, $columns = ['*'])
583588
{
584589
assert(is_array($columns), new TypeError(sprintf('Argument #2 ($columns) must be of type array, %s given', get_debug_type($columns))));
@@ -640,9 +645,10 @@ public function aggregate($function = null, $columns = ['*'])
640645
}
641646

642647
/**
643-
* {@inheritDoc}
648+
* @param string $function
649+
* @param array $columns
644650
*
645-
* @see \Illuminate\Database\Query\Builder::aggregateByGroup()
651+
* @return mixed
646652
*/
647653
public function aggregateByGroup(string $function, array $columns = ['*'])
648654
{
@@ -654,6 +660,7 @@ public function aggregateByGroup(string $function, array $columns = ['*'])
654660
}
655661

656662
/** @inheritdoc */
663+
#[Override]
657664
public function exists()
658665
{
659666
return $this->first(['id']) !== null;
@@ -676,6 +683,7 @@ public function distinct($column = false)
676683
*
677684
* @inheritdoc
678685
*/
686+
#[Override]
679687
public function orderBy($column, $direction = 'asc')
680688
{
681689
if (is_string($direction)) {
@@ -697,6 +705,7 @@ public function orderBy($column, $direction = 'asc')
697705
}
698706

699707
/** @inheritdoc */
708+
#[Override]
700709
public function whereBetween($column, iterable $values, $boolean = 'and', $not = false)
701710
{
702711
$type = 'between';
@@ -721,6 +730,7 @@ public function whereBetween($column, iterable $values, $boolean = 'and', $not =
721730
}
722731

723732
/** @inheritdoc */
733+
#[Override]
724734
public function insert(array $values)
725735
{
726736
// Allow empty insert batch for consistency with Eloquent SQL
@@ -755,6 +765,7 @@ public function insert(array $values)
755765
}
756766

757767
/** @inheritdoc */
768+
#[Override]
758769
public function insertGetId(array $values, $sequence = null)
759770
{
760771
$options = $this->inheritConnectionOptions();
@@ -774,6 +785,7 @@ public function insertGetId(array $values, $sequence = null)
774785
}
775786

776787
/** @inheritdoc */
788+
#[Override]
777789
public function update(array $values, array $options = [])
778790
{
779791
// Use $set as default operator for field names that are not in an operator
@@ -790,6 +802,7 @@ public function update(array $values, array $options = [])
790802
}
791803

792804
/** @inheritdoc */
805+
#[Override]
793806
public function upsert(array $values, $uniqueBy, $update = null): int
794807
{
795808
if ($values === []) {
@@ -836,6 +849,7 @@ public function upsert(array $values, $uniqueBy, $update = null): int
836849
}
837850

838851
/** @inheritdoc */
852+
#[Override]
839853
public function increment($column, $amount = 1, array $extra = [], array $options = [])
840854
{
841855
$query = ['$inc' => [(string) $column => $amount]];
@@ -856,6 +870,12 @@ public function increment($column, $amount = 1, array $extra = [], array $option
856870
return $this->performUpdate($query, $options);
857871
}
858872

873+
/**
874+
* @param array $options
875+
*
876+
* @inheritdoc
877+
*/
878+
#[Override]
859879
public function incrementEach(array $columns, array $extra = [], array $options = [])
860880
{
861881
$stage['$addFields'] = $extra;
@@ -873,12 +893,14 @@ public function incrementEach(array $columns, array $extra = [], array $options
873893
}
874894

875895
/** @inheritdoc */
896+
#[Override]
876897
public function decrement($column, $amount = 1, array $extra = [], array $options = [])
877898
{
878899
return $this->increment($column, -1 * $amount, $extra, $options);
879900
}
880901

881902
/** @inheritdoc */
903+
#[Override]
882904
public function decrementEach(array $columns, array $extra = [], array $options = [])
883905
{
884906
$decrement = [];
@@ -932,6 +954,7 @@ public function divide($column, $amount, array $extra = [], array $options = [])
932954
}
933955

934956
/** @inheritdoc */
957+
#[Override]
935958
public function pluck($column, $key = null)
936959
{
937960
$results = $this->get($key === null ? [$column] : [$column, $key]);
@@ -942,6 +965,7 @@ public function pluck($column, $key = null)
942965
}
943966

944967
/** @inheritdoc */
968+
#[Override]
945969
public function delete($id = null)
946970
{
947971
// If an ID is passed to the method, we will set the where clause to check
@@ -973,6 +997,7 @@ public function delete($id = null)
973997
}
974998

975999
/** @inheritdoc */
1000+
#[Override]
9761001
public function from($collection, $as = null)
9771002
{
9781003
if ($collection) {
@@ -1012,6 +1037,7 @@ public function lists($column, $key = null)
10121037
*
10131038
* @template T
10141039
*/
1040+
#[Override]
10151041
public function raw($value = null)
10161042
{
10171043
// Execute the closure on the mongodb collection
@@ -1114,11 +1140,13 @@ public function drop($columns)
11141140
*
11151141
* @inheritdoc
11161142
*/
1143+
#[Override]
11171144
public function newQuery()
11181145
{
11191146
return new static($this->connection, $this->grammar, $this->processor);
11201147
}
11211148

1149+
#[Override]
11221150
public function runPaginationCountQuery($columns = ['*'])
11231151
{
11241152
if ($this->distinct) {
@@ -1201,6 +1229,7 @@ public function convertKey($id)
12011229
*
12021230
* @return $this
12031231
*/
1232+
#[Override]
12041233
public function where($column, $operator = null, $value = null, $boolean = 'and')
12051234
{
12061235
$params = func_get_args();
@@ -1714,6 +1743,7 @@ private function inheritConnectionOptions(array $options = []): array
17141743
}
17151744

17161745
/** @inheritdoc */
1746+
#[Override]
17171747
public function __call($method, $parameters)
17181748
{
17191749
if ($method === 'unset') {
@@ -1724,90 +1754,105 @@ public function __call($method, $parameters)
17241754
}
17251755

17261756
/** @internal This method is not supported by MongoDB. */
1757+
#[Override]
17271758
public function toSql()
17281759
{
17291760
throw new BadMethodCallException('This method is not supported by MongoDB. Try "toMql()" instead.');
17301761
}
17311762

17321763
/** @internal This method is not supported by MongoDB. */
1764+
#[Override]
17331765
public function toRawSql()
17341766
{
17351767
throw new BadMethodCallException('This method is not supported by MongoDB. Try "toMql()" instead.');
17361768
}
17371769

17381770
/** @internal This method is not supported by MongoDB. */
1771+
#[Override]
17391772
public function whereColumn($first, $operator = null, $second = null, $boolean = 'and')
17401773
{
17411774
throw new BadMethodCallException('This method is not supported by MongoDB');
17421775
}
17431776

17441777
/** @internal This method is not supported by MongoDB. */
1778+
#[Override]
17451779
public function whereFullText($columns, $value, array $options = [], $boolean = 'and')
17461780
{
17471781
throw new BadMethodCallException('This method is not supported by MongoDB');
17481782
}
17491783

17501784
/** @internal This method is not supported by MongoDB. */
1785+
#[Override]
17511786
public function groupByRaw($sql, array $bindings = [])
17521787
{
17531788
throw new BadMethodCallException('This method is not supported by MongoDB');
17541789
}
17551790

17561791
/** @internal This method is not supported by MongoDB. */
1792+
#[Override]
17571793
public function orderByRaw($sql, $bindings = [])
17581794
{
17591795
throw new BadMethodCallException('This method is not supported by MongoDB');
17601796
}
17611797

17621798
/** @internal This method is not supported by MongoDB. */
1799+
#[Override]
17631800
public function unionAll($query)
17641801
{
17651802
throw new BadMethodCallException('This method is not supported by MongoDB');
17661803
}
17671804

17681805
/** @internal This method is not supported by MongoDB. */
1806+
#[Override]
17691807
public function union($query, $all = false)
17701808
{
17711809
throw new BadMethodCallException('This method is not supported by MongoDB');
17721810
}
17731811

17741812
/** @internal This method is not supported by MongoDB. */
1813+
#[Override]
17751814
public function having($column, $operator = null, $value = null, $boolean = 'and')
17761815
{
17771816
throw new BadMethodCallException('This method is not supported by MongoDB');
17781817
}
17791818

17801819
/** @internal This method is not supported by MongoDB. */
1820+
#[Override]
17811821
public function havingRaw($sql, array $bindings = [], $boolean = 'and')
17821822
{
17831823
throw new BadMethodCallException('This method is not supported by MongoDB');
17841824
}
17851825

17861826
/** @internal This method is not supported by MongoDB. */
1827+
#[Override]
17871828
public function havingBetween($column, iterable $values, $boolean = 'and', $not = false)
17881829
{
17891830
throw new BadMethodCallException('This method is not supported by MongoDB');
17901831
}
17911832

17921833
/** @internal This method is not supported by MongoDB. */
1834+
#[Override]
17931835
public function whereIntegerInRaw($column, $values, $boolean = 'and', $not = false)
17941836
{
17951837
throw new BadMethodCallException('This method is not supported by MongoDB');
17961838
}
17971839

17981840
/** @internal This method is not supported by MongoDB. */
1841+
#[Override]
17991842
public function orWhereIntegerInRaw($column, $values)
18001843
{
18011844
throw new BadMethodCallException('This method is not supported by MongoDB');
18021845
}
18031846

18041847
/** @internal This method is not supported by MongoDB. */
1848+
#[Override]
18051849
public function whereIntegerNotInRaw($column, $values, $boolean = 'and')
18061850
{
18071851
throw new BadMethodCallException('This method is not supported by MongoDB');
18081852
}
18091853

18101854
/** @internal This method is not supported by MongoDB. */
1855+
#[Override]
18111856
public function orWhereIntegerNotInRaw($column, $values, $boolean = 'and')
18121857
{
18131858
throw new BadMethodCallException('This method is not supported by MongoDB');

0 commit comments

Comments
 (0)