2017-03-07 11:52:52 +01:00
|
|
|
.. _highlight: bash
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
2017-04-11 14:39:47 +02:00
|
|
|
The official project home page can be found at https://git.higidi.com/Automated-TYPO3-Update/automated-typo3-update .
|
|
|
|
Please open new issues and merge requests there. You can login with your Github account.
|
|
|
|
|
|
|
|
Github is just used as a mirror for the project.
|
|
|
|
|
2017-03-07 11:52:52 +01:00
|
|
|
Requirements
|
|
|
|
============
|
|
|
|
|
2017-04-11 14:39:47 +02:00
|
|
|
- ``composer`` needs to be installed and inside your ``$PATH``. Otherwise run ``make
|
|
|
|
install-composer``.
|
2017-03-07 11:52:52 +01:00
|
|
|
|
|
|
|
Installation
|
|
|
|
============
|
|
|
|
|
|
|
|
Run::
|
|
|
|
|
|
|
|
make install
|
|
|
|
|
2017-03-09 11:49:41 +01:00
|
|
|
and copy the ``vendor/composer/autoload_classaliasmap.php`` generated by ``composer`` in your TYPO3
|
|
|
|
installation to ``LegacyClassnames.php`` in the root of this project.
|
2017-03-07 11:52:52 +01:00
|
|
|
|
|
|
|
Usage
|
|
|
|
=====
|
|
|
|
|
2017-03-09 11:49:41 +01:00
|
|
|
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`` and ``implements``.
|
|
|
|
|
|
|
|
- Static calls like ``t3lib_div::`` to ``\TYPO3\Core\Utility\GeneralUtility``.
|
|
|
|
|
2017-03-28 08:48:43 +02:00
|
|
|
- Static call also checks for ``::class``, as technically we just look before the ``::``.
|
|
|
|
|
2017-03-09 11:49:41 +01:00
|
|
|
- Typehints in methods and function like injects.
|
2017-03-09 11:57:49 +01:00
|
|
|
|
2017-03-14 08:40:45 +01:00
|
|
|
- ``instanceof`` checks.
|
2017-03-09 11:57:49 +01:00
|
|
|
|
2017-03-14 08:32:21 +01:00
|
|
|
- Inline comments for IDEs, e.g. ``/* @var $configurationManager
|
|
|
|
Tx_Extbase_Configuration_ConfigurationManager */``
|
2017-03-09 11:57:49 +01:00
|
|
|
|
2017-03-14 09:25:45 +01:00
|
|
|
- Instantiation through ``new``.
|
2017-03-09 11:57:49 +01:00
|
|
|
|
2017-03-16 14:17:40 +01:00
|
|
|
- Instantiation through ``makeInstance``. Only Classnames in Strings are supported, no ``::class``.
|
2017-03-14 10:06:07 +01:00
|
|
|
|
2017-03-16 14:12:58 +01:00
|
|
|
- Instantiation through ``ObjectManager``, check afterwards as this is static and all function calls
|
|
|
|
using ``get`` and ``create`` will be adjusted. Might be useful to exclude this sniff and run it
|
|
|
|
separately.
|
2017-03-16 14:17:40 +01:00
|
|
|
Only Classnames in Strings are supported, no ``::class``.
|
2017-03-16 14:12:58 +01:00
|
|
|
|
2017-03-16 15:13:33 +01:00
|
|
|
- ``use`` statements.
|
|
|
|
|
2017-03-21 08:30:19 +01:00
|
|
|
- ``catch`` of legacy class names.
|
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
- Convert old legacy class *definitions* in extensions to namespaces.
|
2017-03-21 16:35:25 +01:00
|
|
|
|
2017-03-23 13:09:58 +01:00
|
|
|
- Convert usage of previously converted class definitions. On first run the definition will be
|
2017-03-28 08:40:19 +02:00
|
|
|
converted, on second run the usage. This is due to the fact, that PHPCS might find the definition
|
2017-03-23 13:09:58 +01:00
|
|
|
after the usage, so please run twice.
|
|
|
|
|
|
|
|
*NOTE* The configured file will be updated after each run, for each converted class, trait and
|
2017-03-28 08:40:19 +02:00
|
|
|
interface definition. See options.
|
2017-03-23 13:09:58 +01:00
|
|
|
|
2017-03-23 11:27:40 +01:00
|
|
|
- Add missing vendor to plugin and module registrations and configurations.
|
|
|
|
You might want to set this to non fixable and warning if you already provide the vendor inside a
|
|
|
|
single Variable, together with your extension key, as this is not recognized. So the following
|
|
|
|
will be recognized:
|
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
- ``$_EXTKEY,``
|
2017-03-23 11:27:40 +01:00
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
- ``$VENDOR . $_EXTKEY,``
|
2017-03-23 11:27:40 +01:00
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
- ``'VENDOR.' . $_EXTKEY,``
|
2017-03-23 11:27:40 +01:00
|
|
|
|
|
|
|
While the following will not:
|
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
- ``$key = 'Vendor.' . $_EXTKEY;``
|
2017-03-23 11:27:40 +01:00
|
|
|
|
2017-03-16 14:12:58 +01:00
|
|
|
Also we check for the following deprecated calls:
|
|
|
|
|
|
|
|
- Check for ``create`` on ``ObjectManager``, which is "stupid" just all ``create`` calls are marked
|
|
|
|
with a warning.
|
|
|
|
|
2017-03-30 13:18:18 +02:00
|
|
|
Beside the features above which are covered by ``phpcs`` and phpcbf``, the following linting is also
|
|
|
|
available to generate a report of possible issues and during coding through ``phpcs``:
|
|
|
|
|
|
|
|
- Check for usage of removed functions.
|
|
|
|
The functions are configured via yaml files. The location of them is configurable, default is
|
|
|
|
inside the standard itself, and we try to deliver all information.
|
|
|
|
For configuration options see ``removedFunctionConfigFiles``.
|
|
|
|
|
2017-04-04 10:59:46 +02:00
|
|
|
- Check for usage of removed constants.
|
|
|
|
The constants are configured in same way as removed functions.
|
2017-04-06 08:26:13 +02:00
|
|
|
For configuration options see ``removedConstantConfigFiles``.
|
2017-04-04 10:59:46 +02:00
|
|
|
|
2017-03-09 11:57:49 +01:00
|
|
|
What does it look like?
|
|
|
|
=======================
|
|
|
|
|
|
|
|
.. code::
|
|
|
|
|
|
|
|
$ ./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
|
2017-03-16 11:06:15 +01:00
|
|
|
|
|
|
|
Configuration
|
|
|
|
=============
|
|
|
|
|
|
|
|
Configuration is done through PHPCS Standards, e.g. provide a custom ``ruleset.xml`` or customize
|
|
|
|
the provided one.
|
|
|
|
|
|
|
|
``legacyExtensions``
|
|
|
|
Configures which extension names are legacy. Used to provide further checks and warnings about
|
|
|
|
possible legacy code. E.g. inside of non auto migrated situations.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: xml
|
|
|
|
|
|
|
|
<rule ref="Typo3Update.LegacyClassnames.Instanceof">
|
|
|
|
<properties>
|
|
|
|
<property name="legacyExtensions" type="array" value="Extbase,Fluid,Frontend,Core"/>
|
|
|
|
</properties>
|
|
|
|
</rule>
|
2017-03-16 16:24:47 +01:00
|
|
|
|
|
|
|
Typo3Update.LegacyClassnames.DocComment: ``allowedTags``
|
|
|
|
Configures which tags are checked for legacy class names.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: xml
|
|
|
|
|
|
|
|
<rule ref="Typo3Update.LegacyClassnames.DocComment">
|
|
|
|
<properties>
|
|
|
|
<property name="allowedTags" type="array" value="@param,@return,@var,@see,@throws"/>
|
|
|
|
</properties>
|
|
|
|
</rule>
|
2017-03-21 16:35:25 +01:00
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
``mappingFile``
|
|
|
|
Configure where the `LegacyClassnames.php` is located, through ``ruleset.xml`` or using
|
|
|
|
``--runtime-set``. Default is `LegacyClassnames.php` in the project root.
|
2017-03-21 16:35:25 +01:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: xml
|
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
<config name="mappingFile" value="/projects/typo3_installation/vendor/composer/autoload_classaliasmap.php"/>
|
2017-03-21 16:35:25 +01:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
--runtime-set mappingFile /projects/typo3_installation/vendor/composer/autoload_classaliasmap.php
|
2017-03-23 13:34:12 +01:00
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
``vendor``
|
|
|
|
Configure your vendor through ``ruleset.xml`` or using ``--runtime-set``. Default is
|
|
|
|
``YourCompany``.
|
2017-03-23 09:32:12 +01:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: xml
|
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
<config name="vendor" value="YourVendor"/>
|
2017-03-23 09:32:12 +01:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
2017-03-28 08:40:19 +02:00
|
|
|
--runtime-set vendor YourVendor
|
2017-03-30 13:18:18 +02:00
|
|
|
|
|
|
|
``removedFunctionConfigFiles``
|
|
|
|
Configure your vendor through ``ruleset.xml`` or using ``--runtime-set``. Default is
|
|
|
|
``Configuration/Removed/Functions/*.yaml`` inside the standard itself.
|
|
|
|
Globing is used, so placeholders like ``*`` are possible, see
|
|
|
|
https://secure.php.net/manual/en/function.glob.php
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: xml
|
|
|
|
|
|
|
|
<config name="removedFunctionConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
|
|
|
--runtime-set removedFunctionConfigFiles "/Some/Absolute/Path/*.yaml"
|
2017-04-04 10:59:46 +02:00
|
|
|
|
|
|
|
``removedConstantConfigFiles``
|
|
|
|
Configure your vendor through ``ruleset.xml`` or using ``--runtime-set``. Default is
|
|
|
|
``Configuration/Removed/Constants/*.yaml`` inside the standard itself.
|
|
|
|
Globing is used, so placeholders like ``*`` are possible, see
|
|
|
|
https://secure.php.net/manual/en/function.glob.php
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: xml
|
|
|
|
|
|
|
|
<config name="removedConstantConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
.. code:: bash
|
|
|
|
|
|
|
|
--runtime-set removedConstantConfigFiles "/Some/Absolute/Path/*.yaml"
|