yaml-lint 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of the Symfony package.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. /**
  12. * Runs the Yaml lint command.
  13. *
  14. * @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
  15. */
  16. use Symfony\Component\Console\Application;
  17. use Symfony\Component\Yaml\Command\LintCommand;
  18. function includeIfExists(string $file): bool
  19. {
  20. return file_exists($file) && include $file;
  21. }
  22. if (
  23. !includeIfExists(__DIR__ . '/../../../../autoload.php') &&
  24. !includeIfExists(__DIR__ . '/../../vendor/autoload.php') &&
  25. !includeIfExists(__DIR__ . '/../../../../../../vendor/autoload.php')
  26. ) {
  27. fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL);
  28. exit(1);
  29. }
  30. if (!class_exists(Application::class)) {
  31. fwrite(STDERR, 'You need the "symfony/console" component in order to run the Yaml linter.'.PHP_EOL);
  32. exit(1);
  33. }
  34. (new Application())->add($command = new LintCommand())
  35. ->getApplication()
  36. ->setDefaultCommand($command->getName(), true)
  37. ->run()
  38. ;