Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Sep 12, 2024
2 parents 982710a + 58c2053 commit c9ba568
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 1 deletion.
42 changes: 42 additions & 0 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,13 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
[$value, $operator] = [$operator, '='];
}

$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
Expand Down Expand Up @@ -1558,6 +1565,13 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
[$value, $operator] = [$operator, '='];
}

$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
Expand Down Expand Up @@ -1599,6 +1613,13 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
[$value, $operator] = [$operator, '='];
}

$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
Expand Down Expand Up @@ -1644,6 +1665,13 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
[$value, $operator] = [$operator, '='];
}

$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
Expand Down Expand Up @@ -1689,6 +1717,13 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and')
$value, $operator, func_num_args() === 2
);

// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
[$value, $operator] = [$operator, '='];
}

$value = $this->flattenValue($value);

if ($value instanceof DateTimeInterface) {
Expand Down Expand Up @@ -2114,6 +2149,13 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a
$value, $operator, func_num_args() === 2
);

// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
[$value, $operator] = [$operator, '='];
}

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

if (! $value instanceof ExpressionContract) {
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/EnvironmentDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function getEnvironmentArgument(array $args)
return $args[$i + 1] ?? null;
}

if (str_starts_with($value, '--env')) {
if (str_starts_with($value, '--env=')) {
return head(array_slice(explode('=', $value), 1));
}
}
Expand Down
30 changes: 30 additions & 0 deletions tests/Foundation/FoundationEnvironmentDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,34 @@ public function testConsoleEnvironmentDetectionWithNoValue()
}, ['--env']);
$this->assertSame('foobar', $result);
}

public function testConsoleEnvironmentDetectionDoesNotUseArgumentThatStartsWithEnv()
{
$env = new EnvironmentDetector;

$result = $env->detect(function () {
return 'foobar';
}, ['--envelope=mail']);
$this->assertSame('foobar', $result);
}

public function testConsoleEnvironmentDetectionDoesNotUseArgumentThatStartsWithEnvSeparatedWithSpace()
{
$env = new EnvironmentDetector;

$result = $env->detect(function () {
return 'foobar';
}, ['--envelope', 'mail']);
$this->assertSame('foobar', $result);
}

public function testConsoleEnvironmentDetectionDoesNotUseArgumentThatStartsWithEnvWithNoValue()
{
$env = new EnvironmentDetector;

$result = $env->detect(function () {
return 'foobar';
}, ['--envelope']);
$this->assertSame('foobar', $result);
}
}
Loading

0 comments on commit c9ba568

Please sign in to comment.