@@ -24,7 +24,7 @@ public static function dump(string|Result|null $sql = null, bool $return = false
2424 {
2525 ob_start ();
2626 if ($ sql instanceof Result && PHP_SAPI === 'cli ' ) {
27- $ hasColors = (substr ((string ) getenv ('TERM ' ), 0 , 5 ) === 'xterm ' );
27+ $ hasColors = (str_starts_with ((string ) getenv ('TERM ' ), 'xterm ' ) );
2828 $ maxLen = 0 ;
2929 foreach ($ sql as $ i => $ row ) {
3030 if ($ i === 0 ) {
@@ -89,7 +89,7 @@ public static function dump(string|Result|null $sql = null, bool $return = false
8989 // syntax highlight
9090 $ highlighter = "#(/ \\*.+? \\*/)|( \\* \\*.+? \\* \\*)|(?<=[ \\s,(])( $ keywords1)(?=[ \\s,)])|(?<=[ \\s,(=])( $ keywords2)(?=[ \\s,)=])#is " ;
9191 if (PHP_SAPI === 'cli ' ) {
92- if (substr ((string ) getenv ('TERM ' ), 0 , 5 ) === 'xterm ' ) {
92+ if (str_starts_with ((string ) getenv ('TERM ' ), 'xterm ' ) ) {
9393 $ sql = preg_replace_callback ($ highlighter , function (array $ m ) {
9494 if (!empty ($ m [1 ])) { // comment
9595 return "\033[1;30m " . $ m [1 ] . "\033[0m " ;
@@ -257,7 +257,7 @@ public static function loadFromFile(Connection $connection, string $file, ?calla
257257 if (strtoupper (substr ($ s , 0 , 10 )) === 'DELIMITER ' ) {
258258 $ delimiter = trim (substr ($ s , 10 ));
259259
260- } elseif (substr ($ ts = rtrim ($ s ), - strlen ( $ delimiter )) === $ delimiter ) {
260+ } elseif (str_ends_with ($ ts = rtrim ($ s ), $ delimiter )) {
261261 $ sql .= substr ($ ts , 0 , -strlen ($ delimiter ));
262262 $ driver ->query ($ sql );
263263 $ sql = '' ;
0 commit comments