mirror of https://github.com/rectorphp/rector.git
parent
824b15c9ab
commit
d86003f0c9
|
@ -1,13 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Application;
|
||||
|
||||
use DateTime;
|
||||
use Rector\Core\Exception\VersionException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Inspired by https://github.com/composer/composer/blob/master/src/Composer/Composer.php
|
||||
* See https://github.com/composer/composer/blob/6587715d0f8cae0cd39073b3bc5f018d0e6b84fe/src/Composer/Compiler.php#L208
|
||||
|
@ -19,73 +16,41 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '@package_version@';
|
||||
|
||||
public const PACKAGE_VERSION = 'd292e9dab5a3ccc8a690936a67eaf02d2ecc2416';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '@release_date@';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const GIT = 'git';
|
||||
|
||||
public const RELEASE_DATE = '2022-05-29 22:40:09';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private const SUCCESS_CODE = 0;
|
||||
|
||||
public static function resolvePackageVersion(): string
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
// needed to keep exec() in the rector directory, not depending on cwd of run command of scoper
|
||||
$repositoryDirectory = __DIR__ . '/../..';
|
||||
|
||||
// resolve current tag
|
||||
$commandLine = sprintf('cd %s && git tag --points-at', $repositoryDirectory);
|
||||
exec($commandLine, $tagExecOutput, $tagExecResultCode);
|
||||
|
||||
\exec('git tag --points-at', $tagExecOutput, $tagExecResultCode);
|
||||
if ($tagExecResultCode !== self::SUCCESS_CODE) {
|
||||
throw new VersionException(
|
||||
'Ensure to run compile from composer git repository clone and that git binary is available.'
|
||||
);
|
||||
throw new \Rector\Core\Exception\VersionException('Ensure to run compile from composer git repository clone and that git binary is available.');
|
||||
}
|
||||
|
||||
// debug output
|
||||
var_dump($tagExecOutput);
|
||||
|
||||
if ($tagExecOutput !== []) {
|
||||
$tag = $tagExecOutput[0];
|
||||
if ($tag !== '') {
|
||||
return $tag;
|
||||
}
|
||||
}
|
||||
|
||||
$commandLine = sprintf('cd %s && git log --pretty="%%H" -n1 HEAD', $repositoryDirectory);
|
||||
exec($commandLine, $commitHashExecOutput, $commitHashResultCode);
|
||||
|
||||
\exec('git log --pretty="%H" -n1 HEAD', $commitHashExecOutput, $commitHashResultCode);
|
||||
if ($commitHashResultCode !== 0) {
|
||||
throw new VersionException(
|
||||
'Ensure to run compile from composer git repository clone and that git binary is available.'
|
||||
);
|
||||
throw new \Rector\Core\Exception\VersionException('Ensure to run compile from composer git repository clone and that git binary is available.');
|
||||
}
|
||||
|
||||
// debug output
|
||||
var_dump($commitHashExecOutput);
|
||||
|
||||
$version = trim($commitHashExecOutput[0]);
|
||||
return trim($version, '"');
|
||||
$version = \trim($commitHashExecOutput[0]);
|
||||
return \trim($version, '"');
|
||||
}
|
||||
|
||||
public static function resolverReleaseDateTime(): DateTime
|
||||
public static function resolverReleaseDateTime() : \DateTime
|
||||
{
|
||||
$process = new Process([self::GIT, 'log', '-n1', '--pretty=%ci', 'HEAD'], __DIR__);
|
||||
if ($process->run() !== 0) {
|
||||
throw new VersionException(
|
||||
'You must ensure to run compile from composer git repository clone and that git binary is available.'
|
||||
);
|
||||
\exec('git log -n1 --pretty=%ci HEAD', $output, $resultCode);
|
||||
if ($resultCode !== self::SUCCESS_CODE) {
|
||||
throw new \Rector\Core\Exception\VersionException('You must ensure to run compile from composer git repository clone and that git binary is available.');
|
||||
}
|
||||
|
||||
return new DateTime(trim($process->getOutput()));
|
||||
return new \DateTime(\trim($output[0]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915::getLoader();
|
||||
return ComposerAutoloaderInitb46b6aeaf3e35873cae96a943ec65192::getLoader();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915
|
||||
class ComposerAutoloaderInitb46b6aeaf3e35873cae96a943ec65192
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb46b6aeaf3e35873cae96a943ec65192', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb46b6aeaf3e35873cae96a943ec65192', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitff688ad1ad36414b5e0335c1fc3e9915::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb46b6aeaf3e35873cae96a943ec65192::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitff688ad1ad36414b5e0335c1fc3e9915::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitb46b6aeaf3e35873cae96a943ec65192::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequireff688ad1ad36414b5e0335c1fc3e9915($fileIdentifier, $file);
|
||||
composerRequireb46b6aeaf3e35873cae96a943ec65192($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequireff688ad1ad36414b5e0335c1fc3e9915($fileIdentifier, $file)
|
||||
function composerRequireb46b6aeaf3e35873cae96a943ec65192($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitff688ad1ad36414b5e0335c1fc3e9915
|
||||
class ComposerStaticInitb46b6aeaf3e35873cae96a943ec65192
|
||||
{
|
||||
public static $files = array (
|
||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
||||
|
@ -3850,9 +3850,9 @@ class ComposerStaticInitff688ad1ad36414b5e0335c1fc3e9915
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitff688ad1ad36414b5e0335c1fc3e9915::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitff688ad1ad36414b5e0335c1fc3e9915::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitff688ad1ad36414b5e0335c1fc3e9915::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb46b6aeaf3e35873cae96a943ec65192::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb46b6aeaf3e35873cae96a943ec65192::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb46b6aeaf3e35873cae96a943ec65192::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadInclu
|
|||
if (!class_exists('VersionResolver', false) && !interface_exists('VersionResolver', false) && !trait_exists('VersionResolver', false)) {
|
||||
spl_autoload_call('RectorPrefix20220529\VersionResolver');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915', false) && !interface_exists('ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915', false) && !trait_exists('ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915', false)) {
|
||||
spl_autoload_call('RectorPrefix20220529\ComposerAutoloaderInitff688ad1ad36414b5e0335c1fc3e9915');
|
||||
if (!class_exists('ComposerAutoloaderInitb46b6aeaf3e35873cae96a943ec65192', false) && !interface_exists('ComposerAutoloaderInitb46b6aeaf3e35873cae96a943ec65192', false) && !trait_exists('ComposerAutoloaderInitb46b6aeaf3e35873cae96a943ec65192', false)) {
|
||||
spl_autoload_call('RectorPrefix20220529\ComposerAutoloaderInitb46b6aeaf3e35873cae96a943ec65192');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20220529\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
|
@ -62,9 +62,9 @@ if (!function_exists('print_node')) {
|
|||
return \RectorPrefix20220529\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequireff688ad1ad36414b5e0335c1fc3e9915')) {
|
||||
function composerRequireff688ad1ad36414b5e0335c1fc3e9915() {
|
||||
return \RectorPrefix20220529\composerRequireff688ad1ad36414b5e0335c1fc3e9915(...func_get_args());
|
||||
if (!function_exists('composerRequireb46b6aeaf3e35873cae96a943ec65192')) {
|
||||
function composerRequireb46b6aeaf3e35873cae96a943ec65192() {
|
||||
return \RectorPrefix20220529\composerRequireb46b6aeaf3e35873cae96a943ec65192(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
|
Loading…
Reference in New Issue