Skip to content

Commit def671d

Browse files
committed
formatting
1 parent 676954b commit def671d

File tree

5 files changed

+37
-24
lines changed

5 files changed

+37
-24
lines changed

src/Illuminate/Database/Query/Builder.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ class Builder
204204
];
205205

206206
/**
207-
* All of the available binary operators.
207+
* All of the available bit operators.
208208
*
209209
* @var string[]
210210
*/
211-
public $binaryOperators = [
211+
public $bitOperators = [
212212
'&', '|', '^', '<<', '>>', '&~',
213213
];
214214

@@ -763,8 +763,8 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
763763
}
764764
}
765765

766-
if ($this->isBinaryOperator($operator)) {
767-
$type = 'Binary';
766+
if ($this->isBitOperator($operator)) {
767+
$type = 'Bit';
768768
}
769769

770770
// Now that we are working with just a simple query we can put the elements
@@ -850,10 +850,16 @@ protected function invalidOperator($operator)
850850
! in_array(strtolower($operator), $this->grammar->getOperators(), true);
851851
}
852852

853-
protected function isBinaryOperator($operator)
853+
/**
854+
* Determine if the operator is a bit operator.
855+
*
856+
* @param string $operator
857+
* @return bool
858+
*/
859+
protected function isBitOperator($operator)
854860
{
855-
return in_array(strtolower($operator), $this->binaryOperators, true) ||
856-
in_array(strtolower($operator), $this->grammar->getBinaryOperators(), true);
861+
return in_array(strtolower($operator), $this->bitOperators, true) ||
862+
in_array(strtolower($operator), $this->grammar->getBitOperators(), true);
857863
}
858864

859865
/**
@@ -1934,8 +1940,8 @@ public function having($column, $operator = null, $value = null, $boolean = 'and
19341940
[$value, $operator] = [$operator, '='];
19351941
}
19361942

1937-
if ($this->isBinaryOperator($operator)) {
1938-
$type = 'binary';
1943+
if ($this->isBitOperator($operator)) {
1944+
$type = 'bit';
19391945
}
19401946

19411947
$this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean');

src/Illuminate/Database/Query/Grammars/Grammar.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class Grammar extends BaseGrammar
1919
protected $operators = [];
2020

2121
/**
22-
* The grammar specific binary operators.
22+
* The grammar specific bit operators.
2323
*
2424
* @var array
2525
*/
26-
protected $binaryOperators = [];
26+
protected $bitOperators = [];
2727

2828
/**
2929
* The components that make up a select clause.
@@ -262,7 +262,14 @@ protected function whereBasic(Builder $query, $where)
262262
return $this->wrap($where['column']).' '.$operator.' '.$value;
263263
}
264264

265-
protected function whereBinary(Builder $query, $where)
265+
/**
266+
* Compile a bit operator where clause.
267+
*
268+
* @param \Illuminate\Database\Query\Builder $query
269+
* @param array $where
270+
* @return string
271+
*/
272+
protected function whereBit(Builder $query, $where)
266273
{
267274
$value = $this->parameter($where['value']);
268275

@@ -701,8 +708,8 @@ protected function compileHaving(array $having)
701708
return $having['boolean'].' '.$having['sql'];
702709
} elseif ($having['type'] === 'between') {
703710
return $this->compileHavingBetween($having);
704-
} elseif ($having['type'] === 'binary') {
705-
return $this->compileHavingBinary($having);
711+
} elseif ($having['type'] === 'bit') {
712+
return $this->compileHavingBit($having);
706713
}
707714

708715
return $this->compileBasicHaving($having);
@@ -743,12 +750,12 @@ protected function compileHavingBetween($having)
743750
}
744751

745752
/**
746-
* Compile a having clause involving a binary operator.
753+
* Compile a having clause involving a bit operator.
747754
*
748755
* @param array $having
749756
* @return string
750757
*/
751-
protected function compileHavingBinary($having)
758+
protected function compileHavingBit($having)
752759
{
753760
$column = $this->wrap($having['column']);
754761

@@ -1334,12 +1341,12 @@ public function getOperators()
13341341
}
13351342

13361343
/**
1337-
* Get the grammar specific binary operators.
1344+
* Get the grammar specific bit operators.
13381345
*
13391346
* @return array
13401347
*/
1341-
public function getBinaryOperators()
1348+
public function getBitOperators()
13421349
{
1343-
return $this->binaryOperators;
1350+
return $this->bitOperators;
13441351
}
13451352
}

src/Illuminate/Database/Query/Grammars/PostgresGrammar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class PostgresGrammar extends Grammar
2222
];
2323

2424
/**
25-
* The grammar specific binary operators.
25+
* The grammar specific bit operators.
2626
*
2727
* @var array
2828
*/
29-
protected $binaryOperators = [
29+
protected $bitOperators = [
3030
'~', '&', '|', '#', '<<', '>>', '<<=', '>>=',
3131
];
3232

tests/Database/DatabaseEloquentModelTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,7 @@ protected function addMockConnection($model)
21532153
$model->setConnectionResolver($resolver = m::mock(ConnectionResolverInterface::class));
21542154
$resolver->shouldReceive('connection')->andReturn($connection = m::mock(Connection::class));
21552155
$connection->shouldReceive('getQueryGrammar')->andReturn($grammar = m::mock(Grammar::class));
2156-
$grammar->shouldReceive('getBinaryOperators')->andReturn([]);
2156+
$grammar->shouldReceive('getBitOperators')->andReturn([]);
21572157
$connection->shouldReceive('getPostProcessor')->andReturn($processor = m::mock(Processor::class));
21582158
$connection->shouldReceive('query')->andReturnUsing(function () use ($connection, $grammar, $processor) {
21592159
return new BaseBuilder($connection, $grammar, $processor);
@@ -2441,7 +2441,7 @@ public function getConnection()
24412441
{
24422442
$mock = m::mock(Connection::class);
24432443
$mock->shouldReceive('getQueryGrammar')->andReturn($grammar = m::mock(Grammar::class));
2444-
$grammar->shouldReceive('getBinaryOperators')->andReturn([]);
2444+
$grammar->shouldReceive('getBitOperators')->andReturn([]);
24452445
$mock->shouldReceive('getPostProcessor')->andReturn($processor = m::mock(Processor::class));
24462446
$mock->shouldReceive('getName')->andReturn('name');
24472447
$mock->shouldReceive('query')->andReturnUsing(function () use ($mock, $grammar, $processor) {

tests/Database/DatabaseQueryBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,7 @@ public function testMySqlSoundsLikeOperator()
32093209
$this->assertEquals(['John Doe'], $builder->getBindings());
32103210
}
32113211

3212-
public function testBinaryOperators()
3212+
public function testBitOperators()
32133213
{
32143214
$builder = $this->getBuilder();
32153215
$builder->select('*')->from('users')->where('bar', '&', 1);

0 commit comments

Comments
 (0)