@@ -24,7 +24,7 @@ public static function dump(string|Result $sql = null, bool $return = false): ?s
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 ) {
@@ -86,7 +86,7 @@ public static function dump(string|Result $sql = null, bool $return = false): ?s
8686 // syntax highlight
8787 $ highlighter = "#(/ \\*.+? \\*/)|( \\* \\*.+? \\* \\*)|(?<=[ \\s,(])( $ keywords1)(?=[ \\s,)])|(?<=[ \\s,(=])( $ keywords2)(?=[ \\s,)=])#is " ;
8888 if (PHP_SAPI === 'cli ' ) {
89- if (substr ((string ) getenv ('TERM ' ), 0 , 5 ) === 'xterm ' ) {
89+ if (str_starts_with ((string ) getenv ('TERM ' ), 'xterm ' ) ) {
9090 $ sql = preg_replace_callback ($ highlighter , function (array $ m ) {
9191 if (!empty ($ m [1 ])) { // comment
9292 return "\033[1;30m " . $ m [1 ] . "\033[0m " ;
@@ -249,7 +249,7 @@ public static function loadFromFile(Connection $connection, string $file, callab
249249 if (strtoupper (substr ($ s , 0 , 10 )) === 'DELIMITER ' ) {
250250 $ delimiter = trim (substr ($ s , 10 ));
251251
252- } elseif (substr ($ ts = rtrim ($ s ), - strlen ( $ delimiter )) === $ delimiter ) {
252+ } elseif (str_ends_with ($ ts = rtrim ($ s ), $ delimiter )) {
253253 $ sql .= substr ($ ts , 0 , -strlen ($ delimiter ));
254254 $ driver ->query ($ sql );
255255 $ sql = '' ;
0 commit comments