Skip to content

Commit

Permalink
fix box autoload Neon class in scoper.php.inc by --no-parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jan 6, 2020
1 parent c0a74d3 commit 95874bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions compiler/build/scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// this file will need update sometimes: https://github.com/phpstan/phpstan-src/commits/master/compiler/build/scoper.inc.php
// automate in the future, if needed - @see https://github.com/rectorphp/rector/pull/2575#issuecomment-571133000

require __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';

use Isolated\Symfony\Component\Finder\Finder;
use Nette\Neon\Neon;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

$stubs = [];

Expand Down Expand Up @@ -95,6 +94,7 @@ function (string $filePath, string $prefix, string $content): string {
if (strpos($filePath, '.neon') === false) {
return $content;
}

if ($content === '') {
return $content;
}
Expand All @@ -105,11 +105,15 @@ function (string $filePath, string $prefix, string $content): string {
if (strpos($class, 'PhpParser\\') === 0) {
return $class;
}
if (strpos($class, 'Rector\\') === 0) {
return $class;
}
if (strpos($class, '@') === 0) {
return $class;
}
return $prefix . '\\' . $class;
};

$neon = Neon::decode($content);
$updatedNeon = $neon;
if (array_key_exists('services', $neon)) {
Expand All @@ -123,6 +127,7 @@ function (string $filePath, string $prefix, string $content): string {
$updatedNeon['services'][$key] = $service;
}
}

return Neon::encode($updatedNeon, Neon::BLOCK);
},

Expand Down
4 changes: 3 additions & 1 deletion compiler/src/Console/CompileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->buildDir
);

$this->processFactory->create(['php', 'box.phar', 'compile'], $this->dataDir);
// 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->processFactory->create(['php', 'box.phar', 'compile', '--no-parallel'], $this->dataDir);

$this->restoreComposerJson($composerJsonFile);

Expand Down

0 comments on commit 95874bc

Please sign in to comment.