77
77
use function number_format ;
78
78
use function preg_match ;
79
79
use function rename ;
80
- use function sprintf ;
81
80
use function str_ends_with ;
82
81
use function str_starts_with ;
83
82
use function strlen ;
87
86
use function usort ;
88
87
89
88
use const PHP_EOL ;
89
+ use const PHP_VERSION ;
90
90
use const PSALM_VERSION ;
91
91
use const STDERR ;
92
92
@@ -280,7 +280,7 @@ private function clearCacheDirectoryIfConfigOrComposerLockfileChanged(): void
280
280
clearstatcache (true , $ cache_directory );
281
281
if (is_dir ($ cache_directory )) {
282
282
$ this ->progress ->debug (
283
- 'Composer lockfile change detected, clearing cache directory ' . $ cache_directory . "\n" ,
283
+ 'Composer lockfile change detected, clearing cache directory ' . $ cache_directory . PHP_EOL ,
284
284
);
285
285
286
286
Config::removeCacheDirectory ($ cache_directory );
@@ -297,7 +297,7 @@ private function clearCacheDirectoryIfConfigOrComposerLockfileChanged(): void
297
297
clearstatcache (true , $ cache_directory );
298
298
if (is_dir ($ cache_directory )) {
299
299
$ this ->progress ->debug (
300
- 'Config change detected, clearing cache directory ' . $ cache_directory . "\n" ,
300
+ 'Config change detected, clearing cache directory ' . $ cache_directory . PHP_EOL ,
301
301
);
302
302
303
303
Config::removeCacheDirectory ($ cache_directory );
@@ -350,7 +350,7 @@ private function visitAutoloadFiles(): void
350
350
$ now_time = microtime (true );
351
351
352
352
$ this ->progress ->debug (
353
- 'Visiting autoload files took ' . number_format ($ now_time - $ start_time , 3 ) . 's ' . "\n" ,
353
+ 'Visiting autoload files took ' . number_format ($ now_time - $ start_time , 3 ) . 's ' . PHP_EOL ,
354
354
);
355
355
}
356
356
@@ -411,12 +411,11 @@ private function generatePHPVersionMessage(): string
411
411
$ codebase ->config ->php_extensions_supported_by_psalm_callmaps ,
412
412
);
413
413
414
- $ message = sprintf (
415
- "Target PHP version: %d.%d %s " ,
416
- $ codebase ->getMajorAnalysisPhpVersion (),
417
- $ codebase ->getMinorAnalysisPhpVersion (),
418
- $ source ,
419
- );
414
+ $ message = "Target PHP version: "
415
+ .$ codebase ->getMajorAnalysisPhpVersion ().". "
416
+ .$ codebase ->getMinorAnalysisPhpVersion ()." "
417
+ .$ source
418
+ ;
420
419
421
420
$ enabled_extensions_names = array_keys (array_filter ($ codebase ->config ->php_extensions ));
422
421
if (count ($ enabled_extensions_names ) > 0 ) {
@@ -427,7 +426,9 @@ private function generatePHPVersionMessage(): string
427
426
$ message .= ' (unsupported extensions: ' . implode (', ' , $ unsupported_php_extensions ) . ') ' ;
428
427
}
429
428
430
- return "$ message. \n" ;
429
+ $ message .= '. ' .PHP_EOL .PHP_EOL ."Running on PHP " .PHP_VERSION .'. ' .PHP_EOL .PHP_EOL ;
430
+
431
+ return $ message ;
431
432
}
432
433
433
434
public function check (string $ base_dir , bool $ is_diff = false ): void
@@ -479,8 +480,8 @@ public function check(string $base_dir, bool $is_diff = false): void
479
480
$ this ->codebase ->infer_types_from_usage = true ;
480
481
} else {
481
482
$ this ->codebase ->diff_run = true ;
482
- $ this ->progress ->debug (count ($ diff_files ) . ' changed files: ' . "\n" );
483
- $ this ->progress ->debug (' ' . implode ("\n " , $ diff_files ) . "\n" );
483
+ $ this ->progress ->debug (count ($ diff_files ) . ' changed files: ' . PHP_EOL );
484
+ $ this ->progress ->debug (' ' . implode (PHP_EOL . " " , $ diff_files ) . PHP_EOL );
484
485
485
486
$ this ->codebase ->analyzer ->addFilesToShowResults ($ this ->project_files );
486
487
@@ -528,7 +529,7 @@ public function check(string $base_dir, bool $is_diff = false): void
528
529
$ removed_parser_files = $ this ->parser_cache_provider ->deleteOldParserCaches ($ start_checks );
529
530
530
531
if ($ removed_parser_files ) {
531
- $ this ->progress ->debug ('Removed ' . $ removed_parser_files . ' old parser caches ' . "\n" );
532
+ $ this ->progress ->debug ('Removed ' . $ removed_parser_files . ' old parser caches ' . PHP_EOL );
532
533
}
533
534
}
534
535
}
@@ -851,14 +852,14 @@ public function findReferencesTo(string $symbol): void
851
852
$ selection_start = $ selection_bounds [0 ] - $ snippet_bounds [0 ];
852
853
$ selection_length = $ selection_bounds [1 ] - $ selection_bounds [0 ];
853
854
854
- echo $ location ->file_name . ': ' . $ location ->getLineNumber () . "\n" .
855
+ echo $ location ->file_name . ': ' . $ location ->getLineNumber () . PHP_EOL .
855
856
(
856
857
$ this ->stdout_report_options ->use_color
857
858
? substr ($ snippet , 0 , $ selection_start ) .
858
859
"\e[97;42m " . substr ($ snippet , $ selection_start , $ selection_length ) .
859
860
"\e[0m " . substr ($ snippet , $ selection_length + $ selection_start )
860
861
: $ snippet
861
- ) . "\n" . "\n" ;
862
+ ) . PHP_EOL . PHP_EOL ;
862
863
}
863
864
}
864
865
@@ -947,7 +948,7 @@ private function checkDiffFilesWithConfig(Config $config, array $file_list = [])
947
948
}
948
949
949
950
if (!$ config ->isInProjectDirs ($ file_path )) {
950
- $ this ->progress ->debug ('skipping ' . $ file_path . "\n" );
951
+ $ this ->progress ->debug ('skipping ' . $ file_path . PHP_EOL );
951
952
952
953
continue ;
953
954
}
@@ -960,7 +961,7 @@ private function checkDiffFilesWithConfig(Config $config, array $file_list = [])
960
961
961
962
public function checkFile (string $ file_path ): void
962
963
{
963
- $ this ->progress ->debug ('Checking ' . $ file_path . "\n" );
964
+ $ this ->progress ->debug ('Checking ' . $ file_path . PHP_EOL );
964
965
965
966
$ this ->config ->visitPreloadedStubFiles ($ this ->codebase , $ this ->progress );
966
967
@@ -1003,7 +1004,7 @@ public function checkPaths(array $paths_to_check): void
1003
1004
$ this ->codebase ->scanner ->addFilesToShallowScan ($ this ->extra_files );
1004
1005
1005
1006
foreach ($ paths_to_check as $ path ) {
1006
- $ this ->progress ->debug ('Checking ' . $ path . "\n" );
1007
+ $ this ->progress ->debug ('Checking ' . $ path . PHP_EOL );
1007
1008
1008
1009
if (is_dir ($ path )) {
1009
1010
$ this ->checkDirWithConfig ($ path , $ this ->config , true );
0 commit comments