|
| 1 | +#!/usr/bin/env php |
| 2 | +<?php |
| 3 | + |
| 4 | +declare(strict_types=1); |
| 5 | + |
| 6 | +/* |
| 7 | + * This file is part of the "composer-translation-validator" Composer plugin. |
| 8 | + * |
| 9 | + * (c) 2025-2026 Konrad Michalik <km@move-elevator.de> |
| 10 | + * |
| 11 | + * For the full copyright and license information, please view the LICENSE |
| 12 | + * file that was distributed with this source code. |
| 13 | + */ |
| 14 | + |
| 15 | +use MoveElevator\ComposerTranslationValidator\Command\StandaloneValidateTranslationCommand; |
| 16 | +use Symfony\Component\Console\Application; |
| 17 | + |
| 18 | +(static function (): void { |
| 19 | + $autoloads = [ |
| 20 | + __DIR__.'/../vendor/autoload.php', // running from source / inside the PHAR |
| 21 | + __DIR__.'/../../../autoload.php', // installed as a dependency |
| 22 | + ]; |
| 23 | + |
| 24 | + foreach ($autoloads as $autoload) { |
| 25 | + if (is_file($autoload)) { |
| 26 | + require $autoload; |
| 27 | + |
| 28 | + return; |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + fwrite(\STDERR, 'Composer autoloader not found. Run "composer install".'.\PHP_EOL); |
| 33 | + exit(1); |
| 34 | +})(); |
| 35 | + |
| 36 | +// Replaced with the git tag by Box at compile time; stays literal when run from |
| 37 | +// source. The '@' check must not reference the placeholder string itself, |
| 38 | +// otherwise Box would replace it here too. |
| 39 | +$version = '@git_version@'; |
| 40 | +if (str_contains($version, '@')) { |
| 41 | + $version = 'dev'; |
| 42 | +} |
| 43 | + |
| 44 | +$application = new Application('composer-translation-validator', $version); |
| 45 | +// The PHAR bundles the Symfony version pinned in composer.lock (>= 8), where |
| 46 | +// Application::addCommand() replaced the removed add(). |
| 47 | +$application->addCommand(new StandaloneValidateTranslationCommand()); |
| 48 | +$application->setDefaultCommand('validate-translations', true); |
| 49 | + |
| 50 | +exit($application->run()); |
0 commit comments