File tree 2 files changed +12
-5
lines changed
2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 17
17
use CodeIgniter \Database \Exceptions \DatabaseException ;
18
18
use CodeIgniter \Events \Events ;
19
19
use stdClass ;
20
+ use Stringable ;
20
21
use Throwable ;
21
22
22
23
/**
@@ -1309,12 +1310,15 @@ public function escape($str)
1309
1310
return array_map ($ this ->escape (...), $ str );
1310
1311
}
1311
1312
1312
- /** @psalm-suppress NoValue I don't know why ERROR. */
1313
- if (is_string ($ str ) || (is_object ($ str ) && method_exists ($ str , '__toString ' ))) {
1313
+ if ($ str instanceof Stringable) {
1314
1314
if ($ str instanceof RawSql) {
1315
1315
return $ str ->__toString ();
1316
1316
}
1317
1317
1318
+ $ str = (string ) $ str ;
1319
+ }
1320
+
1321
+ if (is_string ($ str )) {
1318
1322
return "' " . $ this ->escapeString ($ str ) . "' " ;
1319
1323
}
1320
1324
Original file line number Diff line number Diff line change 20
20
use PgSql \Connection as PgSqlConnection ;
21
21
use PgSql \Result as PgSqlResult ;
22
22
use stdClass ;
23
+ use Stringable ;
23
24
24
25
/**
25
26
* Connection for Postgre
@@ -233,20 +234,22 @@ public function escape($str)
233
234
$ this ->initialize ();
234
235
}
235
236
236
- /** @psalm-suppress NoValue I don't know why ERROR. */
237
- if (is_string ($ str ) || (is_object ($ str ) && method_exists ($ str , '__toString ' ))) {
237
+ if ($ str instanceof Stringable) {
238
238
if ($ str instanceof RawSql) {
239
239
return $ str ->__toString ();
240
240
}
241
241
242
+ $ str = (string ) $ str ;
243
+ }
244
+
245
+ if (is_string ($ str )) {
242
246
return pg_escape_literal ($ this ->connID , $ str );
243
247
}
244
248
245
249
if (is_bool ($ str )) {
246
250
return $ str ? 'TRUE ' : 'FALSE ' ;
247
251
}
248
252
249
- /** @psalm-suppress NoValue I don't know why ERROR. */
250
253
return parent ::escape ($ str );
251
254
}
252
255
You can’t perform that action at this time.
0 commit comments