Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scoped on PHP 7.0] bin/rector run with extracted phpstan #6371

Merged
merged 2 commits into from
May 6, 2021
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
11 changes: 9 additions & 2 deletions .github/workflows/build_scoped_rector_php70.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,15 @@ jobs:
# extra content of phpstan.phar to vendor/phpstan/phpstan-extracted
- run: php box.phar extract vendor/phpstan/phpstan/phpstan.phar vendor/phpstan/phpstan-extracted

# original phpstan/phpstan is now duplicated, we don't need it now
- run: composer remove phpstan/phpstan
# "composer remove phpstan/phpstan" original phpstan/phpstan is now duplicated, we don't need it now -required by phpstan extensions, cannot be removed like this

# to avoid double packing the same code
- run: rm -rf vendor/bin/phpstan
- run: rm -rf vendor/phpstan/phpstan/phpstan.phar
- run: rm phpstan-for-rector.neon

# THIS MUST WORK
- run: bin/rector downgrade-paths
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far so good :)

image


# 1. copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop
- run: rsync --exclude rector-build-php70 -av * rector-build-php70 --quiet
Expand Down
7 changes: 6 additions & 1 deletion bin/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
$autoloadIncluder = new AutoloadIncluder();
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();

if (should_include_preload()) {

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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"phpstan/phpstan-phpunit": "^0.12.18",
"rector/rector-cakephp": "^0.10.4",
"rector/rector-doctrine": "^0.10.6",
"rector/rector-installer": "^0.10.1",
"rector/extension-installer": "^0.10.2",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sabbelasichon Btw, I flipped the name to extension-installer, as rector-<x> name is used for framework-specific sets. Like rector-nette, rector-symfony etc.
This should make also clear it does not install rector, but extensions.

"rector/rector-laravel": "^0.10.2",
"rector/rector-nette": "^0.10.9",
"rector/rector-nette-to-symfony": "^0.10.0",
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,5 @@ parameters:
paths:
- rules/EarlyReturn/Rector/If_/ChangeNestedIfsToEarlyReturnRector.php
- rules/EarlyReturn/Rector/If_/ChangeAndIfToEarlyReturnRector.php

- '#Class with base "PhpVersionFactory" name is already used in "PHPStan\\Php\\PhpVersionFactory", "Rector\\Core\\Util\\PhpVersionFactory"\. Use unique name to make classes easy to recognize#'
3 changes: 0 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
use Symplify\SymfonyPhpConfig\ValueObjectInliner;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::SETS, [SetList::NAMING]);

// include sets
$containerConfigurator->import(SetList::CODING_STYLE);
$containerConfigurator->import(SetList::CODE_QUALITY);
Expand Down