The CLI (Command Line Interface) of PHP offers a static code analysis feature (also known as linter) with the
-l option, allowing the user to check a specified PHP file for syntax errors. This helps quickly check a PHP file before running it.
In PHP versions before 8.3, linting multiple PHP files in a single invocation was not possible. Regardless of how many files are given, PHP CLI only checks the syntax of the first file.
Since PHP 8.3, it is now possible to pass multiple PHP files at once, and PHP CLI checks all of them in a single invocation.
php -l test1.php test2.php
No syntax errors detected in test1.php
No syntax errors detected in test2.php
If the linter discovers errors in any of the given files, it displays the error and proceeds to the remaining files in the list.