Skip to content

Commit

Permalink
[TASK] Add config loading to docs and template file
Browse files Browse the repository at this point in the history
  • Loading branch information
helsner committed Oct 16, 2023
1 parent 666dcd9 commit ed6b7c4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
33 changes: 16 additions & 17 deletions docs/configuration_and_processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Let's say you want to migrate the TCA from a TYPO3 7 project to the latest TYPO3
```php
<?php

// rector.php
declare(strict_types=1);

use Rector\Config\RectorConfig;
Expand All @@ -48,27 +47,30 @@ use Ssch\TYPO3Rector\Configuration\Typo3Option;
use Ssch\TYPO3Rector\Rector\General\ConvertImplicitVariablesToExplicitGlobalsRector;
use Ssch\TYPO3Rector\Rector\General\ExtEmConfRector;
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
use Ssch\TYPO3Rector\Set\Typo3SetList;

return static function (RectorConfig $rectorConfig): void {

// If you want to override the number of spaces for your typoscript files you can define it here, the default value is 4
// $parameters = $rectorConfig->parameters();
// $parameters->set(Typo3Option::TYPOSCRIPT_INDENT_SIZE, 2);

$rectorConfig->sets([
Typo3LevelSetList::UP_TO_TYPO3_11
Typo3LevelSetList::UP_TO_TYPO3_11,
// https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/Configuration/Icons.html
// Typo3SetList::REGISTER_ICONS_TO_ICON,
]);

// In order to have a better analysis from phpstan we teach it here some more things
$rectorConfig->phpstanConfig(Typo3Option::PHPSTAN_FOR_RECTOR_PATH);
// register a single rule
// $rectorConfig->import(__DIR__ . '/vendor/ssch/typo3-rector/config/config.php');
// $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector::class);

// FQN classes are not imported by default. If you don't do it manually after every Rector run, enable it by:
$rectorConfig->importNames();
// Define your target version which you want to support
$rectorConfig->phpVersion(PhpVersion::PHP_74);

// Disable parallel otherwise non php file processing is not working i.e. typoscript
$rectorConfig->disableParallel();

// this will not import root namespace classes, like \DateTime or \Exception
$rectorConfig->disableImportShortClasses();

// Define your target version which you want to support
$rectorConfig->phpVersion(PhpVersion::PHP_74);

// 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()
// $rectorConfig->paths([
Expand Down Expand Up @@ -106,12 +108,9 @@ return static function (RectorConfig $rectorConfig): void {
// 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
// $rectorConfig->bootstrapFiles([
// $parameters->set(Option::BOOTSTRAP_FILES, [
// __DIR__ . '/typo3.constants.php'
//]);

// register a single rule
// $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector::class);
// ]);

/**
* Useful rule from RectorPHP itself to transform i.e. GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')
Expand Down
10 changes: 7 additions & 3 deletions templates/rector.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ return static function (RectorConfig $rectorConfig): void {
// Typo3SetList::REGISTER_ICONS_TO_ICON,
]);

// register a single rule
// $rectorConfig->import(__DIR__ . '/vendor/ssch/typo3-rector/config/config.php');
// $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector::class);

// Define your target version which you want to support
$rectorConfig->phpVersion(PhpVersion::PHP_74);

// Disable parallel otherwise non php file processing is not working i.e. typoscript
$rectorConfig->disableParallel();

// 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()
// $rectorConfig->paths([
Expand Down Expand Up @@ -68,9 +75,6 @@ return static function (RectorConfig $rectorConfig): void {
// __DIR__ . '/typo3.constants.php'
// ]);

// register a single rule
// $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v0\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.
Expand Down

0 comments on commit ed6b7c4

Please sign in to comment.