Automate code migrations for TYPO3 Extensions
Daniel Siepmann
20722f26d1
* As method does not belong to class renaming, but is a general method, it was moved to a new trait. Relates: #4 |
||
---|---|---|
src/Standards/Typo3Update | ||
.gitignore | ||
composer.json | ||
LICENSE | ||
Makefile | ||
Readme.rst |
About
Our goal is to provide an automated migration for TYPO3 updates.
This should include source code modifications like adjusting old legacy class names to new ones.
Requirements
composer
needs to be installed and inside your$PATH
.
Installation
Run:
make install
and copy the vendor/composer/autoload_classaliasmap.php
generated by composer
in your TYPO3 installation to
LegacyClassnames.php
in the root of this project.
Usage
Run:
./vendor/bin/phpcbf <path>
This will run the auto fixer recursive for <path>
fixing all issues.
Afterwards you should run:
./vendor/bin/phpcs <path>
To get information about possible issues that were not autofixed.
What's included?
Currently we can migrate calls to old legacy class names of the TYPO3
core like Tx_Extbase...
to new ones like
\TYPO3\Extbase\...
. This is done for:
- PHPDocuments, like Includes and annotations for IDEs.
- Inheritance like
extends
andimplements
. - Static calls like
t3lib_div::
to\TYPO3\Core\Utility\GeneralUtility
. - Typehints in methods and function like injects.
- Instantiation through
new
. - Instantiation through
makeInstance
.
What does it look like?
$ ./vendor/bin/phpcs -p --colors -s <path>
E
FILE: <path>
----------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
----------------------------------------------------------------------
8 | ERROR | [x] Legacy classes are not allowed; found
| | backend_toolbarItem
| | (Typo3Update.LegacyClassnames.Inheritance.legacyClassname)
14 | ERROR | [x] Legacy classes are not allowed; found TYPO3backend
| | (Typo3Update.LegacyClassnames.DocComment.legacyClassname)
16 | ERROR | [x] Legacy classes are not allowed; found TYPO3backend
| | (Typo3Update.LegacyClassnames.TypeHint.legacyClassname)
48 | ERROR | [x] Legacy classes are not allowed; found t3lib_extMgm
| | (Typo3Update.LegacyClassnames.StaticCall.legacyClassname)
61 | ERROR | [x] Legacy classes are not allowed; found t3lib_div
| | (Typo3Update.LegacyClassnames.StaticCall.legacyClassname)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 35ms; Memory: 5Mb