Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit fcc61a6

Browse files
committed
Throw LogicException
1 parent b3a1d5f commit fcc61a6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,11 +1081,11 @@ protected function compileWhereBasic(array $where): array
10811081
if (is_string($value)) {
10821082
$delimiter = substr($value, 0, 1);
10831083
if (! in_array($delimiter, ['/', '#', '~'])) {
1084-
throw new \InvalidArgumentException(sprintf('Regular expressions must be surrounded by delimiter "/". Got "%s"', $value));
1084+
throw new \LogicException(sprintf('Regular expressions must be surrounded by delimiter "/". Got "%s"', $value));
10851085
}
10861086
$e = explode($delimiter, $value);
10871087
if (count($e) < 3) {
1088-
throw new \InvalidArgumentException(sprintf('Regular expressions must be surrounded by delimiter "%s". Got "%s"', $delimiter, $value));
1088+
throw new \LogicException(sprintf('Regular expressions must be surrounded by delimiter "%s". Got "%s"', $delimiter, $value));
10891089
}
10901090
$flags = end($e);
10911091
$regstr = substr($value, 1, -1 - strlen($flags));

tests/Query/BuilderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -562,31 +562,31 @@ public static function provideExceptions(): iterable
562562
];
563563

564564
yield 'where regex not starting with /' => [
565-
\InvalidArgumentException::class,
565+
\LogicException::class,
566566
'Regular expressions must be surrounded by delimiter "/". Got "^ac/me$"',
567567
fn (Builder $builder) => $builder->where('name', 'regex', '^ac/me$'),
568568
];
569569

570570
yield 'where regex not ending with /' => [
571-
\InvalidArgumentException::class,
571+
\LogicException::class,
572572
'Regular expressions must be surrounded by delimiter "/". Got "/^acme$"',
573573
fn (Builder $builder) => $builder->where('name', 'regex', '/^acme$'),
574574
];
575575

576576
yield 'where regex not ending with #' => [
577-
\InvalidArgumentException::class,
577+
\LogicException::class,
578578
'Regular expressions must be surrounded by delimiter "#". Got "#^acme$"',
579579
fn (Builder $builder) => $builder->where('name', 'regex', '#^acme$'),
580580
];
581581

582582
yield 'where regexp not supported' => [
583-
\InvalidArgumentException::class,
583+
\LogicException::class,
584584
'Operator "regexp" is not supported. Use "regex" instead.',
585585
fn (Builder $builder) => $builder->where('name', 'regexp', '/^acme$/'),
586586
];
587587

588588
yield 'where ilike not supported' => [
589-
\InvalidArgumentException::class,
589+
\LogicException::class,
590590
'Operator "ilike" is not supported. Use "like" instead.',
591591
fn (Builder $builder) => $builder->where('name', 'ilike', 'acme'),
592592
];

0 commit comments

Comments
 (0)