mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-19 09:32:22 +00:00
Rector and PHPStan cleanup
This commit is contained in:
parent
b446f0c973
commit
12984cbb59
|
@ -3,24 +3,11 @@
|
|||
|
||||
declare(strict_types = 1);
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Rector\Compiler\Console\RectorCompilerConsoleApplication;
|
||||
use Rector\Compiler\HttpKernel\RectorCompilerKernel;
|
||||
use Rector\Compiler\DependencyInjection\ContainerFactory;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
final class ContainerFactory
|
||||
{
|
||||
public function create(): ContainerInterface
|
||||
{
|
||||
$environment = 'prod' . random_int(1, 10000000);
|
||||
$rectorCompilerKernel = new RectorCompilerKernel($environment, true);
|
||||
$rectorCompilerKernel->boot();
|
||||
|
||||
return $rectorCompilerKernel->getContainer();
|
||||
}
|
||||
}
|
||||
|
||||
$containerFactory = new ContainerFactory();
|
||||
$container = $containerFactory->create();
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ return [
|
|||
return $content;
|
||||
}
|
||||
|
||||
return str_replace('__DIR__ . \'/..', '\'phar://rector.phar', $content);
|
||||
return str_replace("__DIR__ . '/..", '\'phar://rector.phar', $content);
|
||||
},
|
||||
function (string $filePath, string $prefix, string $content): string {
|
||||
if ($filePath !== 'vendor/nette/di/src/DI/Compiler.php') {
|
||||
|
@ -41,7 +41,7 @@ return [
|
|||
if ($filePath !== 'vendor/nette/di/src/DI/Config/DefinitionSchema.php') {
|
||||
return $content;
|
||||
}
|
||||
$content = str_replace(sprintf('\'%s\\\\callable', $prefix), '\'callable', $content);
|
||||
$content = str_replace(sprintf('\'%s\\\\callable', $prefix), "'callable", $content);
|
||||
return str_replace(
|
||||
'|Nette\\\\DI\\\\Definitions\\\\Statement',
|
||||
sprintf('|%s\\\\Nette\\\\DI\\\\Definitions\\\\Statement', $prefix),
|
||||
|
|
|
@ -11,6 +11,7 @@ services:
|
|||
resource: '../src'
|
||||
exclude:
|
||||
- '../src/Exception/*'
|
||||
- '../src/DependencyInjection/*'
|
||||
- '../src/HttpKernel/*'
|
||||
- '../src/PhpScoper/*'
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ final class CompileCommand extends Command
|
|||
$this->symfonyStyle->newLine(2);
|
||||
|
||||
$this->symfonyStyle->title('2. Running "composer update" without dev');
|
||||
|
||||
$process = new Process([
|
||||
'composer',
|
||||
'update',
|
||||
|
@ -93,6 +94,7 @@ final class CompileCommand extends Command
|
|||
'--classmap-authoritative',
|
||||
'--ansi',
|
||||
], $this->buildDir, null, null, null);
|
||||
|
||||
$process->mustRun(static function (string $type, string $buffer) use ($output): void {
|
||||
$output->write($buffer);
|
||||
});
|
||||
|
@ -100,6 +102,7 @@ final class CompileCommand extends Command
|
|||
$this->symfonyStyle->newLine(2);
|
||||
|
||||
$this->symfonyStyle->title('3. Renaming PHPStorm stubs from "*.php" to ".stub"');
|
||||
|
||||
$this->jetbrainsStubsRenamer->renamePhpStormStubs($this->buildDir);
|
||||
|
||||
$this->symfonyStyle->newLine(2);
|
||||
|
@ -107,7 +110,9 @@ final class CompileCommand extends Command
|
|||
// the '--no-parallel' is needed, so "scoper.php.inc" can "require __DIR__ ./vendor/autoload.php"
|
||||
// and "Nette\Neon\Neon" class can be used there
|
||||
$this->symfonyStyle->title('4. Packing and prefixing rector.phar with Box and PHP Scoper');
|
||||
|
||||
$process = new Process(['php', 'box.phar', 'compile', '--no-parallel'], $this->dataDir, null, null, null);
|
||||
|
||||
$process->mustRun(static function (string $type, string $buffer) use ($output): void {
|
||||
$output->write($buffer);
|
||||
});
|
||||
|
|
20
compiler/src/DependencyInjection/ContainerFactory.php
Normal file
20
compiler/src/DependencyInjection/ContainerFactory.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Compiler\DependencyInjection;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Rector\Compiler\HttpKernel\RectorCompilerKernel;
|
||||
|
||||
final class ContainerFactory
|
||||
{
|
||||
public function create(): ContainerInterface
|
||||
{
|
||||
$environment = 'prod' . random_int(1, 10000000);
|
||||
$rectorCompilerKernel = new RectorCompilerKernel($environment, true);
|
||||
$rectorCompilerKernel->boot();
|
||||
|
||||
return $rectorCompilerKernel->getContainer();
|
||||
}
|
||||
}
|
|
@ -36,6 +36,6 @@ final class StaticEasyPrefixer
|
|||
|
||||
$match = sprintf('\'%s\\\\', $prefix);
|
||||
|
||||
return Strings::replace($content, '#' . $match . '#', '\'');
|
||||
return Strings::replace($content, '#' . $match . '#', "'");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ parameters:
|
|||
- 'tests'
|
||||
- 'utils'
|
||||
- 'compiler/src'
|
||||
- 'compiler/bin/compile'
|
||||
- 'compiler/build/scoper.inc.php'
|
||||
|
||||
autoload_paths:
|
||||
- 'compiler/src'
|
||||
|
|
Loading…
Reference in New Issue
Block a user