Skip to content

Commit

Permalink
[Scoped] Remove phpstan-extracted code check reference (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Nov 18, 2021
1 parent c6473c6 commit d23308f
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 43 deletions.
13 changes: 0 additions & 13 deletions bin/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,13 @@
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();


// load extracted PHPStan with its own preload.php
$extractedPhpstanAutoload = __DIR__ . '/../vendor/phpstan/phpstan-extracted/vendor/autoload.php';
if (file_exists($extractedPhpstanAutoload)) {
require_once $extractedPhpstanAutoload;
}

if (file_exists(__DIR__ . '/../preload.php') && is_dir(__DIR__ . '/../vendor')) {
require_once __DIR__ . '/../preload.php';
}

require_once __DIR__ . '/../src/constants.php';

// pre-set for PHP 5.6/7.0 downgraded version
$autoloadIncluder->loadIfExistsAndNotLoadedYet(
__DIR__ . '/../vendor/phpstan/phpstan-extracted/vendor/phpstan-autoload.php'
);

$autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');

$autoloadIncluder->autoloadProjectAutoloaderFile();
$autoloadIncluder->autoloadFromCommandLine();

Expand Down Expand Up @@ -129,7 +117,6 @@ public function autoloadFromCommandLine(): void

public function loadIfExistsAndNotLoadedYet(string $filePath): void
{
// the scoper-autoload.php is exists in phpstan-extracted/vendor/scoper-autoload.php, move the check in :
if (! file_exists($filePath)) {
return;
}
Expand Down
7 changes: 0 additions & 7 deletions src/Stubs/PHPStanStubLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,9 @@ public function loadStubs(): void

private function getStubPath(string $vendorPath, string $stub): ?string
{
// @todo: need to be switched when phpstan-extracted used after scoped php 7.0 works
$path = sprintf('phar://%s/phpstan/phpstan/phpstan.phar/stubs/runtime/%s', $vendorPath, $stub);
$isExists = file_exists($path);

if (! $isExists) {
// this is to handle phpstan's stubs got from phpstan-extracted instead of the .phar when exists after scoped php 7.0 applied
$path = sprintf('%s/phpstan/phpstan-extracted/stubs/runtime/%s', $vendorPath, $stub);
$isExists = file_exists($path);
}

if ($isExists) {
return $path;
}
Expand Down
22 changes: 0 additions & 22 deletions utils/compiler/src/Command/DowngradePathsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'bin rector.php',
], $downgradePaths);

if (file_exists(getcwd() . '/vendor/phpstan/phpstan-extracted/vendor')) {
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/phpstan/phpdoc-parser/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/ondrejmirtes/better-reflection/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/di/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/php-generator/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/utils/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/schema/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/finder/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/robot-loader/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/nette/bootstrap/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/ondram/ci-detector/src';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/symfony/finder';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/symfony/console/Output/OutputInterface.php';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/symfony/console/Output/TrimmedBufferOutput.php';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/symfony/console/Logger/ConsoleLogger.php';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/symfony/console/Style/SymfonyStyle.php';
$downgradePaths[] = 'vendor/phpstan/phpstan-extracted/vendor/symfony/console';
$downgradePaths[] = 'vendor/phpstan/phpstan-phpunit/src';
}

// bash format
$downgradePathsLine = implode(';', $downgradePaths);
echo $downgradePathsLine . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion utils/compiler/src/PhpScoper/StaticEasyPrefixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class StaticEasyPrefixer
'PhpParser\*',
'Ssch\TYPO3Rector\*',

// phpstan needs to be here, as phpstan-extracted/vendor autoload is statically generated and namespaces cannot be changed
// phpstan needs to be here, as phpstan/vendor autoload is statically generated and namespaces cannot be changed
'PHPStan\*',

// this is public API of a Rector rule
Expand Down

0 comments on commit d23308f

Please sign in to comment.