syntaxcheck.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. require_once('libs/api.compat.php');
  3. require_once('libs/api.ubrouting.php');
  4. if (ubRouting::optionCliCheck('run', false)) {
  5. $errorCount = 0;
  6. $yalfLibsPath = __DIR__ . '/libs/';
  7. $allYalfLibs = rcms_scandir($yalfLibsPath, '*.php');
  8. if (!empty($allYalfLibs)) {
  9. $allYalfLibs = array_flip($allYalfLibs);
  10. foreach ($allYalfLibs as $eachYalfLib => $index) {
  11. $lintResult = shell_exec('php -l ' . $yalfLibsPath . $eachYalfLib.' 2>&1');
  12. if (ispos($lintResult, 'PHP ')) {
  13. $errorCount++;
  14. print('FAILED: ' . $eachYalfLib . PHP_EOL);
  15. print('=========================' . PHP_EOL);
  16. print($lintResult.PHP_EOL);
  17. print('=========================' . PHP_EOL);
  18. } else {
  19. print('OK: ' . $eachYalfLib . PHP_EOL);
  20. }
  21. }
  22. }
  23. //summary here
  24. print('=========================' . PHP_EOL);
  25. if ($errorCount > 0) {
  26. print('Found ' . $errorCount . ' issues with libs syntax' . PHP_EOL);
  27. } else {
  28. print('Everything is Ok' . PHP_EOL);
  29. }
  30. } else {
  31. print('Usage: php ./api/syntaxcheck.php --run' . PHP_EOL);
  32. }