mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-13 03:45:21 +01:00
remove unused files
This commit is contained in:
parent
d56e7982d0
commit
45a81bdfa9
@ -1,9 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
20
.gitignore
vendored
20
.gitignore
vendored
@ -1,20 +0,0 @@
|
||||
/vendor
|
||||
composer.lock
|
||||
|
||||
# PHPStorm meta files
|
||||
.idea/
|
||||
|
||||
.phpunit.result.cache
|
||||
|
||||
# often customized locally - example on Github is just fine
|
||||
rector-recipe.php
|
||||
|
||||
# testing
|
||||
abz
|
||||
|
||||
# scoped & downgraded version
|
||||
php-scoper.phar
|
||||
box.phar
|
||||
php-parallel-lint
|
||||
|
||||
tmp
|
@ -1,122 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// see https://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata
|
||||
namespace PHPSTORM_META;
|
||||
|
||||
// $container->get(Type::class) → instance of "Type"
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
|
||||
override(\Psr\Container\ContainerInterface::get(0), type(0));
|
||||
|
||||
expectedArguments(
|
||||
\PHPStan\PhpDocParser\Ast\Node::getAttribute(),
|
||||
0,
|
||||
PhpDocAttributeKey::START_AND_END,
|
||||
PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION,
|
||||
PhpDocAttributeKey::PARENT,
|
||||
);
|
||||
|
||||
expectedArguments(
|
||||
\PHPStan\PhpDocParser\Ast\Node::setAttribute(),
|
||||
0,
|
||||
PhpDocAttributeKey::START_AND_END,
|
||||
PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION,
|
||||
PhpDocAttributeKey::PARENT,
|
||||
);
|
||||
|
||||
expectedArguments(
|
||||
\PHPStan\PhpDocParser\Ast\Node::hasAttribute(),
|
||||
0,
|
||||
PhpDocAttributeKey::START_AND_END,
|
||||
PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION,
|
||||
PhpDocAttributeKey::PARENT,
|
||||
);
|
||||
|
||||
|
||||
// PhpStorm 2019.1 - add argument autocomplete
|
||||
// https://blog.jetbrains.com/phpstorm/2019/02/new-phpstorm-meta-php-features/
|
||||
expectedArguments(
|
||||
\PhpParser\Node::getAttribute(),
|
||||
0,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::METHOD_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_STATEMENT,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::USE_NODES,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::START_TOKEN_POSITION,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::KIND,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NAME,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ARGUMENT_POSITION,
|
||||
);
|
||||
|
||||
expectedArguments(
|
||||
\PhpParser\Node::setAttribute(),
|
||||
0,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::METHOD_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::NEXT_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PREVIOUS_STATEMENT,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::USE_NODES,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::START_TOKEN_POSITION,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::IS_UNREACHABLE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::KIND,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ORIGINAL_NAME,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::VIRTUAL_NODE,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::PARAMETER_POSITION,
|
||||
\Rector\NodeTypeResolver\Node\AttributeKey::ARGUMENT_POSITION,
|
||||
);
|
||||
|
||||
expectedArguments(
|
||||
\Rector\Core\Rector\AbstractRector::isAtLeastPhpVersion(),
|
||||
0,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::DIR_CONSTANT,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::ELVIS_OPERATOR,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::CLASSNAME_CONSTANT,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::EXP_OPERATOR,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::SCALAR_TYPES,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::NULL_COALESCE,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::SPACESHIP,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::DIRNAME_LEVELS,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::CSPRNG_FUNCTIONS,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::THROWABLE_TYPE,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::ITERABLE_TYPE,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::VOID_TYPE,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::CONSTANT_VISIBILITY,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::ARRAY_DESTRUCT,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::MULTI_EXCEPTION_CATCH,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::OBJECT_TYPE,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::IS_COUNTABLE,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::ARRAY_KEY_FIRST_LAST,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::JSON_EXCEPTION,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::SETCOOKIE_ACCEPT_ARRAY_OPTIONS,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::ARROW_FUNCTION,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::LITERAL_SEPARATOR,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::NULL_COALESCE_ASSIGN,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::COVARIANT_RETURN,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::ARRAY_SPREAD,
|
||||
\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES,
|
||||
);
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
// inspired at https://github.com/phpstan/phpstan-src/commit/87897c2a4980d68efa1c46049ac2eefe767ec946#diff-e897e523125a694bd8ea69bf83374c206803c98720c46d7401b7a7cf53915a26
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$buildDirectory = $argv[1];
|
||||
|
||||
buildPreloadScript($buildDirectory);
|
||||
|
||||
function buildPreloadScript(string $buildDirectory): void
|
||||
{
|
||||
$vendorDir = $buildDirectory . '/vendor';
|
||||
if (!is_dir($vendorDir . '/nikic/php-parser/lib/PhpParser')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$preloadFileContent = <<<'php'
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
|
||||
php;
|
||||
|
||||
$finder = (new Finder())
|
||||
->files()
|
||||
->name('*.php')
|
||||
->in($vendorDir . '/nikic/php-parser/lib/PhpParser')
|
||||
->notPath('#\/tests\/#')
|
||||
->notPath('#\/config\/#')
|
||||
->notPath('#\/set\/#')
|
||||
->in($vendorDir . '/symplify/symfony-php-config');
|
||||
|
||||
foreach ($finder->getIterator() as $fileInfo) {
|
||||
$realPath = $fileInfo->getRealPath();
|
||||
if ($realPath === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filePath = '/vendor/' . Strings::after($realPath, 'vendor/');
|
||||
$preloadFileContent .= "require_once __DIR__ . '" . $filePath . "';" . PHP_EOL;
|
||||
}
|
||||
|
||||
file_put_contents($buildDirectory . '/preload.php', $preloadFileContent);
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# see https://stackoverflow.com/questions/66644233/how-to-propagate-colors-from-bash-script-to-github-action?noredirect=1#comment117811853_66644233
|
||||
export TERM=xterm-color
|
||||
|
||||
# show errors
|
||||
set -e
|
||||
|
||||
# script fails if trying to access to an undefined variable
|
||||
set -u
|
||||
|
||||
|
||||
# functions
|
||||
note()
|
||||
{
|
||||
MESSAGE=$1;
|
||||
|
||||
printf "\n";
|
||||
echo "[NOTE] $MESSAGE";
|
||||
printf "\n";
|
||||
}
|
||||
|
||||
|
||||
# configure here
|
||||
BUILD_DIRECTORY=$1
|
||||
RESULT_DIRECTORY=$2
|
||||
|
||||
# ---------------------------
|
||||
|
||||
note "Starts"
|
||||
|
||||
# this will remove dependency on dev packages that are imported in phpstan.neon
|
||||
rm -f "$BUILD_DIRECTORY/phpstan-for-rector.neon"
|
||||
|
||||
# 2. scope it
|
||||
note "Running scoper to $RESULT_DIRECTORY"
|
||||
wget https://github.com/humbug/php-scoper/releases/download/0.14.0/php-scoper.phar -N --no-verbose
|
||||
|
||||
# Work around possible PHP memory limits
|
||||
php -d memory_limit=-1 php-scoper.phar add-prefix preload.php bin config src packages rules upgrade vendor composer.json --output-dir "../$RESULT_DIRECTORY" --config scoper-php70.php --force --ansi --working-dir "$BUILD_DIRECTORY"
|
||||
|
||||
# after not used for scoping, remove composer/composer
|
||||
rm -rf "$RESULT_DIRECTORY/vendor/composer/composer"
|
||||
|
||||
# note "Dumping Composer Autoload"
|
||||
composer dump-autoload --working-dir "$RESULT_DIRECTORY" --ansi --classmap-authoritative --no-dev
|
||||
|
||||
php "$BUILD_DIRECTORY/build/build-preload.php" $RESULT_DIRECTORY
|
||||
|
||||
rm -rf "$BUILD_DIRECTORY"
|
||||
|
||||
|
||||
# copy metafiles needed for release
|
||||
note "Copy metafiles like composer.json, .github etc to repository"
|
||||
rm -f "$RESULT_DIRECTORY/composer.json"
|
||||
|
||||
# make bin/rector runnable without "php"
|
||||
chmod 777 "$RESULT_DIRECTORY/bin/rector"
|
||||
chmod 777 "$RESULT_DIRECTORY/bin/rector.php"
|
||||
|
||||
note "Finished"
|
@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# see https://stackoverflow.com/questions/66644233/how-to-propagate-colors-from-bash-script-to-github-action?noredirect=1#comment117811853_66644233
|
||||
export TERM=xterm-color
|
||||
|
||||
# show errors
|
||||
set -e
|
||||
|
||||
# script fails if trying to access to an undefined variable
|
||||
set -u
|
||||
|
||||
|
||||
# functions
|
||||
note()
|
||||
{
|
||||
MESSAGE=$1;
|
||||
|
||||
printf "\n";
|
||||
echo "[NOTE] $MESSAGE";
|
||||
printf "\n";
|
||||
}
|
||||
|
||||
|
||||
# configure here
|
||||
BUILD_DIRECTORY=$1
|
||||
RESULT_DIRECTORY=$2
|
||||
|
||||
# ---------------------------
|
||||
|
||||
note "Starts"
|
||||
|
||||
# this will remove dependency on dev packages that are imported in phpstan.neon
|
||||
rm -f "$BUILD_DIRECTORY/phpstan-for-rector.neon"
|
||||
|
||||
# 2. scope it
|
||||
note "Running scoper to $RESULT_DIRECTORY"
|
||||
wget https://github.com/humbug/php-scoper/releases/download/0.14.0/php-scoper.phar -N --no-verbose
|
||||
|
||||
# Work around possible PHP memory limits
|
||||
php -d memory_limit=-1 php-scoper.phar add-prefix preload.php bin config src packages rules upgrade vendor composer.json --output-dir "../$RESULT_DIRECTORY" --config scoper.php --force --ansi --working-dir "$BUILD_DIRECTORY"
|
||||
|
||||
|
||||
# note "Dumping Composer Autoload"
|
||||
composer dump-autoload --working-dir "$RESULT_DIRECTORY" --ansi --classmap-authoritative --no-dev
|
||||
|
||||
php "$BUILD_DIRECTORY/build/build-preload.php" $RESULT_DIRECTORY
|
||||
|
||||
rm -rf "$BUILD_DIRECTORY"
|
||||
|
||||
|
||||
# copy metafiles needed for release
|
||||
note "Copy metafiles like composer.json, .github etc to repository"
|
||||
rm -f "$RESULT_DIRECTORY/composer.json"
|
||||
|
||||
# make bin/rector runnable without "php"
|
||||
chmod 777 "$RESULT_DIRECTORY/bin/rector"
|
||||
chmod 777 "$RESULT_DIRECTORY/bin/rector.php"
|
||||
|
||||
note "Finished"
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Stubs\PHPStanStubLoader;
|
||||
use Rector\Set\ValueObject\DowngradeSetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
$phpStanStubLoader = new PHPStanStubLoader();
|
||||
$phpStanStubLoader->loadStubs();
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::SKIP, DowngradeRectorConfig::DEPENDENCY_EXCLUDE_PATHS);
|
||||
|
||||
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, __DIR__ . '/phpstan-for-downgrade.neon');
|
||||
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_80);
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_74);
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_73);
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_72);
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_71);
|
||||
};
|
||||
|
||||
/**
|
||||
* Configuration consts for the different rector.php config files
|
||||
*/
|
||||
final class DowngradeRectorConfig
|
||||
{
|
||||
/**
|
||||
* Exclude paths when downgrading a dependency
|
||||
*/
|
||||
public const DEPENDENCY_EXCLUDE_PATHS = [
|
||||
'*/tests/*',
|
||||
// symfony test are parts of package
|
||||
'*/Test/*',
|
||||
|
||||
// missing phpunit test case
|
||||
'packages/Testing/PHPUnit/AbstractRectorTestCase.php',
|
||||
'packages/Testing/PHPUnit/AbstractComposerRectorTestCase.php',
|
||||
|
||||
// only for dev
|
||||
'packages/Testing/PhpConfigPrinter/*',
|
||||
|
||||
// Individual classes that can be excluded because
|
||||
// they are not used by Rector, and they use classes
|
||||
// loaded with "require-dev" so it'd throw an error
|
||||
|
||||
// use relative paths, so files are excluded on nested directory too
|
||||
'vendor/symfony/http-kernel/HttpKernelBrowser.php',
|
||||
'vendor/symfony/http-foundation/Session/*',
|
||||
'vendor/symfony/string/Slugger/AsciiSlugger.php',
|
||||
'vendor/symfony/cache/*',
|
||||
'nette/caching/src/Bridges/*',
|
||||
|
||||
// This class has an issue for PHP 7.1:
|
||||
// https://github.com/rectorphp/rector/issues/4816#issuecomment-743209526
|
||||
// It doesn't happen often, and Rector doesn't use it, so then
|
||||
// we simply skip downgrading this class
|
||||
'vendor/symfony/dependency-injection/ExpressionLanguage.php',
|
||||
'vendor/symfony/dependency-injection/ExpressionLanguageProvider.php',
|
||||
'vendor/symfony/var-dumper/Caster/*',
|
||||
];
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Stubs\PHPStanStubLoader;
|
||||
use Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector;
|
||||
use Rector\Set\ValueObject\DowngradeSetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
$phpStanStubLoader = new PHPStanStubLoader();
|
||||
$phpStanStubLoader->loadStubs();
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$skip = array_merge(
|
||||
DowngradeRectorConfig::DEPENDENCY_EXCLUDE_PATHS,
|
||||
[
|
||||
// should be skipped until phpstan is downgraded to avoid conflict like this https://github.com/rectorphp/rector-prefixed/runs/2422176105#step:4:4
|
||||
DowngradeNullableTypeDeclarationRector::class
|
||||
]
|
||||
);
|
||||
$parameters->set(Option::SKIP, $skip);
|
||||
|
||||
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, __DIR__ . '/phpstan-for-downgrade.neon');
|
||||
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_80);
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_74);
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_73);
|
||||
$containerConfigurator->import(DowngradeSetList::PHP_72);
|
||||
};
|
||||
|
||||
/**
|
||||
* Configuration consts for the different rector.php config files
|
||||
*/
|
||||
final class DowngradeRectorConfig
|
||||
{
|
||||
/**
|
||||
* Exclude paths when downgrading a dependency
|
||||
*/
|
||||
public const DEPENDENCY_EXCLUDE_PATHS = [
|
||||
'*/tests/*',
|
||||
// symfony test are parts of package
|
||||
'*/Test/*',
|
||||
|
||||
// missing phpunit test case
|
||||
'packages/Testing/PHPUnit/AbstractRectorTestCase.php',
|
||||
'packages/Testing/PHPUnit/AbstractComposerRectorTestCase.php',
|
||||
|
||||
// only for dev
|
||||
'packages/Testing/PhpConfigPrinter/*',
|
||||
|
||||
// Individual classes that can be excluded because
|
||||
// they are not used by Rector, and they use classes
|
||||
// loaded with "require-dev" so it'd throw an error
|
||||
|
||||
// use relative paths, so files are excluded on nested directory too
|
||||
'vendor/symfony/http-kernel/HttpKernelBrowser.php',
|
||||
'vendor/symfony/http-foundation/Session/*',
|
||||
'vendor/symfony/string/Slugger/AsciiSlugger.php',
|
||||
'vendor/symfony/cache/*',
|
||||
'nette/caching/src/Bridges/*',
|
||||
|
||||
// This class has an issue for PHP 7.1:
|
||||
// https://github.com/rectorphp/rector/issues/4816#issuecomment-743209526
|
||||
// It doesn't happen often, and Rector doesn't use it, so then
|
||||
// we simply skip downgrading this class
|
||||
'vendor/symfony/dependency-injection/ExpressionLanguage.php',
|
||||
'vendor/symfony/dependency-injection/ExpressionLanguageProvider.php',
|
||||
'vendor/symfony/var-dumper/Caster/*',
|
||||
];
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
# this config has extensions, that helps PHPStan inside Rector to resolve more precise types
|
||||
parameters:
|
||||
inferPrivatePropertyTypeFromConstructor: true
|
||||
|
||||
scanDirectories:
|
||||
# this is needed for symfony/dependendency-injection as it has hidden dependency on symfony/expression-language that we don't use here
|
||||
- ../../stubs
|
||||
|
||||
# see https://github.com/rectorphp/rector/issues/3490#issue-634342324
|
||||
featureToggles:
|
||||
disableRuntimeReflectionProvider: true
|
@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# see https://stackoverflow.com/questions/66644233/how-to-propagate-colors-from-bash-script-to-github-action?noredirect=1#comment117811853_66644233
|
||||
export TERM=xterm-color
|
||||
|
||||
# show errors
|
||||
set -e
|
||||
|
||||
# script fails if trying to access to an undefined variable
|
||||
set -u
|
||||
|
||||
|
||||
# configure - 1st argument, use like
|
||||
# sh build/downgrade-rector.sh <directory-with-code-to-downgrade>
|
||||
BUILD_DIRECTORY=$1
|
||||
|
||||
#---------------------------------------------
|
||||
|
||||
# 1. downgrade it
|
||||
echo "[NOTE] Running downgrade in '$BUILD_DIRECTORY' directory\n";
|
||||
|
||||
# 3. provide directories to downgrade; includes the rector dirs
|
||||
directories=$(php -d memory_limit=-1 bin/rector downgrade-paths --config build/config/config-downgrade-php70.php --working-dir $BUILD_DIRECTORY --ansi)
|
||||
|
||||
# split array see https://stackoverflow.com/a/1407098/1348344
|
||||
export IFS=";"
|
||||
|
||||
# 4. downgrade the directories
|
||||
for directory in $directories; do
|
||||
echo "[NOTE] Downgrading '$directory' directory\n"
|
||||
|
||||
# --working-dir is needed, so "SKIP" parameter is applied in absolute path of nested directory
|
||||
php -d memory_limit=-1 bin/rector process $directory --config build/config/config-downgrade-php70.php --working-dir $BUILD_DIRECTORY --ansi
|
||||
done
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# see https://stackoverflow.com/questions/66644233/how-to-propagate-colors-from-bash-script-to-github-action?noredirect=1#comment117811853_66644233
|
||||
export TERM=xterm-color
|
||||
|
||||
# show errors
|
||||
set -e
|
||||
|
||||
# script fails if trying to access to an undefined variable
|
||||
set -u
|
||||
|
||||
|
||||
# configure - 1st argument, use like
|
||||
# sh build/downgrade-rector.sh <directory-with-code-to-downgrade>
|
||||
BUILD_DIRECTORY=$1
|
||||
|
||||
#---------------------------------------------
|
||||
|
||||
# 1. downgrade it
|
||||
echo "[NOTE] Running downgrade in '$BUILD_DIRECTORY' directory\n";
|
||||
|
||||
# 2. debug downgrade paths
|
||||
bin/rector downgrade-paths --config build/config/config-downgrade.php --working-dir $BUILD_DIRECTORY --ansi
|
||||
|
||||
# 3. provide directories to downgrade; includes the rector dirs
|
||||
directories=$(php bin/rector downgrade-paths --config build/config/config-downgrade.php --working-dir $BUILD_DIRECTORY --ansi)
|
||||
# experimental
|
||||
|
||||
# split array see https://stackoverflow.com/a/1407098/1348344
|
||||
export IFS=";"
|
||||
|
||||
# 4. downgrade the directories
|
||||
for directory in $directories; do
|
||||
echo "[NOTE] Downgrading '$directory' directory\n"
|
||||
|
||||
# --working-dir is needed, so "SKIP" parameter is applied in absolute path of nested directory
|
||||
php -d memory_limit=-1 bin/rector process $directory --config build/config/config-downgrade.php --working-dir $BUILD_DIRECTORY --ansi
|
||||
done
|
@ -1,27 +0,0 @@
|
||||
name: Bare Run
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
bare_run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php_version: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php_version }}
|
||||
coverage: none
|
||||
|
||||
- run: php bin/rector list --ansi
|
@ -1,60 +0,0 @@
|
||||
name: Rector Run
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
rector_run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php_version: ['7.0', 7.1', '7.2', '7.3', '7.4', '8.0']
|
||||
commands:
|
||||
-
|
||||
name: 'Finalize Entity'
|
||||
install: composer require doctrine/orm
|
||||
run: vendor/bin/rector process ../tests/fixture-finalize --config ../ci/rector-finalize.php --ansi
|
||||
|
||||
-
|
||||
name: 'Composer Dependency'
|
||||
install: composer require symfony/console 2.8
|
||||
run: vendor/bin/rector list --debug --ansi
|
||||
|
||||
-
|
||||
name: 'Along PHPStan'
|
||||
install: composer require phpstan/phpstan --dev --ansi
|
||||
run: |
|
||||
vendor/bin/rector list --ansi
|
||||
vendor/bin/phpstan -h --ansi
|
||||
|
||||
name: "PHP ${{ matrix.php_version }}"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php_version }}
|
||||
coverage: none
|
||||
|
||||
- run: |
|
||||
mkdir standalone
|
||||
cd standalone
|
||||
# wait for deploy to packagist
|
||||
sleep 70
|
||||
|
||||
- run: |
|
||||
cd standalone
|
||||
# run
|
||||
composer require rector/rector-prefixed:dev-main --dev --ansi
|
||||
${{ matrix.commands.install }}
|
||||
|
||||
-
|
||||
run: |
|
||||
cd standalone
|
||||
${{ matrix.commands.run }}
|
@ -1,21 +0,0 @@
|
||||
name: PHP 8 Attributes
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
php8_attributes:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
coverage: none
|
||||
|
||||
- run: bin/rector process tests/fixture-php8-attributes --config ci/rector-attributes.php --ansi
|
@ -1,22 +0,0 @@
|
||||
name: Simple Test
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
simple_test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.4
|
||||
coverage: none
|
||||
|
||||
- run: composer require phpunit/phpunit --dev
|
||||
- run: vendor/bin/phpunit tests/Rector/RenameSimpleRectorTest.php
|
@ -1,25 +0,0 @@
|
||||
# Prefixed Rector
|
||||
|
||||
[![Build Status Github Actions](https://img.shields.io/github/workflow/status/rectorphp/rector-prefixed/Code_Checks?style=flat-square)](https://github.com/rectorphp/rector-prefixed/actions)
|
||||
[![Downloads](https://img.shields.io/packagist/dt/rector/rector-prefixed.svg?style=flat-square)](https://packagist.org/packages/rector/rector-prefixed)
|
||||
|
||||
Do you have conflicts on Rector install? You're in the right place. Prefixed Rector can [be installed even on very old Symfony](https://getrector.org/blog/2020/01/20/how-to-install-rector-despite-composer-conflicts).
|
||||
|
||||
Do you have older PHP? Rector prefixed goes down to PHP 7.0, so you can install it even on older projects.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
composer require rector/rector-prefixed --dev
|
||||
```
|
||||
|
||||
```bash
|
||||
# generate "rector.php" config
|
||||
vendor/bin/rector init
|
||||
|
||||
# dry run
|
||||
vendor/bin/rector process src --dry-run
|
||||
|
||||
# changing run
|
||||
vendor/bin/rector process src
|
||||
```
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\Symfony\Set\SymfonySetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
// route class must exist and be loaded, as annotation parser uses dynamic reflection
|
||||
require_once __DIR__ . '/../stubs/Symfony/Component/Routing/Annotation/Route.php';
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$containerConfigurator->import(SymfonySetList::SYMFONY_52);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
|
||||
};
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(FinalizeClassesWithoutChildrenRector::class);
|
||||
};
|
@ -1,16 +0,0 @@
|
||||
{
|
||||
"name": "rector/rector-prefixed-php70",
|
||||
"description": "Prefixed and PHP 7.0 downgraded version of rector/rector",
|
||||
"license": "MIT",
|
||||
"bin": [
|
||||
"bin/rector"
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.0|^8.0"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.10-dev"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<phpunit
|
||||
bootstrap="tests/bootstrap.php"
|
||||
colors="true"
|
||||
verbose="true"
|
||||
>
|
||||
</phpunit>
|
@ -1,177 +0,0 @@
|
||||
<?php
|
||||
|
||||
/** @changelog https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/Annotation/Route.php */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Symfony\Component\Routing\Annotation;
|
||||
|
||||
if (class_exists('Symfony\Component\Routing\Annotation\Route')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
class Route
|
||||
{
|
||||
private $path;
|
||||
private $localizedPaths = [];
|
||||
private $name;
|
||||
private $requirements = [];
|
||||
private $options = [];
|
||||
private $defaults = [];
|
||||
private $host;
|
||||
private $methods = [];
|
||||
private $schemes = [];
|
||||
private $condition;
|
||||
private $locale;
|
||||
private $format;
|
||||
private $utf8;
|
||||
|
||||
/**
|
||||
* @param array $data An array of key/value parameters
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (isset($data['localized_paths'])) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', \get_class($this)));
|
||||
}
|
||||
|
||||
if (isset($data['value'])) {
|
||||
$data[\is_array($data['value']) ? 'localized_paths' : 'path'] = $data['value'];
|
||||
unset($data['value']);
|
||||
}
|
||||
|
||||
if (isset($data['path']) && \is_array($data['path'])) {
|
||||
$data['localized_paths'] = $data['path'];
|
||||
unset($data['path']);
|
||||
}
|
||||
|
||||
if (isset($data['locale'])) {
|
||||
$data['defaults']['_locale'] = $data['locale'];
|
||||
unset($data['locale']);
|
||||
}
|
||||
|
||||
if (isset($data['format'])) {
|
||||
$data['defaults']['_format'] = $data['format'];
|
||||
unset($data['format']);
|
||||
}
|
||||
|
||||
if (isset($data['utf8'])) {
|
||||
$data['options']['utf8'] = filter_var($data['utf8'], FILTER_VALIDATE_BOOLEAN) ?: false;
|
||||
unset($data['utf8']);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$method = 'set'.str_replace('_', '', $key);
|
||||
if (!method_exists($this, $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, \get_class($this)));
|
||||
}
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function setLocalizedPaths(array $localizedPaths)
|
||||
{
|
||||
$this->localizedPaths = $localizedPaths;
|
||||
}
|
||||
|
||||
public function getLocalizedPaths(): array
|
||||
{
|
||||
return $this->localizedPaths;
|
||||
}
|
||||
|
||||
public function setHost($pattern)
|
||||
{
|
||||
$this->host = $pattern;
|
||||
}
|
||||
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setRequirements($requirements)
|
||||
{
|
||||
$this->requirements = $requirements;
|
||||
}
|
||||
|
||||
public function getRequirements()
|
||||
{
|
||||
return $this->requirements;
|
||||
}
|
||||
|
||||
public function setOptions($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function setDefaults($defaults)
|
||||
{
|
||||
$this->defaults = $defaults;
|
||||
}
|
||||
|
||||
public function getDefaults()
|
||||
{
|
||||
return $this->defaults;
|
||||
}
|
||||
|
||||
public function setSchemes($schemes)
|
||||
{
|
||||
$this->schemes = \is_array($schemes) ? $schemes : [$schemes];
|
||||
}
|
||||
|
||||
public function getSchemes()
|
||||
{
|
||||
return $this->schemes;
|
||||
}
|
||||
|
||||
public function setMethods($methods)
|
||||
{
|
||||
$this->methods = \is_array($methods) ? $methods : [$methods];
|
||||
}
|
||||
|
||||
public function getMethods()
|
||||
{
|
||||
return $this->methods;
|
||||
}
|
||||
|
||||
public function setCondition($condition)
|
||||
{
|
||||
$this->condition = $condition;
|
||||
}
|
||||
|
||||
public function getCondition()
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
$value = 1000;
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
$newValue = 1000;
|
||||
|
||||
?>
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
||||
/**
|
||||
* @see \RenameSimpleRectorTest
|
||||
*/
|
||||
final class RenameSimpleRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @return array<class-string<\PhpParser\Node>>
|
||||
*/
|
||||
public function getNodeTypes(): array
|
||||
{
|
||||
return [Variable::class];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Variable $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
$node->name = 'newValue';
|
||||
return $node;
|
||||
}
|
||||
|
||||
public function getRuleDefinition(): RuleDefinition
|
||||
{
|
||||
// ...
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class RenameSimpleRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(SmartFileInfo $fileInfo): void
|
||||
{
|
||||
$this->doTestFileInfo($fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Iterator<SmartFileInfo>
|
||||
*/
|
||||
public function provideData(): Iterator
|
||||
{
|
||||
return $this->yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
public function provideConfigFilePath(): string
|
||||
{
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(RenameSimpleRector::class);
|
||||
};
|
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/Rector/RenameSimpleRector.php';
|
||||
require_once __DIR__ . '/Rector/RenameSimpleRectorTest.php';
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\RectorPrefixed\Tests;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class SkipSomeEntity
|
||||
{
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\RectorPrefixed\Tests;
|
||||
|
||||
class SomeClassWithoutChildren
|
||||
{
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class SomeController
|
||||
{
|
||||
/**
|
||||
* @Route()
|
||||
*/
|
||||
public function someMethod()
|
||||
{
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
################################################
|
||||
## Docker image used for profiling Rector ##
|
||||
################################################
|
||||
|
||||
ARG PHP_VERSION=8.0
|
||||
|
||||
FROM rector/rector:php${PHP_VERSION}
|
||||
|
||||
# Install php extensions
|
||||
RUN apt-get update && apt-get install -y \
|
||||
wget \
|
||||
gnupg2
|
||||
|
||||
# Setup blackfire repo
|
||||
RUN wget -q -O - https://packages.blackfire.io/gpg.key | apt-key add -
|
||||
RUN echo "deb http://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list
|
||||
|
||||
# Install blackfire php extensions
|
||||
RUN apt-get update && apt-get install -y \
|
||||
blackfire-php
|
||||
|
||||
# Install blackfire cli tool
|
||||
RUN mkdir -p /tmp/blackfire \
|
||||
&& architecture=$(case $(uname -m) in i386 | i686 | x86) echo "i386" ;; x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
|
||||
&& curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux/$architecture | tar zxp -C /tmp/blackfire \
|
||||
&& mv /tmp/blackfire/blackfire /usr/bin/blackfire \
|
||||
&& rm -Rf /tmp/blackfire
|
@ -1,34 +0,0 @@
|
||||
## Docker image for Blackfire profiling
|
||||
|
||||
### Build
|
||||
|
||||
Builds image with `rector-blackfire` tag.
|
||||
|
||||
```
|
||||
docker build . --tag rector-blackfire --file .docker/php-blackfire/Dockerfile
|
||||
```
|
||||
|
||||
You can use `--build-arg PHP_VERSION=7.4` to build with specific PHP version. Supported versions are: 7.3, 7.4, 8.0
|
||||
|
||||
|
||||
### Prepare
|
||||
|
||||
These variables must be set on host to pass them into container (obtain values at [blackfire.io](https://blackfire.io)):
|
||||
```
|
||||
export BLACKFIRE_CLIENT_ID=""
|
||||
export BLACKFIRE_CLIENT_TOKEN=""
|
||||
```
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
Get into container:
|
||||
|
||||
```
|
||||
docker run --entrypoint="" -it --rm -e BLACKFIRE_CLIENT_ID -e BLACKFIRE_CLIENT_TOKEN -v $(pwd):/rector rector-blackfire bash
|
||||
```
|
||||
|
||||
Once in container, you can start profiling:
|
||||
```
|
||||
blackfire run php bin/rector <args..>
|
||||
```
|
@ -1,11 +0,0 @@
|
||||
################################################
|
||||
## Docker image used for debugging Rector ##
|
||||
################################################
|
||||
|
||||
ARG PHP_VERSION=8.0
|
||||
|
||||
FROM rector/rector:php${PHP_VERSION}
|
||||
|
||||
RUN pecl install xdebug
|
||||
|
||||
COPY .docker/php-xdebug/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
|
@ -1,26 +0,0 @@
|
||||
## Docker image for Xdebug debugging
|
||||
|
||||
### Build
|
||||
|
||||
Builds image with `rector-xdebug` tag.
|
||||
|
||||
```shell
|
||||
docker build . --tag rector-xdebug --file .docker/php-xdebug/Dockerfile
|
||||
```
|
||||
|
||||
You can use `--build-arg PHP_VERSION=7.4` to build with specific PHP version. Supported versions are: 7.3, 7.4, 8.0
|
||||
|
||||
### Usage
|
||||
|
||||
Get into container (change ip address):
|
||||
|
||||
```shell
|
||||
docker run -it --rm \
|
||||
--entrypoint="" \
|
||||
--volume $(pwd):/rector \
|
||||
--env XDEBUG_CONFIG="client_host=172.16.165.1" \
|
||||
--env PHP_IDE_CONFIG="serverName=rector" \
|
||||
rector-xdebug bash
|
||||
```
|
||||
|
||||
**Do not forget to run rector binary with `--xdebug` option.**
|
@ -1,5 +0,0 @@
|
||||
[xdebug]
|
||||
zend_extension = "/usr/local/lib/php/extensions/no-debug-non-zts-20200930/xdebug.so"
|
||||
xdebug.mode = debug
|
||||
xdebug.client_port = 9003
|
||||
xdebug.start_with_request = yes
|
@ -1,10 +0,0 @@
|
||||
[opcache]
|
||||
opcache.memory_consumption=128
|
||||
opcache.interned_strings_buffer=8
|
||||
opcache.max_accelerated_files=4000
|
||||
opcache.revalidate_freq=60
|
||||
opcache.fast_shutdown=1
|
||||
opcache.enable_cli=1
|
||||
opcache.enable=1
|
||||
opcache.file_cache='/tmp/opcache'
|
||||
opcache.file_update_protection=0
|
@ -1,28 +0,0 @@
|
||||
*~
|
||||
.DS_Store
|
||||
.idea/
|
||||
|
||||
.env
|
||||
.editorconfig
|
||||
.phpstorm.meta.php
|
||||
|
||||
phpstan.neon
|
||||
rector.php
|
||||
phpunit.xml
|
||||
ecs.php
|
||||
|
||||
LICENSE
|
||||
|
||||
.gitattributes
|
||||
.gitignore
|
||||
|
||||
*.md
|
||||
|
||||
.dockerignore
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
docker-compose.dist.yml
|
||||
|
||||
/docs
|
||||
|
||||
*.phar
|
@ -1,29 +0,0 @@
|
||||
name: Bare Run
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
bare_run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php_version }}
|
||||
coverage: none
|
||||
|
||||
- run: php bin/rector --version --ansi
|
||||
|
||||
- run: php bin/rector list --ansi
|
@ -1,21 +0,0 @@
|
||||
name: PHP 8 Attributes
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
php8_attributes:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
coverage: none
|
||||
|
||||
- run: bin/rector process tests/fixture-php8-attributes --config ci/rector-attributes.php --ansi
|
@ -1,25 +0,0 @@
|
||||
name: PHP Parser 3
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
php_parser_3:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
-
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 7.1
|
||||
coverage: none
|
||||
|
||||
# wait for deploy to packagist
|
||||
- run: sleep 70
|
||||
|
||||
- run: composer require nikic/php-parser:^3.1 --ansi
|
||||
- run: composer require rector/rector-prefixed:dev-main --dev --ansi
|
||||
- run: vendor/bin/rector list --ansi
|
@ -1,64 +0,0 @@
|
||||
name: Build docker images
|
||||
on:
|
||||
push:
|
||||
# Publish `main` as Docker `latest` image.
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Publish `v1.2.3` tags as releases.
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
||||
COMPOSER_ROOT_VERSION: "dev-main"
|
||||
|
||||
jobs:
|
||||
publish_images:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Build images
|
||||
run: |
|
||||
DOCKER_TAGS=""
|
||||
|
||||
# Pull tag and branch from github.ref, which is either refs/heads/... or refs/tags/...
|
||||
TAG=$(echo "${{ github.ref }}" | sed -e '/refs\/tags\//!d; s,refs/.*/v\?\(.*\),\1,')
|
||||
BRANCH=$(echo "${{ github.ref }}" | sed -e '/refs\/heads\//!d; s,refs/.*/\(.*\),\1,')
|
||||
|
||||
if [ "main" == "$BRANCH" ]; then
|
||||
DOCKER_TAGS="$DOCKER_TAGS latest"
|
||||
fi
|
||||
|
||||
if [ ! -z "$TAG" ]; then
|
||||
DOCKER_TAGS="$DOCKER_TAGS $TAG"
|
||||
fi
|
||||
|
||||
echo "Image will be tagged with: $DOCKER_TAGS"
|
||||
|
||||
DOCKER_TAG_ARG=""
|
||||
for ARG in $DOCKER_TAGS; do
|
||||
DOCKER_TAG_ARG="$DOCKER_TAG_ARG --tag rector/rector:$ARG"
|
||||
done
|
||||
|
||||
docker buildx create --name builder-php8 --use
|
||||
docker buildx build \
|
||||
--progress plain \
|
||||
--cache-from=rector/rector:build-cache-php8 \
|
||||
--cache-to=type=registry,ref=rector/rector:build-cache-php8,mode=max,push=true \
|
||||
--target rector \
|
||||
--push \
|
||||
$DOCKER_TAG_ARG \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--build-arg PHP_VERSION=8 .
|
@ -1,60 +0,0 @@
|
||||
name: Rector Run
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
rector_run:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php_version: ['7.1', '7.2', '7.3', '7.4', '8.0']
|
||||
commands:
|
||||
-
|
||||
name: 'Finalize Entity'
|
||||
install: composer require doctrine/orm
|
||||
run: vendor/bin/rector process ../tests/fixture-finalize --config ../ci/rector-finalize.php --ansi
|
||||
|
||||
-
|
||||
name: 'Composer Dependency'
|
||||
install: composer require symfony/console 2.8
|
||||
run: vendor/bin/rector list --debug --ansi
|
||||
|
||||
-
|
||||
name: 'Along PHPStan'
|
||||
install: composer require phpstan/phpstan:0.12.85 --dev --ansi
|
||||
run: |
|
||||
vendor/bin/rector list --ansi
|
||||
vendor/bin/phpstan -h --ansi
|
||||
|
||||
name: "PHP ${{ matrix.php_version }}"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php_version }}
|
||||
coverage: none
|
||||
|
||||
- run: |
|
||||
mkdir standalone
|
||||
cd standalone
|
||||
# wait for deploy to packagist
|
||||
sleep 70
|
||||
|
||||
- run: |
|
||||
cd standalone
|
||||
# run
|
||||
composer require rector/rector-prefixed:dev-main --dev --ansi
|
||||
${{ matrix.commands.install }}
|
||||
|
||||
-
|
||||
run: |
|
||||
cd standalone
|
||||
${{ matrix.commands.run }}
|
@ -1,37 +0,0 @@
|
||||
name: Standalone Rule Test
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
standalone_rule_test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
actions:
|
||||
-
|
||||
name: 'Rector Prefixed'
|
||||
run: composer require rector/rector-prefixed:dev-main --dev
|
||||
|
||||
steps:
|
||||
# see https://github.com/rectorphp/rector-prefixed-rule-test
|
||||
-
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: rectorphp/rector-prefixed-rule-test
|
||||
|
||||
- uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.3'
|
||||
coverage: none
|
||||
|
||||
- uses: "ramsey/composer-install@v1"
|
||||
|
||||
- run: ${{ matrix.actions.run }}
|
||||
|
||||
- run: vendor/bin/phpunit
|
@ -1,58 +0,0 @@
|
||||
ARG PHP_VERSION=8.0
|
||||
FROM php:${PHP_VERSION}-cli as base
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libzip4 \
|
||||
libicu63 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM base as build
|
||||
|
||||
WORKDIR /rector
|
||||
|
||||
# Install php extensions
|
||||
RUN apt-get update && apt-get install -y \
|
||||
g++ \
|
||||
git \
|
||||
libicu-dev \
|
||||
libzip-dev \
|
||||
unzip \
|
||||
wget \
|
||||
zip \
|
||||
&& pecl -q install \
|
||||
zip \
|
||||
&& docker-php-ext-configure intl \
|
||||
&& docker-php-ext-configure opcache --enable-opcache \
|
||||
&& docker-php-ext-install \
|
||||
intl \
|
||||
opcache \
|
||||
zip
|
||||
|
||||
# Add source
|
||||
COPY . .
|
||||
|
||||
# Build runtime image
|
||||
FROM base as rector
|
||||
|
||||
COPY --from=build /usr/local/lib/php /usr/local/lib/php
|
||||
COPY --from=build /usr/local/etc/php /usr/local/etc/php
|
||||
COPY .docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
|
||||
|
||||
ENV PATH /rector/bin:$PATH
|
||||
|
||||
# Add source
|
||||
COPY . /rector
|
||||
|
||||
ENTRYPOINT [ "rector" ]
|
||||
|
||||
VOLUME ["/project"]
|
||||
WORKDIR "/project"
|
||||
|
||||
RUN mkdir -p /tmp/opcache
|
||||
|
||||
RUN chmod +x /rector/bin/rector
|
||||
RUN /rector/bin/rector list
|
||||
|
||||
RUN mkdir -p /tmp/opcache \
|
||||
&& /rector/bin/rector list \
|
||||
&& chmod 777 -R /tmp
|
@ -1,25 +0,0 @@
|
||||
# Prefixed Rector
|
||||
|
||||
[![Build Status Github Actions](https://img.shields.io/github/workflow/status/rectorphp/rector-prefixed/Code_Checks?style=flat-square)](https://github.com/rectorphp/rector-prefixed/actions)
|
||||
[![Downloads](https://img.shields.io/packagist/dt/rector/rector-prefixed.svg?style=flat-square)](https://packagist.org/packages/rector/rector-prefixed)
|
||||
|
||||
Do you have conflicts on Rector install? You're in the right place. Prefixed Rector can [be installed even on very old Symfony](https://getrector.org/blog/2020/01/20/how-to-install-rector-despite-composer-conflicts).
|
||||
|
||||
Do you have older PHP? Rector prefixed goes down to PHP 7.1, so you can install it even on older projects.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
composer require rector/rector-prefixed --dev
|
||||
```
|
||||
|
||||
```bash
|
||||
# generate "rector.php" config
|
||||
vendor/bin/rector init
|
||||
|
||||
# dry run
|
||||
vendor/bin/rector process src --dry-run
|
||||
|
||||
# changing run
|
||||
vendor/bin/rector process src
|
||||
```
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
// inspired by https://github.com/phpstan/phpstan/blob/master/bootstrap.php
|
||||
|
||||
spl_autoload_register(function (string $class): void {
|
||||
static $composerAutoloader;
|
||||
|
||||
// already loaded in bin/rector.php
|
||||
if (defined('__RECTOR_RUNNING__')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// load prefixed or native class, e.g. for running tests
|
||||
if (strpos($class, 'RectorPrefix') === 0 || strpos($class, 'Rector\\') === 0) {
|
||||
if ($composerAutoloader === null) {
|
||||
// prefixed version autoload
|
||||
$composerAutoloader = require __DIR__ . '/vendor/autoload.php';
|
||||
}
|
||||
$composerAutoloader->loadClass($class);
|
||||
}
|
||||
|
||||
// aliased by php-scoper, that's why its missing
|
||||
if ($class === 'Symplify\SmartFileSystem\SmartFileInfo') {
|
||||
$filePath = __DIR__ . '/vendor/symplify/smart-file-system/src/SmartFileInfo.php';
|
||||
if (file_exists($filePath)) {
|
||||
require $filePath;
|
||||
}
|
||||
}
|
||||
});
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\Symfony\Set\SymfonySetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
// route class must exist and be loaded, as annotation parser uses dynamic reflection
|
||||
require_once __DIR__ . '/../stubs/Symfony/Component/Routing/Annotation/Route.php';
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$containerConfigurator->import(SymfonySetList::SYMFONY_52);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
|
||||
};
|
@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(FinalizeClassesWithoutChildrenRector::class);
|
||||
};
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"name": "rector/rector-prefixed",
|
||||
"description": "Prefixed and PHP 7.1 downgraded version of rector/rector",
|
||||
"license": "MIT",
|
||||
"bin": [
|
||||
"bin/rector"
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1|^8.0",
|
||||
"phpstan/phpstan": "0.12.85"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.10-dev"
|
||||
}
|
||||
},
|
||||
"conflict": {
|
||||
"phpstan/phpdoc-parser": "<=0.5.3",
|
||||
"phpstan/phpstan": "<=0.12.82"
|
||||
}
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
<?php
|
||||
|
||||
/** @changelog https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/Annotation/Route.php */
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Symfony\Component\Routing\Annotation;
|
||||
|
||||
if (class_exists('Symfony\Component\Routing\Annotation\Route')) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "METHOD"})
|
||||
*/
|
||||
class Route
|
||||
{
|
||||
private $path;
|
||||
private $localizedPaths = [];
|
||||
private $name;
|
||||
private $requirements = [];
|
||||
private $options = [];
|
||||
private $defaults = [];
|
||||
private $host;
|
||||
private $methods = [];
|
||||
private $schemes = [];
|
||||
private $condition;
|
||||
private $locale;
|
||||
private $format;
|
||||
private $utf8;
|
||||
|
||||
/**
|
||||
* @param array $data An array of key/value parameters
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (isset($data['localized_paths'])) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "localized_paths" on annotation "%s".', \get_class($this)));
|
||||
}
|
||||
|
||||
if (isset($data['value'])) {
|
||||
$data[\is_array($data['value']) ? 'localized_paths' : 'path'] = $data['value'];
|
||||
unset($data['value']);
|
||||
}
|
||||
|
||||
if (isset($data['path']) && \is_array($data['path'])) {
|
||||
$data['localized_paths'] = $data['path'];
|
||||
unset($data['path']);
|
||||
}
|
||||
|
||||
if (isset($data['locale'])) {
|
||||
$data['defaults']['_locale'] = $data['locale'];
|
||||
unset($data['locale']);
|
||||
}
|
||||
|
||||
if (isset($data['format'])) {
|
||||
$data['defaults']['_format'] = $data['format'];
|
||||
unset($data['format']);
|
||||
}
|
||||
|
||||
if (isset($data['utf8'])) {
|
||||
$data['options']['utf8'] = filter_var($data['utf8'], FILTER_VALIDATE_BOOLEAN) ?: false;
|
||||
unset($data['utf8']);
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$method = 'set'.str_replace('_', '', $key);
|
||||
if (!method_exists($this, $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, \get_class($this)));
|
||||
}
|
||||
$this->$method($value);
|
||||
}
|
||||
}
|
||||
|
||||
public function setPath($path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function setLocalizedPaths(array $localizedPaths)
|
||||
{
|
||||
$this->localizedPaths = $localizedPaths;
|
||||
}
|
||||
|
||||
public function getLocalizedPaths(): array
|
||||
{
|
||||
return $this->localizedPaths;
|
||||
}
|
||||
|
||||
public function setHost($pattern)
|
||||
{
|
||||
$this->host = $pattern;
|
||||
}
|
||||
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setRequirements($requirements)
|
||||
{
|
||||
$this->requirements = $requirements;
|
||||
}
|
||||
|
||||
public function getRequirements()
|
||||
{
|
||||
return $this->requirements;
|
||||
}
|
||||
|
||||
public function setOptions($options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function setDefaults($defaults)
|
||||
{
|
||||
$this->defaults = $defaults;
|
||||
}
|
||||
|
||||
public function getDefaults()
|
||||
{
|
||||
return $this->defaults;
|
||||
}
|
||||
|
||||
public function setSchemes($schemes)
|
||||
{
|
||||
$this->schemes = \is_array($schemes) ? $schemes : [$schemes];
|
||||
}
|
||||
|
||||
public function getSchemes()
|
||||
{
|
||||
return $this->schemes;
|
||||
}
|
||||
|
||||
public function setMethods($methods)
|
||||
{
|
||||
$this->methods = \is_array($methods) ? $methods : [$methods];
|
||||
}
|
||||
|
||||
public function getMethods()
|
||||
{
|
||||
return $this->methods;
|
||||
}
|
||||
|
||||
public function setCondition($condition)
|
||||
{
|
||||
$this->condition = $condition;
|
||||
}
|
||||
|
||||
public function getCondition()
|
||||
{
|
||||
return $this->condition;
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\RectorPrefixed\Tests;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
*/
|
||||
class SkipSomeEntity
|
||||
{
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\RectorPrefixed\Tests;
|
||||
|
||||
class SomeClassWithoutChildren
|
||||
{
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class SomeController
|
||||
{
|
||||
/**
|
||||
* @Route()
|
||||
*/
|
||||
public function someMethod()
|
||||
{
|
||||
}
|
||||
}
|
101
ecs.php
101
ecs.php
@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer;
|
||||
use PhpCsFixer\Fixer\ReturnNotation\ReturnAssignmentFixer;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\CodingStandard\Fixer\Commenting\ParamReturnAndVarTagMalformsFixer;
|
||||
use Symplify\CodingStandard\Fixer\Commenting\RemoveCommentedCodeFixer;
|
||||
use Symplify\CodingStandard\Fixer\LineLength\DocBlockLineLengthFixer;
|
||||
use Symplify\EasyCodingStandard\ValueObject\Option;
|
||||
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(GeneralPhpdocAnnotationRemoveFixer::class)
|
||||
->call('configure', [[
|
||||
'annotations' => [
|
||||
'throws',
|
||||
'author',
|
||||
'package',
|
||||
'group',
|
||||
'required',
|
||||
'phpstan-ignore-line',
|
||||
'phpstan-ignore-next-line',
|
||||
],
|
||||
]]);
|
||||
|
||||
$services->set(NoSuperfluousPhpdocTagsFixer::class)
|
||||
->call('configure', [[
|
||||
'allow_mixed' => true,
|
||||
]]);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$parameters->set(Option::PATHS, [
|
||||
__DIR__ . '/bin',
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/packages',
|
||||
__DIR__ . '/packages-tests',
|
||||
__DIR__ . '/rules',
|
||||
__DIR__ . '/rules-tests',
|
||||
__DIR__ . '/tests',
|
||||
__DIR__ . '/utils',
|
||||
__DIR__ . '/config',
|
||||
__DIR__ . '/ecs.php',
|
||||
__DIR__ . '/rector.php',
|
||||
__DIR__ . '/config/set',
|
||||
]);
|
||||
|
||||
$containerConfigurator->import(SetList::PSR_12);
|
||||
$containerConfigurator->import(SetList::SYMPLIFY);
|
||||
$containerConfigurator->import(SetList::COMMON);
|
||||
$containerConfigurator->import(SetList::CLEAN_CODE);
|
||||
|
||||
$parameters->set(Option::SKIP, [
|
||||
'*/Source/*',
|
||||
'*/Fixture/*',
|
||||
'*/Expected/*',
|
||||
|
||||
// fixed in master
|
||||
ParamReturnAndVarTagMalformsFixer::class,
|
||||
|
||||
GeneralPhpdocAnnotationRemoveFixer::class => [
|
||||
__DIR__ . '/src/Rector/AbstractRector.php',
|
||||
'*TypeInferer*',
|
||||
'*TypeResolver*',
|
||||
'*NameResolver*',
|
||||
'*Mapper*',
|
||||
// allowed @required
|
||||
__DIR__ . '/packages/StaticTypeMapper/Naming/NameScopeFactory.php',
|
||||
__DIR__ . '/packages/NodeTypeResolver/NodeTypeResolver.php',
|
||||
__DIR__ . '/packages/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/PlainValueParser.php',
|
||||
],
|
||||
|
||||
UnaryOperatorSpacesFixer::class,
|
||||
|
||||
// buggy - @todo fix on Symplify master
|
||||
RemoveCommentedCodeFixer::class,
|
||||
DocBlockLineLengthFixer::class,
|
||||
|
||||
// breaks on-purpose annotated variables
|
||||
ReturnAssignmentFixer::class,
|
||||
|
||||
PhpdocTypesFixer::class => [__DIR__ . '/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php'],
|
||||
|
||||
// buggy on "Float" class
|
||||
PhpUnitStrictFixer::class => [
|
||||
__DIR__ . '/packages-tests/BetterPhpDocParser/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php',
|
||||
__DIR__ . '/tests/PhpParser/Node/NodeFactoryTest.php',
|
||||
__DIR__ . '/packages-tests/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser/StaticDoctrineAnnotationParserTest.php',
|
||||
'*TypeResolverTest.php',
|
||||
],
|
||||
]);
|
||||
|
||||
$parameters->set(Option::LINE_ENDING, "\n");
|
||||
};
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# see https://stackoverflow.com/questions/66644233/how-to-propagate-colors-from-bash-script-to-github-action?noredirect=1#comment117811853_66644233
|
||||
export TERM=xterm-color
|
||||
|
||||
# show errors
|
||||
set -e
|
||||
|
||||
# script fails if trying to access to an undefined variable
|
||||
set -u
|
||||
|
||||
|
||||
|
||||
|
||||
composer install --no-dev --ansi
|
||||
|
||||
rsync --exclude rector-build -av * rector-build --quiet
|
||||
rm -rf rector-build/packages-tests rector-build/rules-tests rector-build/tests
|
||||
|
||||
sh build/downgrade-rector.sh rector-build
|
||||
sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node\Stmt\Nop;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter;
|
||||
use Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer\DocBlockTagReplacer;
|
||||
use Rector\Testing\PHPUnit\AbstractTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileSystem;
|
||||
|
||||
final class PhpDocInfoTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* @var PhpDocInfo
|
||||
*/
|
||||
private $phpDocInfo;
|
||||
|
||||
/**
|
||||
* @var PhpDocInfoPrinter
|
||||
*/
|
||||
private $phpDocInfoPrinter;
|
||||
|
||||
/**
|
||||
* @var SmartFileSystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
|
||||
/**
|
||||
* @var DocBlockTagReplacer
|
||||
*/
|
||||
private $docBlockTagReplacer;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->boot();
|
||||
|
||||
$this->phpDocInfoPrinter = $this->getService(PhpDocInfoPrinter::class);
|
||||
$this->smartFileSystem = $this->getService(SmartFileSystem::class);
|
||||
$this->docBlockTagReplacer = $this->getService(DocBlockTagReplacer::class);
|
||||
|
||||
$this->phpDocInfo = $this->createPhpDocInfoFromFile(__DIR__ . '/Source/doc.txt');
|
||||
}
|
||||
|
||||
public function testGetTagsByName(): void
|
||||
{
|
||||
$paramTags = $this->phpDocInfo->getTagsByName('param');
|
||||
$this->assertCount(2, $paramTags);
|
||||
}
|
||||
|
||||
public function testGetVarType(): void
|
||||
{
|
||||
$expectedObjectType = new ObjectType('SomeType');
|
||||
$this->assertEquals($expectedObjectType, $this->phpDocInfo->getVarType());
|
||||
}
|
||||
|
||||
public function testGetReturnType(): void
|
||||
{
|
||||
$expectedObjectType = new ObjectType('SomeType');
|
||||
$this->assertEquals($expectedObjectType, $this->phpDocInfo->getReturnType());
|
||||
}
|
||||
|
||||
public function testReplaceTagByAnother(): void
|
||||
{
|
||||
$phpDocInfo = $this->createPhpDocInfoFromFile(__DIR__ . '/Source/test-tag.txt');
|
||||
$this->docBlockTagReplacer->replaceTagByAnother($phpDocInfo, 'test', 'flow');
|
||||
|
||||
$printedPhpDocInfo = $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo);
|
||||
$this->assertStringEqualsFile(__DIR__ . '/Source/expected-replaced-tag.txt', $printedPhpDocInfo);
|
||||
}
|
||||
|
||||
private function createPhpDocInfoFromFile(string $path): PhpDocInfo
|
||||
{
|
||||
$phpDocInfoFactory = $this->getService(PhpDocInfoFactory::class);
|
||||
$phpDocContent = $this->smartFileSystem->readFile($path);
|
||||
|
||||
$nop = new Nop();
|
||||
$nop->setDocComment(new Doc($phpDocContent));
|
||||
|
||||
return $phpDocInfoFactory->createFromNode($nop);
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/**
|
||||
* @var SomeType
|
||||
* @return SomeType
|
||||
* @param SomeType|NoSlash|\Preslashed|null|\string $value
|
||||
* @param \DOMElement $node Element to parse that represents a Route
|
||||
*
|
||||
* @throw \Type
|
||||
* @return HelperInterface[] An array of helper instances
|
||||
*/
|
@ -1,5 +0,0 @@
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @flow
|
||||
*/
|
@ -1,9 +0,0 @@
|
||||
/**
|
||||
* @var AnotherType
|
||||
* @return AnotherType
|
||||
* @param AnotherType|NoSlash|\Preslashed|null|\string $value
|
||||
* @param \DOMElement $node Element to parse that represents a Route
|
||||
*
|
||||
* @throw \Type
|
||||
* @return HelperInterface[] An array of helper instances
|
||||
*/
|
@ -1,5 +0,0 @@
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @test
|
||||
*/
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfoPrinter;
|
||||
|
||||
use Iterator;
|
||||
use PhpParser\Comment\Doc;
|
||||
use PhpParser\Node;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter;
|
||||
use Rector\Testing\PHPUnit\AbstractTestCase;
|
||||
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
|
||||
use Symplify\SmartFileSystem\SmartFileSystem;
|
||||
|
||||
abstract class AbstractPhpDocInfoPrinterTest extends AbstractTestCase
|
||||
{
|
||||
/**
|
||||
* @var PhpDocInfoPrinter
|
||||
*/
|
||||
protected $phpDocInfoPrinter;
|
||||
|
||||
/**
|
||||
* @var SmartFileSystem
|
||||
*/
|
||||
protected $smartFileSystem;
|
||||
|
||||
/**
|
||||
* @var PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->boot();
|
||||
|
||||
$this->phpDocInfoFactory = $this->getService(PhpDocInfoFactory::class);
|
||||
$this->phpDocInfoPrinter = $this->getService(PhpDocInfoPrinter::class);
|
||||
$this->smartFileSystem = $this->getService(SmartFileSystem::class);
|
||||
}
|
||||
|
||||
protected function createPhpDocInfoFromDocCommentAndNode(string $docComment, Node $node): PhpDocInfo
|
||||
{
|
||||
$node->setDocComment(new Doc($docComment));
|
||||
return $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
}
|
||||
|
||||
protected function yieldFilesFromDirectory(string $directory, string $suffix = '*.php'): Iterator
|
||||
{
|
||||
return StaticFixtureFinder::yieldDirectory($directory, $suffix);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfoPrinter;
|
||||
|
||||
use Iterator;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfoPrinter\Source\Doctrine\CaseSensitive;
|
||||
use Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfoPrinter\Source\Doctrine\IndexInTable;
|
||||
use Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfoPrinter\Source\Doctrine\Short;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class DoctrineTest extends AbstractPhpDocInfoPrinterTest
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideDataClass()
|
||||
*/
|
||||
public function testClass(string $docFilePath, Node $node): void
|
||||
{
|
||||
$docComment = $this->smartFileSystem->readFile($docFilePath);
|
||||
$phpDocInfo = $this->createPhpDocInfoFromDocCommentAndNode($docComment, $node);
|
||||
|
||||
$fileInfo = new SmartFileInfo($docFilePath);
|
||||
$relativeFilePathFromCwd = $fileInfo->getRelativeFilePathFromCwd();
|
||||
|
||||
$printedPhpDocInfo = $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo);
|
||||
$this->assertSame($docComment, $printedPhpDocInfo, $relativeFilePathFromCwd);
|
||||
}
|
||||
|
||||
public function provideDataClass(): Iterator
|
||||
{
|
||||
yield [__DIR__ . '/Source/Doctrine/index_in_table.txt', new Class_(IndexInTable::class)];
|
||||
yield [__DIR__ . '/Source/Doctrine/case_sensitive.txt', new Class_(CaseSensitive::class)];
|
||||
yield [__DIR__ . '/Source/Doctrine/short.txt', new Class_(Short::class)];
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @param callable $loader A callback function or callable class responsible for
|
||||
* constructing a translations package instance.
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @dataProvider someMethod()
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @var Type
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @customAnnotation(arg)
|
||||
*/
|
@ -1 +0,0 @@
|
||||
/** @var Type */
|
@ -1 +0,0 @@
|
||||
/** @var Type */
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @param bool $setTicketAuthor @see self::create()
|
||||
*/
|
@ -1,6 +0,0 @@
|
||||
/**
|
||||
* Stage constructor.
|
||||
*
|
||||
* @param string $stage
|
||||
* @param boolean $undefined Should the object be undefined?
|
||||
*/
|
@ -1,6 +0,0 @@
|
||||
/**
|
||||
* @param SomeType
|
||||
*
|
||||
*
|
||||
* @return SomeType
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @param object $subject
|
||||
*/
|
@ -1,10 +0,0 @@
|
||||
/**
|
||||
* @param something $value
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throw that
|
||||
* @throw this too
|
||||
*
|
||||
* @drop this
|
||||
*/
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @property int $defaultMaturity
|
||||
* @property string $pdfDirectory
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @Assert\Type("DateTime")
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @Route("/", name="homepage")
|
||||
*/
|
@ -1,7 +0,0 @@
|
||||
/**
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*
|
||||
* @copyright Copyright (c) 2015-2016 Zend Technologies USA Inc. (https://www.zend.com/)
|
||||
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
|
||||
*/
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @Route("/", name="homepage")
|
||||
* @Route("/another-path", name="another-path")
|
||||
*/
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* ```
|
||||
* SomeClass::someMethod('default'
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```
|
||||
* SomeClass::someMethod(
|
||||
* );
|
||||
* ```
|
||||
*/
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @method int|bool|null|void main(...$args)
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @method \Cake\Collection\CollectionInterface groupBy(string|callable $field) In-memory group all results by the value of a column.
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @foor a,
|
||||
*/
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @param string $key
|
||||
* @param int $selected
|
||||
*/
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @param int $key
|
||||
* @param int $selected
|
||||
*/
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @param AttributeAwareIdentifierTypeNode&IdentifierTypeNode $typeNode
|
||||
* @param string[] ...$types
|
||||
*/
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @link https://book.cakephp.org/4/en/core-libraries/global-constants-and-functions.html#pluginSplit
|
||||
* @psalm-return array{string|null, string}
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @psalm-param array{cache:string, callbacks?: mixed, plugin?:mixed} $options
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @return (string|bool)[]
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @return array<string|bool>
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @return string Set of slashes ("\\" or "/")
|
||||
*/
|
@ -1,5 +0,0 @@
|
||||
/**
|
||||
* @see https://book.cakephp.org/2/en/models/associations-linking-models-together.html#relationship-types
|
||||
* hasOne => one to one
|
||||
* hasMany => one to many
|
||||
*/
|
@ -1,6 +0,0 @@
|
||||
/**
|
||||
* Inspiration @see https://github.com/rectorphp/rector/pull/1865/files#diff-0d18e660cdb626958662641b491623f8
|
||||
* @wip
|
||||
*
|
||||
* @see \Rector\Tests\Autodiscovery\Rector\Class_\MoveValueObjectsToValueObjectDirectoryRector\MoveValueObjectsToValueObjectDirectoryRectorTest
|
||||
*/
|
@ -1,8 +0,0 @@
|
||||
/**
|
||||
* @return SomeType
|
||||
* @param SomeType|NoSlash|\Preslashed|null|\string $value
|
||||
* @param \DOMElement $node Element to parse that represents a Route
|
||||
*
|
||||
* @throw \Type
|
||||
* @return HelperInterface[] An array of helper instances
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/
|
||||
*/
|
@ -1 +0,0 @@
|
||||
/** @template T as int */
|
@ -1 +0,0 @@
|
||||
/** @template T of int */
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* @todo decouple to NodeAnalyzer
|
||||
* Matches array like...
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @param (string|int) $cookies
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @param (string|\SomeClass)[] $cookies
|
||||
*/
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @param array<string|\SomeClass> $cookies
|
||||
*/
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user