Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"php": "^7.2",
"nette/neon": "^3.0",
"nette/utils": "^3.0",
"ondram/ci-detector": "^3.3",
"sebastian/diff": "^3.0|^4.0",
"symfony/console": "^4.4|^5.0",
"symfony/process": "^4.4|^5.0",
Expand Down
2 changes: 2 additions & 0 deletions compiler/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ services:
- '../src/HttpKernel/*'

Symfony\Component\Filesystem\Filesystem: null

OndraM\CiDetector\CiDetector: null
1 change: 0 additions & 1 deletion compiler/src/Composer/ComposerJsonManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function fixComposerJson(string $composerJsonFile): void
public function restoreComposerJson(string $composerJsonFile): void
{
$this->filesystem->dumpFile($composerJsonFile, $this->originalComposerJsonFileContent);
// re-run @todo composer update on root
}

private function removeDevKeys(array $json): array
Expand Down
24 changes: 23 additions & 1 deletion compiler/src/Console/Command/CompileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Compiler\Console\Command;

use OndraM\CiDetector\CiDetector;
use Rector\Compiler\Composer\ComposerJsonManipulator;
use Rector\Compiler\Debug\FileLister;
use Rector\Compiler\Renaming\JetbrainsStubsRenamer;
Expand Down Expand Up @@ -49,13 +50,19 @@ final class CompileCommand extends Command
*/
private $fileLister;

/**
* @var CiDetector
*/
private $ciDetector;

public function __construct(
string $dataDir,
string $buildDir,
ComposerJsonManipulator $composerJsonManipulator,
SymfonyStyle $symfonyStyle,
JetbrainsStubsRenamer $jetbrainsStubsRenamer,
FileLister $fileLister
FileLister $fileLister,
CiDetector $ciDetector
) {
$this->dataDir = $dataDir;
$this->buildDir = $buildDir;
Expand All @@ -64,6 +71,7 @@ public function __construct(
$this->jetbrainsStubsRenamer = $jetbrainsStubsRenamer;
$this->fileLister = $fileLister;
$this->symfonyStyle = $symfonyStyle;
$this->ciDetector = $ciDetector;

parent::__construct();
}
Expand Down Expand Up @@ -102,6 +110,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->symfonyStyle->note('You still need to run "composer update" to install those dependencies');
$this->composerJsonManipulator->restoreComposerJson($composerJsonFile);

$this->restoreDependenciesLocallyIfNotCi($output);

return ShellCode::SUCCESS;
}

private function restoreDependenciesLocallyIfNotCi(OutputInterface $output): void
{
if ($this->ciDetector->isCiDetected()) {
return;
}

$process = new Process(['composer', 'install'], $this->buildDir, null, null, null);
$process->mustRun(static function (string $type, string $buffer) use ($output): void {
$output->write($buffer);
});
}
}
1 change: 0 additions & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ services:
exclude:
- '../src/Rector/**/*Rector.php'
- '../src/Testing/PHPUnit/*'
- '../src/Testing/Dumper/*'
- '../src/RectorDefinition/*'
- '../src/Exception/*'
- '../src/DependencyInjection/CompilerPass/*'
Expand Down
98 changes: 0 additions & 98 deletions helpers/extract_class_changes_from_diff.php

This file was deleted.

169 changes: 0 additions & 169 deletions helpers/extract_default_value_changes_from_diff.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace Rector\BetterPhpDocParser\Comment;

use PhpParser\Node;

final class MergedNodeCommentPreserver
{
public function keepComments(Node $newNode, Node ...$mergedNodes): void
{
$comments = [];

foreach ($mergedNodes as $mergedNode) {
$comments = array_merge($comments, $mergedNode->getComments());
}

if ($comments === []) {
return;
}

$comments = array_merge($newNode->getComments(), $comments);
$newNode->setAttribute('comments', $comments);
}
}
Loading