Skip to content

Commit 47ca753

Browse files
staabmclxmstaab
andauthored
RuntimeConfiguration: Allow opt-in for bool handling (#148)
Co-authored-by: Markus Staab <[email protected]>
1 parent 88e3749 commit 47ca753

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/QueryReflection/RuntimeConfiguration.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@
88

99
final class RuntimeConfiguration
1010
{
11+
/**
12+
* methods should return `false` on error.
13+
*/
14+
public const ERROR_MODE_BOOL = 'bool';
15+
/**
16+
* methods will throw exceptions on errors, therefore will never return `false`.
17+
*/
1118
public const ERROR_MODE_EXCEPTION = 'exception';
19+
/**
20+
* use whatever the current php-src version uses per default.
21+
*/
1222
public const ERROR_MODE_DEFAULT = 'default';
1323

1424
/**
@@ -52,6 +62,9 @@ public function throwsPdoExceptions(PhpVersion $phpVersion): bool
5262
if (self::ERROR_MODE_EXCEPTION === $this->errorMode) {
5363
return true;
5464
}
65+
if (self::ERROR_MODE_BOOL === $this->errorMode) {
66+
return false;
67+
}
5568

5669
// since php8 the pdo php-src default error mode changed to exception
5770
return $phpVersion->getVersionId() >= 80000;
@@ -62,6 +75,9 @@ public function throwsMysqliExceptions(PhpVersion $phpVersion): bool
6275
if (self::ERROR_MODE_EXCEPTION === $this->errorMode) {
6376
return true;
6477
}
78+
if (self::ERROR_MODE_BOOL === $this->errorMode) {
79+
return false;
80+
}
6581

6682
// since php8.1 the mysqli php-src default error mode changed to exception
6783
return $phpVersion->getVersionId() >= 80100;

0 commit comments

Comments
 (0)