File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1717use CodeIgniter \Database \Exceptions \DatabaseException ;
1818use CodeIgniter \Events \Events ;
1919use stdClass ;
20+ use Stringable ;
2021use Throwable ;
2122
2223/**
@@ -1309,12 +1310,15 @@ public function escape($str)
13091310 return array_map ($ this ->escape (...), $ str );
13101311 }
13111312
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) {
13141314 if ($ str instanceof RawSql) {
13151315 return $ str ->__toString ();
13161316 }
13171317
1318+ $ str = (string ) $ str ;
1319+ }
1320+
1321+ if (is_string ($ str )) {
13181322 return "' " . $ this ->escapeString ($ str ) . "' " ;
13191323 }
13201324
Original file line number Diff line number Diff line change 2020use PgSql \Connection as PgSqlConnection ;
2121use PgSql \Result as PgSqlResult ;
2222use stdClass ;
23+ use Stringable ;
2324
2425/**
2526 * Connection for Postgre
@@ -233,20 +234,22 @@ public function escape($str)
233234 $ this ->initialize ();
234235 }
235236
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) {
238238 if ($ str instanceof RawSql) {
239239 return $ str ->__toString ();
240240 }
241241
242+ $ str = (string ) $ str ;
243+ }
244+
245+ if (is_string ($ str )) {
242246 return pg_escape_literal ($ this ->connID , $ str );
243247 }
244248
245249 if (is_bool ($ str )) {
246250 return $ str ? 'TRUE ' : 'FALSE ' ;
247251 }
248252
249- /** @psalm-suppress NoValue I don't know why ERROR. */
250253 return parent ::escape ($ str );
251254 }
252255
You can’t perform that action at this time.
0 commit comments