prepare to release rc3, add dev:php-ver command

This commit is contained in:
crazywhalecc 2023-07-27 23:18:44 +08:00
parent 6131e1881b
commit 752b88f62d
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 34 additions and 1 deletions

View File

@ -16,7 +16,7 @@ use Symfony\Component\Console\Command\ListCommand;
*/
class ConsoleApplication extends Application
{
public const VERSION = '2.0-rc2';
public const VERSION = '2.0-rc3';
/**
* @throws \ReflectionException

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace SPC\command\dev;
use SPC\command\BaseCommand;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand('dev:php-ver', 'Dev command')]
class PhpVerCommand extends BaseCommand
{
public function initialize(InputInterface $input, OutputInterface $output)
{
$this->no_motd = true;
parent::initialize($input, $output);
}
public function handle(): int
{
// Find php from source/php-src
$file = SOURCE_PATH . '/php-src/main/php_version.h';
$result = preg_match('/#define PHP_VERSION "(\d+\.\d+\.\d+)"/', file_get_contents($file), $match);
if ($result === false) {
$this->output->writeln('<error>PHP source not found, maybe you need to extract first ?</error>');
return 1;
}
$this->output->writeln('<info>' . $match[1] . '</info>');
return 0;
}
}