-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use script for checking php syntax that exits with status code set to…
… 1 if there are deprecation warnings
- Loading branch information
1 parent
d41f882
commit 87ea80f
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
/** | ||
* Checks all PHP files in this project recursively | ||
* and passes them to PHP's built-in linter. | ||
* | ||
* If the output contains "deprecated", the final status code will be 1. | ||
*/ | ||
|
||
$global_exit_code = 0; | ||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(".", RecursiveDirectoryIterator::SKIP_DOTS)); | ||
|
||
foreach ($iterator as $file) { | ||
if ( | ||
str_starts_with($file->getPathname(), './vendor/') | ||
|| str_starts_with($file->getPathname(), './node_modules/') | ||
|| false == $file->isFile() | ||
|| $file->getExtension() !== 'php' | ||
) { | ||
continue; | ||
} | ||
|
||
$exit_code = 0; | ||
$output = []; | ||
exec("php -l {$file->getPathname()}", $output, $exit_code); | ||
$output = join("\n", $output); | ||
echo $output . "\n"; | ||
|
||
if ($exit_code || str_contains($output, 'Deprecated')) { | ||
$global_exit_code = 1; | ||
} | ||
} | ||
|
||
exit($global_exit_code); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters