brotkrueml / schema-rector
Instant upgrade and refactoring for the TYPO3 schema extension code by using Rector
Requires
- php: >=7.3
- brotkrueml/schema: ^1.7
- rector/rector: ^0.10.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- phpunit/phpunit: ^9.5
- rector/rector-generator: ^0.1.6
This package is auto-updated.
Last update: 2023-09-12 14:47:04 UTC
README
This package provides Rector rules for migrating code from older versions of the TYPO3 extension schema.
Note: If you don't know already, you can also migrate TYPO3 core-specific code with Rector for TYPO3.
Installation
The package can be installed with composer:
composer req --dev brotkrueml/schema-rector
Caution: Never run this tool on production, only on development environment where code is under version control (e.g. git). Always review and test automatic changes before releasing to production.
Configuration
Create a rector.php
file in the project's root folder:
<?php declare(strict_types=1); use Brotkrueml\SchemaRector\Rules\RenameSchemaManagerSetMainEntityOfWebPageRector;use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameSchemaManagerSetMainEntityOfWebPageRector::class); };
Afterwards you can start a dry-run to see the possible changes
(assuming the extensions of your projects are available under the
packages
folder):
vendor/bin/rector process packages --dry-run
If everything is okay for you than you can omit the dry-run
option
to write the changes to your code.
Rules
The following rules are available:
RenameSchemaManagerSetMainEntityOfWebPageRector
This Rector migrates the deprecated SchemaManager->setMainEntityOfWebPage()
method call to the new SchemaManager->addMainEntityOfWebPage()
.
🔧 configure it!
use Brotkrueml\SchemaRector\Rules\RenameSchemaManagerSetMainEntityOfWebPageRector; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); $services->set(RenameSchemaManagerSetMainEntityOfWebPageRector::class); };
↓
$schemaManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Brotkrueml\Schema\Manager\SchemaManager::class); $type = new \Brotkrueml\Schema\Model\Type\Thing(); -$schemaManager->setMainEntityOfPage($type); +$schemaManager->addMainEntityOfPage($type);