Commit 587f56f8 authored by Simon Gilli's avatar Simon Gilli
Browse files

Merge branch 'task/add-rector' into 'develop'

[TASK] Add rector configuration and CI job for upcoming code refactoring

See merge request !693
parents 6cd31a00 b66305ad
Pipeline #20767 passed with stages
in 6 minutes and 27 seconds
......@@ -75,6 +75,17 @@ test:mutation:
- build/infection-log.json
expire_in: 30 min
test:rector:
stage: test
image: composer:2
variables:
GIT_STRATEGY: "clone"
allow_failure: true
before_script:
- composer install --ignore-platform-reqs
script:
- vendor/bin/rector process -n
mutation:badge:
stage: badges
image: python:3.9
......
{
"name": "t3o/ter",
"description": "Website for TYPO3 Extension Repository",
"authors": [
{
"name": "t3o team",
"email": "maintenance@typo3.org"
}
],
"support": {
"email": "maintenance@typo3.org",
"issues": "https://git-t3o.typo3.org/t3o/ter/issues"
},
"repositories": [
{
"type": "path",
"url": "extensions/*"
},
{
"type": "composer",
"url": "https://gitlab.typo3.org/api/v4/group/560/-/packages/composer/"
}
],
"require": {
"php": "^7.4",
"ext-curl": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-pdo": "*",
"ext-zip": "*",
"ext-zlib": "*",
"apache-solr-for-typo3/solr": "^11.0",
"b13/typo3-composerize": "dev-main",
"cweagans/composer-patches": "^1.7",
"gordalina/cachetool": "^4.0",
"lcobucci/jwt": "^3.3",
"nimut/testing-framework": "^5.0",
"t3o/t3olayout": "^5.0",
"t3o/ter-frontend": "@dev",
"t3o/ter-layout": "@dev",
"t3o/ter-rest": "@dev",
"t3o/ter-soap": "@dev",
"typo3/cms-adminpanel": "^10.4",
"typo3/cms-seo": "^10.4"
},
"require-dev": {
"codeception/codeception": "^4.1",
"codeception/module-asserts": "^1.2",
"codeception/module-phpbrowser": "^1.0",
"friendsofphp/php-cs-fixer": "^2.16",
"infection/infection": "^0.20.0",
"neos/utility-arrays": "^6.0",
"neos/utility-files": "^6.0",
"punktde/codeception-cli": "^2.0",
"punktde/codeception-database": "^2.0",
"punktde/codeception-filesystem": "^2.0",
"punktde/codeception-webdriver": "^2.2",
"t3o/test-helpers": "dev-main"
"name": "t3o/ter",
"description": "Website for TYPO3 Extension Repository",
"authors": [
{
"name": "t3o team",
"email": "maintenance@typo3.org"
}
],
"support": {
"email": "maintenance@typo3.org",
"issues": "https://git-t3o.typo3.org/t3o/ter/issues"
},
"repositories": [
{
"type": "path",
"url": "extensions/*"
},
"config": {
"store-auths": false,
"platform": {
"php": "7.4.8"
},
"sort-packages": true
{
"type": "composer",
"url": "https://gitlab.typo3.org/api/v4/group/560/-/packages/composer/"
}
],
"require": {
"php": "^7.4",
"ext-curl": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-pdo": "*",
"ext-zip": "*",
"ext-zlib": "*",
"apache-solr-for-typo3/solr": "^11.0",
"b13/typo3-composerize": "dev-main",
"cweagans/composer-patches": "^1.7",
"gordalina/cachetool": "^4.0",
"lcobucci/jwt": "^3.3",
"nimut/testing-framework": "^5.0",
"t3o/t3olayout": "^5.0",
"t3o/ter-frontend": "@dev",
"t3o/ter-layout": "@dev",
"t3o/ter-rest": "@dev",
"t3o/ter-soap": "@dev",
"typo3/cms-adminpanel": "^10.4",
"typo3/cms-seo": "^10.4"
},
"require-dev": {
"codeception/codeception": "^4.1",
"codeception/module-asserts": "^1.2",
"codeception/module-phpbrowser": "^1.0",
"friendsofphp/php-cs-fixer": "^2.16",
"infection/infection": "^0.20.0",
"neos/utility-arrays": "^6.0",
"neos/utility-files": "^6.0",
"punktde/codeception-cli": "^2.0",
"punktde/codeception-database": "^2.0",
"punktde/codeception-filesystem": "^2.0",
"punktde/codeception-webdriver": "^2.2",
"rector/rector": "^0.12.5",
"t3o/test-helpers": "dev-main"
},
"config": {
"store-auths": false,
"platform": {
"php": "7.4.26"
},
"extra": {
"typo3/cms": {
"web-dir": "public",
"root-dir": "private"
},
"patches-file": "composer.patches.json"
"sort-packages": true
},
"extra": {
"typo3/cms": {
"web-dir": "public",
"root-dir": "private"
},
"scripts": {
"test:unit": [
"XDEBUG_MODE='coverage' ./vendor/bin/phpunit -c .gitlab-ci/Tests/phpunit.xml --log-junit build/junit-report.xml --coverage-text --colors=never"
],
"test:mutation": [
"XDEBUG_MODE='coverage' ./vendor/bin/infection"
],
"test:api": [
"./vendor/bin/codecept run api --steps"
],
"test:php": [
"./vendor/bin/php-cs-fixer fix --dry-run --diff-format=udiff --path-mode=intersection --config=.gitlab-ci/build/.php_cs --diff extensions"
]
}
"patches-file": "composer.patches.json"
},
"scripts": {
"test:unit": [
"XDEBUG_MODE='coverage' ./vendor/bin/phpunit -c .gitlab-ci/Tests/phpunit.xml --log-junit build/junit-report.xml --coverage-text --colors=never"
],
"test:mutation": [
"XDEBUG_MODE='coverage' ./vendor/bin/infection"
],
"test:api": [
"./vendor/bin/codecept run api --steps"
],
"test:php": [
"./vendor/bin/php-cs-fixer fix --dry-run --diff-format=udiff --path-mode=intersection --config=.gitlab-ci/build/.php_cs --diff extensions"
],
"test:rector": [
"rector process -n"
],
"run:rector": [
"rector process"
]
}
}
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "87a5d46b6382e68dc14192a11245fb9c",
"content-hash": "e3ded8a72fa9ae7377e155a43b6053f4",
"packages": [
{
"name": "adoy/fastcgi-client",
......@@ -8476,7 +8476,7 @@
},
{
"name": "t3o/ter-frontend",
"version": "dev-develop",
"version": "dev-master",
"dist": {
"type": "path",
"url": "extensions/ter_fe2",
......@@ -8524,7 +8524,7 @@
},
{
"name": "t3o/ter-layout",
"version": "dev-develop",
"version": "dev-master",
"dist": {
"type": "path",
"url": "extensions/ter_layout",
......@@ -8564,7 +8564,7 @@
},
{
"name": "t3o/ter-rest",
"version": "dev-develop",
"version": "dev-master",
"dist": {
"type": "path",
"url": "extensions/ter_rest",
......@@ -8610,7 +8610,7 @@
},
{
"name": "t3o/ter-soap",
"version": "dev-develop",
"version": "dev-master",
"dist": {
"type": "path",
"url": "extensions/ter",
......@@ -12397,6 +12397,70 @@
},
"time": "2020-10-06T19:10:04+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "cbe085f9fdead5b6d62e4c022ca52dc9427a10ee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/cbe085f9fdead5b6d62e4c022ca52dc9427a10ee",
"reference": "cbe085f9fdead5b6d62e4c022ca52dc9427a10ee",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
}
},
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/1.2.0"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://www.patreon.com/phpstan",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"time": "2021-11-18T14:09:01+00:00"
},
{
"name": "punktde/codeception-cli",
"version": "2.0.0",
......@@ -12539,6 +12603,66 @@
},
"time": "2020-04-14T07:03:22+00:00"
},
{
"name": "rector/rector",
"version": "0.12.5",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "e50e40e0fe73b88a46f27e086441e1998ceeca3c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/e50e40e0fe73b88a46f27e086441e1998ceeca3c",
"reference": "e50e40e0fe73b88a46f27e086441e1998ceeca3c",
"shasum": ""
},
"require": {
"php": "^7.1|^8.0",
"phpstan/phpstan": "^1.1.1"
},
"conflict": {
"phpstan/phpdoc-parser": "<1.2",
"rector/rector-cakephp": "*",
"rector/rector-doctrine": "*",
"rector/rector-laravel": "*",
"rector/rector-nette": "*",
"rector/rector-phpoffice": "*",
"rector/rector-phpunit": "*",
"rector/rector-prefixed": "*",
"rector/rector-symfony": "*"
},
"bin": [
"bin/rector"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "0.12-dev"
}
},
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Prefixed and PHP 7.1 downgraded version of rector/rector",
"support": {
"issues": "https://github.com/rectorphp/rector/issues",
"source": "https://github.com/rectorphp/rector/tree/0.12.5"
},
"funding": [
{
"url": "https://github.com/tomasvotruba",
"type": "github"
}
],
"time": "2021-11-23T17:38:29+00:00"
},
{
"name": "sanmai/pipeline",
"version": "v5.1.0",
......
<?php
declare(strict_types = 1);
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Ssch\TYPO3Rector\Configuration\Typo3Option;
use Ssch\TYPO3Rector\FileProcessor\Composer\Rector\ExtensionComposerRector;
use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\ExtbasePersistenceTypoScriptRector;
use Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\FileIncludeToImportStatementTypoScriptRector;
use Ssch\TYPO3Rector\Rector\General\ConvertImplicitVariablesToExplicitGlobalsRector;
use Ssch\TYPO3Rector\Rector\General\ExtEmConfRector;
use Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector;
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$containerConfigurator->import(Typo3LevelSetList::UP_TO_TYPO3_11);
// In order to have a better analysis from phpstan we teach it here some more things
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, Typo3Option::PHPSTAN_FOR_RECTOR_PATH);
// FQN classes are not imported by default. If you don't do it manually after every Rector run, enable it by:
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
// this will not import root namespace classes, like \DateTime or \Exception
$parameters->set(Option::IMPORT_SHORT_CLASSES, false);
// this will not import classes used in PHP DocBlocks, like in /** @var \Some\Class */
$parameters->set(Option::IMPORT_DOC_BLOCKS, false);
// Define your target version which you want to support
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_72);
// If you have an editorconfig and changed files should keep their format enable it here
// $parameters->set(Option::ENABLE_EDITORCONFIG, true);
// If you only want to process one/some TYPO3 extension(s), you can specify its path(s) here.
// If you use the option --config change __DIR__ to getcwd()
$parameters->set(Option::PATHS, [
__DIR__ . '/extensions/',
]);
// If you use the option --config change __DIR__ to getcwd()
$parameters->set(Option::SKIP, [
// @see https://github.com/sabbelasichon/typo3-rector/issues/2536
__DIR__ . '/**/Configuration/ExtensionBuilder/*',
// We skip those directories on purpose as there might be node_modules or similar
// that include typescript which would result in false positive processing
__DIR__ . '/**/Resources/**/node_modules/*',
__DIR__ . '/**/Resources/**/NodeModules/*',
__DIR__ . '/**/Resources/**/BowerComponents/*',
__DIR__ . '/**/Resources/**/bower_components/*',
__DIR__ . '/**/Resources/**/build/*',
]);
// This is used by the class \Ssch\TYPO3Rector\Rector\PostRector\FullQualifiedNamePostRector to force FQN in this paths and files
$parameters->set(Typo3Option::PATHS_FULL_QUALIFIED_NAMESPACES, [
// If you are targeting TYPO3 Version 11 use can now use Short namespace
// @see namespace https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ConfigurationFiles/Index.html
'ext_localconf.php',
'ext_tables.php',
'ClassAliasMap.php',
__DIR__ . '/**/Configuration/*.php',
__DIR__ . '/**/Configuration/**/*.php',
]);
// If you have trouble that rector cannot run because some TYPO3 constants are not defined add an additional constants file
// @see https://github.com/sabbelasichon/typo3-rector/blob/master/typo3.constants.php
// @see https://github.com/rectorphp/rector/blob/main/docs/static_reflection_and_autoload.md#include-files
// $parameters->set(Option::BOOTSTRAP_FILES, [
// __DIR__ . '/typo3.constants.php'
// ]);
// get services (needed for register a single rule)
$services = $containerConfigurator->services();
// register a single rule
// $services->set(InjectAnnotationRector::class);
/**
* Useful rule from RectorPHP itself to transform i.e. GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')
* to GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class) calls.
* But be warned, sometimes it produces false positives (edge cases), so watch out
*/
// $services->set(StringClassNameToClassConstantRector::class);
// Optional non-php file functionalities:
// @see https://github.com/sabbelasichon/typo3-rector/blob/main/docs/beyond_php_file_processors.md
// Adapt your composer.json dependencies to the latest available version for the defined SetList
// $containerConfigurator->import(Typo3SetList::COMPOSER_PACKAGES_104_CORE);
// $containerConfigurator->import(Typo3SetList::COMPOSER_PACKAGES_104_EXTENSIONS);
// Rewrite your extbase persistence class mapping from typoscript into php according to official docs.
// This processor will create a summarized file with all of the typoscript rewrites combined into a single file.
// The filename can be passed as argument, "Configuration_Extbase_Persistence_Classes.php" is default.
// $services->set(ExtbasePersistenceTypoScriptRector::class);
// Add some general TYPO3 rules
$services->set(ConvertImplicitVariablesToExplicitGlobalsRector::class);
$services->set(ExtEmConfRector::class);
$services->set(ExtensionComposerRector::class);
// Do you want to modernize your TypoScript include statements for files and move from <INCLUDE /> to @import use the FileIncludeToImportStatementVisitor
// $services->set(FileIncludeToImportStatementTypoScriptRector::class);
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment