mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-08 12:20:52 +00:00
[scoper] keep phpstan.phar to avoid conflict in install (#5009)
* fix scoping of Symfony autodiscovery namespace * scoped: add along phpstan run * wait longer, the old version is used * keep phpstan.phar
This commit is contained in:
parent
34a2a497b3
commit
520335251d
3
.github/workflows/build_scoped_rector.yaml
vendored
3
.github/workflows/build_scoped_rector.yaml
vendored
|
@ -3,7 +3,8 @@ name: Build Scoped Rector
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: master
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build_scoped_rector:
|
||||
|
|
|
@ -34,7 +34,6 @@ $autoloadIncluder->loadIfExistsAndNotLoadedYet(getcwd() . '/vendor/autoload.php'
|
|||
|
||||
$autoloadIncluder->autoloadProjectAutoloaderFile();
|
||||
$autoloadIncluder->autoloadFromCommandLine();
|
||||
$autoloadIncluder->autoloadPhpStanExtracted();
|
||||
|
||||
$symfonyStyleFactory = new SymfonyStyleFactory(new PrivatesCaller());
|
||||
$symfonyStyle = $symfonyStyleFactory->create();
|
||||
|
@ -105,14 +104,6 @@ final class AutoloadIncluder
|
|||
$this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../../autoload.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* This autoloads extracted PHPStan autoload
|
||||
*/
|
||||
public function autoloadPhpStanExtracted(): void
|
||||
{
|
||||
$this->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/phpstan/phpstan-extracted/vendor/autoload.php');
|
||||
}
|
||||
|
||||
public function autoloadFromCommandLine(): void
|
||||
{
|
||||
$cliArgs = $_SERVER['argv'];
|
||||
|
|
|
@ -32,11 +32,6 @@ rsync -av * "$NESTED_DIRECTORY" --quiet
|
|||
note "Running composer update without dev"
|
||||
composer update --no-dev --no-progress --ansi --working-dir "$NESTED_DIRECTORY"
|
||||
|
||||
# Unpacking PHPStan
|
||||
note "Unpacking PHPStan"
|
||||
wget https://github.com/box-project/box/releases/download/3.11.0/box.phar -N --no-verbose
|
||||
php box.phar extract "$NESTED_DIRECTORY/vendor/phpstan/phpstan/phpstan.phar" "$NESTED_DIRECTORY/vendor/phpstan/phpstan-extracted"
|
||||
|
||||
# this will remove dependency on dev packages that are imported in phpstan.neon
|
||||
rm -f "$NESTED_DIRECTORY/phpstan-for-rector.neon"
|
||||
|
||||
|
@ -50,14 +45,9 @@ wget https://github.com/humbug/php-scoper/releases/download/0.14.0/php-scoper.ph
|
|||
|
||||
php php-scoper.phar add-prefix bin config packages rules src templates vendor composer.json --output-dir "../$SCOPED_DIRECTORY" --config scoper.php.inc --force --ansi --working-dir "$NESTED_DIRECTORY"
|
||||
|
||||
# keep only one PHPStan version
|
||||
note "Remove package phpstan version"
|
||||
rm -rf "$SCOPED_DIRECTORY/vendor/phpstan/phpstan"
|
||||
|
||||
note "Dumping Composer Autoload"
|
||||
composer dump-autoload --working-dir "$SCOPED_DIRECTORY" --ansi --optimize --classmap-authoritative --no-dev
|
||||
|
||||
|
||||
# clean up
|
||||
rm -rf "$NESTED_DIRECTORY"
|
||||
|
||||
|
@ -66,7 +56,6 @@ note "Copy metafiles like composer.json, .github etc to repository"
|
|||
rm -f "$SCOPED_DIRECTORY/composer.json"
|
||||
cp -R scoped/. "$SCOPED_DIRECTORY"
|
||||
|
||||
|
||||
# make bin/rector runnable without "php"
|
||||
chmod 777 "$SCOPED_DIRECTORY/bin/rector"
|
||||
chmod 777 "$SCOPED_DIRECTORY/bin/rector.php"
|
||||
|
|
2
scoped/.github/workflows/along_phpstan.yaml
vendored
2
scoped/.github/workflows/along_phpstan.yaml
vendored
|
@ -26,11 +26,13 @@ jobs:
|
|||
cd standalone
|
||||
# wait for deploy to packagist
|
||||
sleep 60
|
||||
|
||||
- run: |
|
||||
cd standalone
|
||||
# run
|
||||
composer require rector/rector-prefixed:dev-master --dev --ansi
|
||||
composer require phpstan/phpstan --dev --ansi
|
||||
|
||||
-
|
||||
run: |
|
||||
cd standalone
|
||||
|
|
|
@ -40,7 +40,7 @@ jobs:
|
|||
mkdir standalone
|
||||
cd standalone
|
||||
# wait for deploy to packagist
|
||||
sleep 45
|
||||
sleep 60
|
||||
|
||||
- run: |
|
||||
cd standalone
|
||||
|
|
|
@ -25,7 +25,7 @@ jobs:
|
|||
mkdir standalone
|
||||
cd standalone
|
||||
# wait for deploy to packagist
|
||||
sleep 45
|
||||
sleep 60
|
||||
|
||||
- run: |
|
||||
cd standalone
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"bin/rector"
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.3|^8.0"
|
||||
"php": "^7.3|^8.0",
|
||||
"phpstan/phpstan": "^0.12.64"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use Nette\Utils\DateTime;
|
|||
use Nette\Utils\Strings;
|
||||
use Rector\Compiler\PhpScoper\StaticEasyPrefixer;
|
||||
use Rector\Compiler\ValueObject\ScoperOption;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
|
@ -17,16 +16,6 @@ $filePathsToSkip = [
|
|||
];
|
||||
|
||||
// remove phpstan, because it is already prefixed in its own scope
|
||||
$finder = new Finder();
|
||||
$phpstanPhpFileInfos = $finder->files()
|
||||
->name('*.php')
|
||||
// the working dir is already "rector-nested"
|
||||
->in(__DIR__ . '/vendor/phpstan/phpstan-extracted')
|
||||
->getIterator();
|
||||
|
||||
foreach ($phpstanPhpFileInfos as $phpstanPhpFileInfo) {
|
||||
$filePathsToSkip[] = $phpstanPhpFileInfo->getRealPath();
|
||||
}
|
||||
|
||||
$dateTime = DateTime::from('now');
|
||||
$timestamp = $dateTime->format('Ymd');
|
||||
|
@ -41,7 +30,8 @@ return [
|
|||
|
||||
// scoper missed PSR-4 autodiscovery in Symfony
|
||||
function (string $filePath, string $prefix, string $content): string {
|
||||
if (!Strings::endsWith($filePath, 'config.php') && !Strings::endsWith($filePath, 'services.php')) {
|
||||
// scoper missed PSR-4 autodiscovery in Symfony
|
||||
if (! Strings::endsWith($filePath, 'config.php') && ! Strings::endsWith($filePath, 'services.php')) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
@ -51,6 +41,6 @@ return [
|
|||
}
|
||||
|
||||
return Strings::replace($content, '#services\->load\(\'#', 'services->load(\'' . $prefix . '\\');
|
||||
}
|
||||
},
|
||||
],
|
||||
];
|
||||
|
|
|
@ -25,8 +25,10 @@ final class StaticEasyPrefixer
|
|||
'Rector\*',
|
||||
// we use this API a lot
|
||||
'PhpParser\*',
|
||||
|
||||
// phpstan needs to be here, as phpstan-extracted/vendor autoload is statically generated and namespaces cannot be changed
|
||||
'PHPStan\*',
|
||||
// 'Symplify\*',
|
||||
|
||||
// doctrine annotations to autocomplete
|
||||
'Doctrine\ORM\Mapping\*',
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue
Block a user