Merge branch 'feature/72-refactor-sniff-architecture' into feature/54-add-checks-for-typoscript
This commit is contained in:
commit
69bb97ad94
88 changed files with 807 additions and 934 deletions
|
@ -26,47 +26,36 @@ sync:github:
|
|||
- cd mirror
|
||||
- git push --mirror ${MIRROR_GIT_URL}
|
||||
|
||||
lint:coding-guideline:
|
||||
lint:coding-guideline: &PHP-LINTING
|
||||
image: php:7.0-alpine
|
||||
stage: test
|
||||
script:
|
||||
- ./vendor/bin/phpcs -s -n
|
||||
- ./vendor/bin/phpcs -s -n > result/phpcs-summary.txt
|
||||
- ./vendor/bin/phpcs -s -n --report-full=result/phpcs-full.txt --report-diff=result/phpcs-diff.txt --report-summary=result/phpcs-summary.txt
|
||||
artifacts:
|
||||
when: on_failure
|
||||
paths:
|
||||
- result
|
||||
|
||||
lint:php-mass-detection:
|
||||
image: php:7.0-alpine
|
||||
stage: test
|
||||
<<: *PHP-LINTING
|
||||
script:
|
||||
- ./vendor/bin/phpmd src text phpmd.xml > result/phpmd.txt
|
||||
- ./vendor/bin/phpmd src html phpmd.xml > result/phpmd.html
|
||||
artifacts:
|
||||
when: on_failure
|
||||
paths:
|
||||
- result
|
||||
|
||||
test:5.6:
|
||||
test:5.6: &PHP-UNITTESTING
|
||||
image: php:5.6-alpine
|
||||
stage: test
|
||||
script:
|
||||
- ./vendor/bin/phpunit
|
||||
|
||||
test:7.0:
|
||||
<<: *PHP-UNITTESTING
|
||||
image: php:7.0-alpine
|
||||
stage: test
|
||||
script:
|
||||
- ./vendor/bin/phpunit
|
||||
|
||||
test:latest:
|
||||
<<: *PHP-UNITTESTING
|
||||
image: php:7-alpine
|
||||
stage: test
|
||||
script:
|
||||
- ./vendor/bin/phpunit
|
||||
|
||||
test:documentation:syntax:
|
||||
test:documentation:syntax: &SPHINX-DOCS
|
||||
image: 'danielsiepmann/sphinx:latest'
|
||||
stage: test
|
||||
before_script:
|
||||
|
@ -75,18 +64,13 @@ test:documentation:syntax:
|
|||
- make dummy
|
||||
|
||||
test:documentation:external-links:
|
||||
image: 'danielsiepmann/sphinx:latest'
|
||||
stage: test
|
||||
before_script:
|
||||
- cd Documentation
|
||||
<<: *SPHINX-DOCS
|
||||
script:
|
||||
- make linkcheck
|
||||
|
||||
render:documentation:
|
||||
image: 'danielsiepmann/sphinx:latest'
|
||||
<<: *SPHINX-DOCS
|
||||
stage: render
|
||||
before_script:
|
||||
- cd Documentation
|
||||
script:
|
||||
- make html
|
||||
artifacts:
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
build:
|
||||
tests:
|
||||
before:
|
||||
- make install
|
||||
environment:
|
||||
php:
|
||||
version: 5.6
|
||||
ini:
|
||||
'date.timezone': 'Europe/Berlin'
|
||||
|
||||
filter:
|
||||
excluded_paths:
|
||||
- "tests/Fixtures/"
|
|
@ -29,7 +29,7 @@ import os
|
|||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.intersphinx',
|
||||
# 'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
]
|
||||
|
||||
|
@ -310,4 +310,4 @@ texinfo_documents = [
|
|||
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
# intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
|
|
|
@ -36,13 +36,13 @@ Configures which extension names are legacy. Used to provide further checks and
|
|||
possible legacy code. All class usages starting with ``Tx_<ExtensionName>`` where ExtensionName is
|
||||
defined in this array, will produce a warning, until the class is already found to be deprecaed.
|
||||
|
||||
Can and have to be configured for each sniff, e.g. ``Instanceof`` and ``DocComment``.
|
||||
Can and have to be configured for each sniff, e.g. ``Instanceof`` and ``PhpDocComment``.
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: xml
|
||||
|
||||
<rule ref="Typo3Update.LegacyClassnames.Instanceof">
|
||||
<rule ref="Typo3Update.Classname.Instanceof">
|
||||
<properties>
|
||||
<property name="legacyExtensions" type="array" value="Extbase,Fluid,Frontend,Core"/>
|
||||
</properties>
|
||||
|
@ -54,7 +54,7 @@ Example:
|
|||
allowedTags
|
||||
^^^^^^^^^^^
|
||||
|
||||
Only used inside Sniff ``Typo3Update.LegacyClassnames.DocComment``.
|
||||
Only used inside Sniff ``Typo3Update.Classname.PhpDocComment``.
|
||||
|
||||
Configures which tags are checked for legacy class names.
|
||||
|
||||
|
@ -65,7 +65,7 @@ Example:
|
|||
|
||||
.. code:: xml
|
||||
|
||||
<rule ref="Typo3Update.LegacyClassnames.DocComment">
|
||||
<rule ref="Typo3Update.Classname.PhpDocComment">
|
||||
<properties>
|
||||
<property name="allowedTags" type="array" value="@param,@return,@var,@see,@throws"/>
|
||||
</properties>
|
||||
|
@ -114,7 +114,7 @@ Using :file:`ruleset.xml`:
|
|||
|
||||
<config name="vendor" value="YourVendor"/>
|
||||
|
||||
Example:
|
||||
Using ``runtime-set``:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
|
@ -137,7 +137,7 @@ Using :file:`ruleset.xml`:
|
|||
|
||||
<config name="removedFunctionConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
|
||||
|
||||
Example:
|
||||
Using ``runtime-set``:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
|
@ -159,7 +159,7 @@ Using :file:`ruleset.xml`:
|
|||
|
||||
<config name="removedConstantConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
|
||||
|
||||
Example:
|
||||
Using ``runtime-set``:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
|
@ -181,12 +181,33 @@ Using :file:`ruleset.xml`:
|
|||
|
||||
<config name="removedTypoScriptConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
|
||||
|
||||
Example:
|
||||
Using ``runtime-set``:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
--runtime-set removedTypoScriptConfigFiles "/Some/Absolute/Path/*.yaml"
|
||||
|
||||
.. _configuration-features:
|
||||
|
||||
features
|
||||
^^^^^^^^
|
||||
|
||||
Configure where to look for configuration files defining the feature mappings. Default is
|
||||
``Configuration/Features/*.yaml`` inside the standard itself. Globing is used, so placeholders like
|
||||
``*`` are possible, see https://secure.php.net/manual/en/function.glob.php
|
||||
|
||||
Using :file:`ruleset.xml`:
|
||||
|
||||
.. code:: xml
|
||||
|
||||
<config name="features" value="/Some/Absolute/Path/*.yaml"/>
|
||||
|
||||
Using ``runtime-set``:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
--runtime-set features "/Some/Absolute/Path/*.yaml"
|
||||
|
||||
.. _configuration-yaml-files:
|
||||
|
||||
YAML Files
|
||||
|
|
|
@ -24,6 +24,24 @@ The following resources might be helpful during working with ``phpcs``:
|
|||
|
||||
- :file:`CodeSniffer/File.php`
|
||||
|
||||
.. _extending-features:
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Sniffs do not always add errors or warnings in our standard, instead for more flexibility, we use
|
||||
them to find specific "tokens", e.g. class names. We then attach so called *Features* to sniffs to
|
||||
work on that token.
|
||||
|
||||
E.g. we deliver the Feature ``LegacyClassnameFeature`` which will check whether a given class name
|
||||
is legacy and should be replaced. As class names may occur in many places like type hints or php doc
|
||||
blocks, the sniffs will detect the class names and the feature will work on them.
|
||||
|
||||
Features can be attached to the sniffs. A feature has to implement the ``FeatureInterface`` and will
|
||||
work on tokens found by sniffs.
|
||||
|
||||
To attach a Feature to Sniffs, provide a yaml-configuration, see :ref:`configuration-features`.
|
||||
|
||||
.. _extending-tests:
|
||||
|
||||
Tests
|
||||
|
@ -40,7 +58,7 @@ has to exist: :file:`tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname
|
|||
.. _extending-tests-single:
|
||||
|
||||
Single test per sniff
|
||||
---------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Inside of the folder at least a file :file:`InputFileForIssues.php` has to exist, containing PHP
|
||||
code to use for the test. Also a file :file:`Expected.json` has to exist, with the json result of
|
||||
|
@ -54,7 +72,7 @@ If your sniff also implements fixable errors or warnings, you can further provid
|
|||
.. _extending-tests-multiple:
|
||||
|
||||
Multiple tests per sniff
|
||||
------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Also it's possible to provide multiple tests for a single sniff, e.g. with different cli arguments
|
||||
like options for the sniff. In that case you have to place a :file:`Arguments.php` in the folder.
|
||||
|
@ -81,7 +99,7 @@ Also you can provide further cli arguments on a key -> value base. Where ``runti
|
|||
as it contains a sub array to provide multiple runtime sets.
|
||||
|
||||
How sniff tests are implemented
|
||||
-------------------------------
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
We just find all folders below :file:`tests/Fixtures/Standards/Typo3Update/Sniffs` ending with
|
||||
``Sniff`` and check the structure. They are provided to the test itself through a dataprovider in
|
||||
|
|
|
@ -98,10 +98,10 @@ Also we check for the following deprecated calls:
|
|||
|
||||
Check for usage of *removed functions* in general. 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``.
|
||||
information. For configuration options see :ref:`configuration-removedFunctionConfigFiles`.
|
||||
|
||||
Check for usage of *removed constants*. The constants are configured in same way as removed
|
||||
functions. For configuration options see ``removedConstantConfigFiles``.
|
||||
functions. For configuration options see :ref:`configuration-removedConstantConfigFiles`.
|
||||
|
||||
|
||||
Further checks
|
||||
|
|
239
Readme.rst
239
Readme.rst
|
@ -1,5 +1,3 @@
|
|||
.. _highlight: bash
|
||||
|
||||
About
|
||||
=====
|
||||
|
||||
|
@ -12,239 +10,4 @@ Please open new issues and merge requests there. You can login with your Github
|
|||
|
||||
Github is just used as a mirror for the project.
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
- ``composer`` needs to be installed and inside your ``$PATH``. Otherwise run ``make
|
||||
install-composer``.
|
||||
|
||||
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`` and ``implements``.
|
||||
|
||||
- Static calls like ``t3lib_div::`` to ``\TYPO3\Core\Utility\GeneralUtility``.
|
||||
|
||||
- Static call also checks for ``::class``, as technically we just look before the ``::``.
|
||||
|
||||
- Typehints in methods and function like injects.
|
||||
|
||||
- ``instanceof`` checks.
|
||||
|
||||
- Inline comments for IDEs, e.g. ``/* @var $configurationManager
|
||||
Tx_Extbase_Configuration_ConfigurationManager */``
|
||||
|
||||
- Instantiation through ``new``.
|
||||
|
||||
- Instantiation through ``makeInstance``. Only Classnames in Strings are supported, no ``::class``.
|
||||
|
||||
- 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.
|
||||
Only Classnames in Strings are supported, no ``::class``.
|
||||
|
||||
- ``use`` statements.
|
||||
|
||||
- ``catch`` of legacy class names.
|
||||
|
||||
- Convert old legacy class *definitions* in extensions to namespaces.
|
||||
|
||||
- Convert usage of previously converted class definitions. On first run the definition will be
|
||||
converted, on second run the usage. This is due to the fact, that PHPCS might find the definition
|
||||
after the usage, so please run twice.
|
||||
|
||||
*NOTE* The configured file will be updated after each run, for each converted class, trait and
|
||||
interface definition. See options.
|
||||
|
||||
- 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:
|
||||
|
||||
- ``$_EXTKEY,``
|
||||
|
||||
- ``$VENDOR . $_EXTKEY,``
|
||||
|
||||
- ``'VENDOR.' . $_EXTKEY,``
|
||||
|
||||
While the following will not:
|
||||
|
||||
- ``$key = 'Vendor.' . $_EXTKEY;``
|
||||
|
||||
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.
|
||||
|
||||
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``.
|
||||
|
||||
- Check for usage of removed constants.
|
||||
The constants are configured in same way as removed functions.
|
||||
For configuration options see ``removedConstantConfigFiles``.
|
||||
|
||||
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
|
||||
|
||||
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>
|
||||
|
||||
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>
|
||||
|
||||
``mappingFile``
|
||||
Configure where the `LegacyClassnames.php` is located, through ``ruleset.xml`` or using
|
||||
``--runtime-set``. Default is `LegacyClassnames.php` in the project root.
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: xml
|
||||
|
||||
<config name="mappingFile" value="/projects/typo3_installation/vendor/composer/autoload_classaliasmap.php"/>
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
--runtime-set mappingFile /projects/typo3_installation/vendor/composer/autoload_classaliasmap.php
|
||||
|
||||
``vendor``
|
||||
Configure your vendor through ``ruleset.xml`` or using ``--runtime-set``. Default is
|
||||
``YourCompany``.
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: xml
|
||||
|
||||
<config name="vendor" value="YourVendor"/>
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
--runtime-set vendor YourVendor
|
||||
|
||||
``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"
|
||||
|
||||
``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"
|
||||
Check out the official documentation at: https://automated-typo3-update.readthedocs.io
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
Typo3Update\Feature\LegacyClassnameFeature:
|
||||
- Typo3Update_Sniffs_Classname_InheritanceSniff
|
||||
- Typo3Update_Sniffs_Classname_InlineCommentSniff
|
||||
- Typo3Update_Sniffs_Classname_InstanceofSniff
|
||||
- Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff
|
||||
- Typo3Update_Sniffs_Classname_InstantiationWithNewSniff
|
||||
- Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff
|
||||
- Typo3Update_Sniffs_Classname_IsACallSniff
|
||||
- Typo3Update_Sniffs_Classname_MissingVendorForPluginsAndModulesSniff
|
||||
- Typo3Update_Sniffs_Classname_PhpDocCommentSniff
|
||||
- Typo3Update_Sniffs_Classname_StaticCallSniff
|
||||
- Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff
|
||||
- Typo3Update_Sniffs_Classname_TypeHintSniff
|
||||
- Typo3Update_Sniffs_Classname_UseSniff
|
||||
- Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff
|
40
src/Standards/Typo3Update/Feature/FeatureInterface.php
Normal file
40
src/Standards/Typo3Update/Feature/FeatureInterface.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
namespace Typo3Update\Feature;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
|
||||
/**
|
||||
* See "Features" in documentation.
|
||||
*/
|
||||
interface FeatureInterface
|
||||
{
|
||||
/**
|
||||
* Process like a PHPCS Sniff.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile The current PhpCsFile working with.
|
||||
* @param int $stackPtr The current stack pointer.
|
||||
* @param string $content The content detected to work with.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr, $content);
|
||||
}
|
73
src/Standards/Typo3Update/Feature/Features.php
Normal file
73
src/Standards/Typo3Update/Feature/Features.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
namespace Typo3Update\Feature;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||
use Typo3Update\Options;
|
||||
|
||||
/**
|
||||
* Contains all configured features for a single sniff.
|
||||
*/
|
||||
class Features implements \Iterator
|
||||
{
|
||||
protected $index = 0;
|
||||
protected $features = [];
|
||||
|
||||
/**
|
||||
* @param PhpCsSniff $sniff The sniff to collect features for.
|
||||
*/
|
||||
public function __construct(PhpCsSniff $sniff)
|
||||
{
|
||||
foreach (Options::getFeaturesConfiguration() as $featureName => $sniffs) {
|
||||
if (in_array(get_class($sniff), $sniffs)) {
|
||||
if (!class_implements($featureName, FeatureInterface::class)) {
|
||||
throw new \Exception(
|
||||
'Configured Feature "' . $featureName . '" does not implement "' . FeatureInterface::class . '".',
|
||||
1493115488
|
||||
);
|
||||
}
|
||||
$this->features[] = $featureName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// implement Iterator interface:
|
||||
public function current()
|
||||
{
|
||||
return $this->features[$this->index];
|
||||
}
|
||||
public function key()
|
||||
{
|
||||
return $this->index;
|
||||
}
|
||||
public function next()
|
||||
{
|
||||
++$this->index;
|
||||
}
|
||||
public function rewind()
|
||||
{
|
||||
$this->index = 0;
|
||||
}
|
||||
public function valid()
|
||||
{
|
||||
return isset($this->features[$this->index]);
|
||||
}
|
||||
}
|
65
src/Standards/Typo3Update/Feature/FeaturesSupport.php
Normal file
65
src/Standards/Typo3Update/Feature/FeaturesSupport.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
namespace Typo3Update\Feature;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
|
||||
/**
|
||||
* Provides "feature" support for sniffs.
|
||||
*/
|
||||
trait FeaturesSupport
|
||||
{
|
||||
/**
|
||||
* @var Features
|
||||
*/
|
||||
protected $features;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->features = new Features($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes all features for the sniff.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $stackPtr
|
||||
* @param string $content
|
||||
*/
|
||||
public function processFeatures(PhpCsFile $phpcsFile, $stackPtr, $content)
|
||||
{
|
||||
foreach ($this->features as $featureClassName) {
|
||||
$feature = $this->createFeature($featureClassName);
|
||||
$feature->process($phpcsFile, $stackPtr, $content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the given feature.
|
||||
*
|
||||
* @param string $featureClassname
|
||||
* @return FeatureInterface
|
||||
*/
|
||||
protected function createFeature($featureClassname)
|
||||
{
|
||||
return new $featureClassname($this);
|
||||
}
|
||||
}
|
212
src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php
Normal file
212
src/Standards/Typo3Update/Feature/LegacyClassnameFeature.php
Normal file
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
namespace Typo3Update\Feature;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer as PhpCs;
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||
|
||||
/**
|
||||
* This feature will add fixable errors for old legacy classnames.
|
||||
*
|
||||
* Can be attached to sniffs returning classnames.
|
||||
*/
|
||||
class LegacyClassnameFeature implements FeatureInterface
|
||||
{
|
||||
/**
|
||||
* A list of extension names that might contain legacy class names.
|
||||
* Used to check clas names for warnings.
|
||||
*
|
||||
* Configure through ruleset.xml.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
public $legacyExtensions = ['Extbase', 'Fluid'];
|
||||
|
||||
/**
|
||||
* @var LegacyClassnameMapping
|
||||
*/
|
||||
protected $legacyMapping;
|
||||
|
||||
/**
|
||||
* @var PhpCsSniff
|
||||
*/
|
||||
protected $sniff;
|
||||
|
||||
public function __construct(PhpCsSniff $sniff)
|
||||
{
|
||||
$this->sniff = $sniff;
|
||||
$this->legacyMapping = LegacyClassnameMapping::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process like a PHPCS Sniff.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $classnamePosition
|
||||
* @param string $classname
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname)
|
||||
{
|
||||
$classname = trim($classname, '\\\'"'); // Remove trailing slash, and quotes.
|
||||
$this->addMaybeWarning($phpcsFile, $classnamePosition, $classname);
|
||||
|
||||
if ($this->isLegacyClassname($classname) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fix = $phpcsFile->addFixableError(
|
||||
'Legacy classes are not allowed; found "%s", use "%s" instead',
|
||||
$classnamePosition,
|
||||
'legacyClassname',
|
||||
[$classname, $this->getNewClassname($classname)]
|
||||
);
|
||||
|
||||
if ($fix === true) {
|
||||
$this->replaceLegacyClassname($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a mapping exists for the given $classname,
|
||||
* indicating it's legacy.
|
||||
*
|
||||
* @param string $classname
|
||||
* @return bool
|
||||
*/
|
||||
protected function isLegacyClassname($classname)
|
||||
{
|
||||
return $this->legacyMapping->isLegacyClassname($classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guesses whether the given classname is legacy. Will not check
|
||||
* isLegacyClassname
|
||||
*
|
||||
* @param string $classname
|
||||
* @return bool
|
||||
*/
|
||||
protected function isMaybeLegacyClassname($classname)
|
||||
{
|
||||
if (strpos($classname, 'Tx_') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$extensionName = call_user_func(function ($classname) {
|
||||
$nameParts = explode('_', $classname);
|
||||
return $nameParts[1];
|
||||
}, $classname);
|
||||
|
||||
if (!in_array($extensionName, $this->legacyExtensions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $classname
|
||||
* @return string
|
||||
*/
|
||||
protected function getNewClassname($classname)
|
||||
{
|
||||
return $this->legacyMapping->getNewClassname($classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an warning if given $classname is maybe legacy.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $classnamePosition
|
||||
* @param string $classname
|
||||
*/
|
||||
protected function addMaybeWarning(PhpCsFile $phpcsFile, $classnamePosition, $classname)
|
||||
{
|
||||
if ($this->isLegacyClassname($classname) || $this->isMaybeLegacyClassname($classname) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$phpcsFile->addWarning(
|
||||
'Legacy classes are not allowed; found %s that might be a legacy class that does not exist anymore',
|
||||
$classnamePosition,
|
||||
'mightBeLegacyClassname',
|
||||
[$classname]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the classname at $classnamePosition with $classname in $phpcsFile.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $classnamePosition
|
||||
* @param string $classname
|
||||
*/
|
||||
protected function replaceLegacyClassname(
|
||||
PhpCsFile $phpcsFile,
|
||||
$classnamePosition,
|
||||
$classname
|
||||
) {
|
||||
$prefix = '\\';
|
||||
if ($this->useEmptyPrefix($phpcsFile, $classnamePosition)) {
|
||||
$prefix = '';
|
||||
}
|
||||
|
||||
$newClassname = str_replace(
|
||||
$classname,
|
||||
$prefix . $this->getNewClassname($classname),
|
||||
$phpcsFile->getTokens()[$classnamePosition]['content']
|
||||
);
|
||||
|
||||
// Handle double quotes, with special escaping.
|
||||
if ($newClassname[0] === '"') {
|
||||
$newClassname = '"\\\\' . str_replace('\\', '\\\\', ltrim(substr($newClassname, 1), '\\'));
|
||||
}
|
||||
|
||||
$phpcsFile->fixer->replaceToken($classnamePosition, $newClassname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether new class name for replacment should not contain the "\" as prefix.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function useEmptyPrefix(PhpCsFile $phpcsFile, $classnamePosition)
|
||||
{
|
||||
// Use statements don't start with T_NS_SEPARATOR.
|
||||
if (get_class($this->sniff) === \Typo3Update_Sniffs_Classname_UseSniff::class) {
|
||||
return true;
|
||||
}
|
||||
// If T_NS_SEPARATOR is already present before, don't add again.
|
||||
if ($phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) {
|
||||
return true;
|
||||
}
|
||||
// If inside string starting with T_NS_SEPARATOR don't add again.
|
||||
if (isset($phpcsFile->getTokens()[$classnamePosition]['content'][1])
|
||||
&& $phpcsFile->getTokens()[$classnamePosition]['content'][1] === '\\'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace Typo3Update\Sniffs\LegacyClassnames;
|
||||
namespace Typo3Update\Feature;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
|
@ -20,7 +20,7 @@ namespace Typo3Update\Sniffs\LegacyClassnames;
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\Options;
|
||||
use Typo3Update\Options;
|
||||
|
||||
/**
|
||||
* Singleton wrapper for mappings.
|
||||
|
@ -28,7 +28,7 @@ use Typo3Update\Sniffs\Options;
|
|||
* Will check the configured file for whether a class is legacy and provides further methods.
|
||||
* Also can update to add new migrated class names.
|
||||
*/
|
||||
final class Mapping
|
||||
final class LegacyClassnameMapping
|
||||
{
|
||||
// Singleton implementation - Start
|
||||
static protected $instance = null;
|
||||
|
@ -40,7 +40,7 @@ final class Mapping
|
|||
public static function getInstance()
|
||||
{
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new Mapping();
|
||||
static::$instance = new LegacyClassnameMapping();
|
||||
}
|
||||
|
||||
return static::$instance;
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace Typo3Update\Sniffs;
|
||||
namespace Typo3Update;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
|
@ -21,6 +21,7 @@ namespace Typo3Update\Sniffs;
|
|||
*/
|
||||
|
||||
use PHP_CodeSniffer as PhpCs;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Wrapper to retrieve options from PhpCs with defaults.
|
||||
|
@ -51,7 +52,7 @@ class Options
|
|||
{
|
||||
return (string) static::getOptionWithDefault(
|
||||
'mappingFile',
|
||||
__DIR__ . '/../../../../LegacyClassnames.php'
|
||||
__DIR__ . '/../../../LegacyClassnames.php'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,7 @@ class Options
|
|||
{
|
||||
return static::getOptionFileNames(
|
||||
'removedFunctionConfigFiles',
|
||||
__DIR__ . '/../Configuration/Removed/Functions/*.yaml'
|
||||
__DIR__ . '/Configuration/Removed/Functions/*.yaml'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -77,7 +78,7 @@ class Options
|
|||
{
|
||||
return static::getOptionFileNames(
|
||||
'removedConstantConfigFiles',
|
||||
__DIR__ . '/../Configuration/Removed/Constants/*.yaml'
|
||||
__DIR__ . '/Configuration/Removed/Constants/*.yaml'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,7 @@ class Options
|
|||
{
|
||||
return static::getOptionFileNames(
|
||||
'removedTypoScript',
|
||||
__DIR__ . '/../Configuration/Removed/TypoScript/*.yaml'
|
||||
__DIR__ . '/Configuration/Removed/TypoScript/*.yaml'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -112,6 +113,24 @@ class Options
|
|||
return $option;
|
||||
}
|
||||
|
||||
public static function getFeaturesConfiguration()
|
||||
{
|
||||
$option = [];
|
||||
$fileNames = static::getOptionFileNames(
|
||||
'features',
|
||||
__DIR__ . '/Configuration/Features/*.yaml'
|
||||
);
|
||||
|
||||
foreach ($fileNames as $file) {
|
||||
$option = array_merge(
|
||||
$option,
|
||||
Yaml::parse(file_get_contents((string) $file))
|
||||
);
|
||||
}
|
||||
|
||||
return $option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file names defined by option using optionName, if not defined, use default.
|
||||
*
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
namespace Typo3Update\Sniffs\Classname;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||
use Typo3Update\Feature\FeaturesSupport;
|
||||
|
||||
/**
|
||||
* Provide common uses for all sniffs, regarding class name checks.
|
||||
*
|
||||
* Will do nothing but calling configured features, allowing new extending
|
||||
* sniffs to find further class names.
|
||||
*/
|
||||
abstract class AbstractClassnameChecker implements PhpCsSniff
|
||||
{
|
||||
use FeaturesSupport;
|
||||
|
||||
/**
|
||||
* Define whether the T_STRING default behaviour should be checked before
|
||||
* or after the $stackPtr.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldLookBefore()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* This is the default implementation, as most of the time next T_STRING is
|
||||
* the class name. This way only the register method has to be registered
|
||||
* in default cases.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ElseExpression) This is for performance reason.
|
||||
*/
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
if ($this->shouldLookBefore()) {
|
||||
$classnamePosition = $phpcsFile->findPrevious(T_STRING, $stackPtr);
|
||||
} else {
|
||||
$classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr);
|
||||
}
|
||||
|
||||
if ($classnamePosition === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$classname = $tokens[$classnamePosition]['content'];
|
||||
$this->processFeatures($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
}
|
|
@ -20,12 +20,9 @@
|
|||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate extend and implement of old legacy classnames.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_InheritanceSniff extends AbstractClassnameChecker
|
||||
{
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
|
@ -34,10 +31,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClass
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
return [
|
||||
T_EXTENDS,
|
||||
T_IMPLEMENTS,
|
||||
];
|
||||
return [T_EXTENDS, T_IMPLEMENTS];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,16 +73,12 @@ class Typo3Update_Sniffs_LegacyClassnames_InheritanceSniff extends AbstractClass
|
|||
}
|
||||
|
||||
foreach ($interfaces as $interface) {
|
||||
if (! $this->isLegacyClassname($interface)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$position = $phpcsFile->findNext(T_STRING, $stackPtr, null, false, $interface);
|
||||
if ($position === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->addFixableError($phpcsFile, $position, $interface);
|
||||
$this->processFeatures($phpcsFile, $position, $interface);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,12 +20,9 @@
|
|||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Migrate PHP inline comments, e.g. for IDEs.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_InlineCommentSniff extends AbstractClassnameChecker
|
||||
{
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
|
@ -34,9 +31,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractCla
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
return [
|
||||
T_COMMENT,
|
||||
];
|
||||
return [T_COMMENT];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +54,7 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractCla
|
|||
return;
|
||||
}
|
||||
|
||||
$this->addFixableError($phpcsFile, $stackPtr, $commentParts[$this->getClassnamePosition($commentParts)]);
|
||||
$this->processFeatures($phpcsFile, $stackPtr, $commentParts[$this->getClassnamePosition($commentParts)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,25 +72,4 @@ class Typo3Update_Sniffs_LegacyClassnames_InlineCommentSniff extends AbstractCla
|
|||
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* As token contains more then just class name, we have to build new content ourself.
|
||||
*
|
||||
* @param string $newClassname
|
||||
* @param string $originalClassname
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @return string
|
||||
*/
|
||||
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
|
||||
{
|
||||
$token = preg_split('/\s+/', $this->originalTokenContent);
|
||||
$token[$this->getClassnamePosition($token)] = $newClassname;
|
||||
|
||||
// Keep line ending, removed by preg_split
|
||||
if ($token[0] === '//') {
|
||||
$token[count($token)] = $phpcsFile->eolChar;
|
||||
}
|
||||
|
||||
return implode(' ', $token);
|
||||
}
|
||||
}
|
|
@ -19,12 +19,9 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate instanceof checks of old legacy classnames.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstanceofSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_InstanceofSniff extends AbstractClassnameChecker
|
||||
{
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
|
@ -33,8 +30,6 @@ class Typo3Update_Sniffs_LegacyClassnames_InstanceofSniff extends AbstractClassn
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
return [
|
||||
T_INSTANCEOF,
|
||||
];
|
||||
return [T_INSTANCEOF];
|
||||
}
|
||||
}
|
|
@ -21,12 +21,9 @@
|
|||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate instantiations of old legacy classnames using "makeInstance".
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithMakeInstanceSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
|
||||
|
||||
|
@ -67,19 +64,6 @@ class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithMakeInstanceSniff ext
|
|||
|
||||
$classname = $tokens[$classnamePosition]['content'];
|
||||
$this->originalTokenContent = $tokens[$classnamePosition]['content'];
|
||||
$this->addFixableError($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* As token contains more then just class name, we have to build new content ourself.
|
||||
*
|
||||
* @param string $newClassname
|
||||
* @param string $originalClassname
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @return string
|
||||
*/
|
||||
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
|
||||
{
|
||||
return $this->getTokenReplacementForString($newClassname);
|
||||
$this->processFeatures($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
}
|
|
@ -19,12 +19,9 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate old legacy classnames instantiations using phps "new".
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithNewSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_InstantiationWithNewSniff extends AbstractClassnameChecker
|
||||
{
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
|
@ -21,12 +21,9 @@
|
|||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate old legacy classname instantiations using objectmanager create and get.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithObjectManagerSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
|
||||
|
||||
|
@ -80,20 +77,6 @@ class Typo3Update_Sniffs_LegacyClassnames_InstantiationWithObjectManagerSniff ex
|
|||
}
|
||||
|
||||
$classname = $tokens[$classnamePosition]['content'];
|
||||
$this->originalTokenContent = $tokens[$classnamePosition]['content'];
|
||||
$this->addFixableError($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* As token contains more then just class name, we have to build new content ourself.
|
||||
*
|
||||
* @param string $newClassname
|
||||
* @param string $originalClassname
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @return string
|
||||
*/
|
||||
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
|
||||
{
|
||||
return $this->getTokenReplacementForString($newClassname);
|
||||
$this->processFeatures($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
}
|
|
@ -20,12 +20,9 @@
|
|||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpcsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate instantiations of old legacy classnames using "makeInstance".
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_IsACallSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_IsACallSniff extends AbstractClassnameChecker
|
||||
{
|
||||
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
|
||||
|
||||
|
@ -69,20 +66,6 @@ class Typo3Update_Sniffs_LegacyClassnames_IsACallSniff extends AbstractClassname
|
|||
}
|
||||
|
||||
$classname = $tokens[$classnamePosition]['content'];
|
||||
$this->originalTokenContent = $tokens[$classnamePosition]['content'];
|
||||
$this->addFixableError($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* As token contains more then just class name, we have to build new content ourself.
|
||||
*
|
||||
* @param string $newClassname
|
||||
* @param string $originalClassname
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @return string
|
||||
*/
|
||||
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
|
||||
{
|
||||
return $this->getTokenReplacementForString($newClassname);
|
||||
$this->processFeatures($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
}
|
|
@ -20,15 +20,20 @@
|
|||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||
use Typo3Update\Feature\FeaturesSupport;
|
||||
|
||||
/**
|
||||
* Migrate PHP Doc comments.
|
||||
* Handle PHP Doc comments.
|
||||
*
|
||||
* E.g. annotations like @param or @return, see $allowedTags.
|
||||
*
|
||||
* Will do nothing itself, but call features.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_PhpDocCommentSniff implements PhpCsSniff
|
||||
{
|
||||
use FeaturesSupport;
|
||||
|
||||
/**
|
||||
* The configured tags will be processed.
|
||||
* @var array<string>
|
||||
|
@ -42,9 +47,7 @@ class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff extends AbstractClassn
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
return [
|
||||
T_DOC_COMMENT_TAG,
|
||||
];
|
||||
return [T_DOC_COMMENT_TAG];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,32 +71,8 @@ class Typo3Update_Sniffs_LegacyClassnames_DocCommentSniff extends AbstractClassn
|
|||
}
|
||||
$classnames = explode('|', explode(' ', $tokens[$classnamePosition]['content'])[0]);
|
||||
|
||||
$this->originalTokenContent = $tokens[$classnamePosition]['content'];
|
||||
foreach ($classnames as $classname) {
|
||||
$this->addFixableError($phpcsFile, $classnamePosition, $classname);
|
||||
$this->processFeatures($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* As token contains more then just class name, we have to build new content ourself.
|
||||
*
|
||||
* @param string $newClassname
|
||||
* @param string $originalClassname
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @return string
|
||||
*/
|
||||
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
|
||||
{
|
||||
$token = explode(' ', $this->originalTokenContent);
|
||||
|
||||
$classNames = explode('|', $token[0]);
|
||||
foreach ($classNames as $position => $classname) {
|
||||
if ($classname === $originalClassname) {
|
||||
$classNames[$position] = $newClassname;
|
||||
}
|
||||
}
|
||||
$token[0] = implode('|', $classNames);
|
||||
|
||||
return implode(' ', $token);
|
||||
}
|
||||
}
|
|
@ -19,12 +19,9 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate static calls to old legacy classnames.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_StaticCallSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_StaticCallSniff extends AbstractClassnameChecker
|
||||
{
|
||||
/**
|
||||
* Define whether the T_STRING default behaviour should be checked before
|
|
@ -19,12 +19,9 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Migrate Typehints in catch statements.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_TypehintCatchExceptionSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff extends AbstractClassnameChecker
|
||||
{
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
|
@ -20,12 +20,9 @@
|
|||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Migrate Typehints in function / method definitions.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_TypehintSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_TypeHintSniff extends AbstractClassnameChecker
|
||||
{
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
|
@ -58,7 +55,7 @@ class Typo3Update_Sniffs_LegacyClassnames_TypehintSniff extends AbstractClassnam
|
|||
if ($position === false) {
|
||||
continue;
|
||||
}
|
||||
$this->addFixableError($phpcsFile, $position, $parameter['type_hint']);
|
||||
$this->processFeatures($phpcsFile, $position, $parameter['type_hint']);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,14 +20,9 @@
|
|||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
|
||||
|
||||
/**
|
||||
* Detect and migrate use statements with legacy classnames..
|
||||
*
|
||||
* According to PSR-2, only one class per use statement is expected.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_Classname_UseSniff extends AbstractClassnameChecker
|
||||
{
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
|
@ -38,23 +33,4 @@ class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChec
|
|||
{
|
||||
return [T_USE];
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite to remove prefix.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $classnamePosition
|
||||
* @param string $classname
|
||||
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||
*/
|
||||
protected function replaceLegacyClassname(
|
||||
PhpCsFile $phpcsFile,
|
||||
$classnamePosition,
|
||||
$classname,
|
||||
$forceEmptyPrefix = true
|
||||
) {
|
||||
return parent::replaceLegacyClassname($phpcsFile, $classnamePosition, $classname, $forceEmptyPrefix);
|
||||
}
|
||||
}
|
|
@ -20,13 +20,14 @@
|
|||
*/
|
||||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\AbstractClassnameChecker;
|
||||
use Typo3Update\Sniffs\Options;
|
||||
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||
use Typo3Update\Feature\LegacyClassnameMapping;
|
||||
use Typo3Update\Options;
|
||||
|
||||
/**
|
||||
* Detect missing namespaces for class definitions.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends AbstractClassnameChecker
|
||||
class Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff implements PhpCsSniff
|
||||
{
|
||||
/**
|
||||
* Returns the token types that this sniff is interested in.
|
||||
|
@ -66,27 +67,16 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
|
|||
}
|
||||
|
||||
$classname = $tokens[$classnamePosition]['content'];
|
||||
$this->addFixableError($phpcsFile, $classnamePosition, $classname);
|
||||
$fix = $phpcsFile->addFixableError(
|
||||
'Legacy class definitions are not allowed; found "%s".'
|
||||
. ' Wrap your class inside a namespace.',
|
||||
$classnamePosition,
|
||||
'legacyClassname',
|
||||
[$classname]
|
||||
);
|
||||
if ($fix === true) {
|
||||
$this->replaceLegacyClassname($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite as we don't look up the classname, but check whether the style is legacy.
|
||||
*
|
||||
* @param string $classname
|
||||
* @return bool
|
||||
*/
|
||||
protected function isLegacyClassname($classname)
|
||||
{
|
||||
return strpos($classname, 'Tx_') === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $classname
|
||||
* @return string
|
||||
*/
|
||||
protected function getNewClassname($classname)
|
||||
{
|
||||
return substr($classname, strrpos($classname, '_') + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,18 +84,12 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
|
|||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $classnamePosition
|
||||
* @param string $classname
|
||||
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||
*/
|
||||
protected function replaceLegacyClassname(
|
||||
PhpCsFile $phpcsFile,
|
||||
$classnamePosition,
|
||||
$classname,
|
||||
$forceEmptyPrefix = true
|
||||
$classname
|
||||
) {
|
||||
parent::replaceLegacyClassname($phpcsFile, $classnamePosition, $classname, $forceEmptyPrefix);
|
||||
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
$lineEndings = PhpCsFile::detectLineEndings($phpcsFile->getFilename());
|
||||
$suffix = $lineEndings;
|
||||
|
@ -114,16 +98,29 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
|
|||
$suffix .= $lineEndings;
|
||||
}
|
||||
|
||||
$phpcsFile->fixer->replaceToken(
|
||||
$classnamePosition,
|
||||
substr($classname, strrpos($classname, '_') + 1)
|
||||
);
|
||||
$phpcsFile->fixer->replaceToken(
|
||||
$this->getNamespacePosition($phpcsFile),
|
||||
'<?php' . $lineEndings . $this->getNamespaceDefinition($classname) . $suffix
|
||||
);
|
||||
$this->addLegacyClassname(
|
||||
LegacyClassnameMapping::getInstance()->addLegacyClassname(
|
||||
$classname,
|
||||
$this->getNamespace($classname) . '\\' . $this->getNewClassname($classname)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $classname
|
||||
* @return string
|
||||
*/
|
||||
protected function getNewClassname($classname)
|
||||
{
|
||||
return substr($classname, strrpos($classname, '_') + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @return int|false
|
|
@ -22,12 +22,12 @@
|
|||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Typo3Update\Sniffs\Options;
|
||||
use Typo3Update\Options;
|
||||
|
||||
/**
|
||||
* Detect whether vendor is missing for plugins and modules registrations and configurations.
|
||||
*/
|
||||
class Typo3Update_Sniffs_LegacyClassnames_MissingVendorForPluginsAndModulesSniff implements PhpCsSniff
|
||||
class Typo3Update_Sniffs_LegacyClassname_MissingVendorForPluginsAndModulesSniff implements PhpCsSniff
|
||||
{
|
||||
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
|
||||
|
|
@ -1,279 +0,0 @@
|
|||
<?php
|
||||
namespace Typo3Update\Sniffs\LegacyClassnames;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use PHP_CodeSniffer as PhpCs;
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||
use Typo3Update\Sniffs\LegacyClassnames\Mapping;
|
||||
|
||||
/**
|
||||
* Provide common uses for all sniffs, regarding class name checks.
|
||||
*/
|
||||
abstract class AbstractClassnameChecker implements PhpCsSniff
|
||||
{
|
||||
/**
|
||||
* A list of extension names that might contain legacy class names.
|
||||
* Used to check clas names for warnings.
|
||||
*
|
||||
* Configure through ruleset.xml.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
public $legacyExtensions = ['Extbase', 'Fluid'];
|
||||
|
||||
/**
|
||||
* @var Mapping
|
||||
*/
|
||||
protected $legacyMapping;
|
||||
|
||||
/**
|
||||
* Used by some sniffs to keep original token for replacement.
|
||||
*
|
||||
* E.g. when Token itself is a whole inline comment, and we just want to replace the classname within.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $originalTokenContent = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->legacyMapping = Mapping::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define whether the T_STRING default behaviour should be checked before
|
||||
* or after the $stackPtr.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldLookBefore()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the tokens that this sniff is interested in.
|
||||
*
|
||||
* This is the default implementation, as most of the time next T_STRING is
|
||||
* the class name. This way only the register method has to be registered
|
||||
* in default cases.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile The file where the token was found.
|
||||
* @param int $stackPtr The position in the stack where
|
||||
* the token was found.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ElseExpression) This is for performance reason.
|
||||
*/
|
||||
public function process(PhpCsFile $phpcsFile, $stackPtr)
|
||||
{
|
||||
$tokens = $phpcsFile->getTokens();
|
||||
|
||||
if ($this->shouldLookBefore()) {
|
||||
$classnamePosition = $phpcsFile->findPrevious(T_STRING, $stackPtr);
|
||||
} else {
|
||||
$classnamePosition = $phpcsFile->findNext(T_STRING, $stackPtr);
|
||||
}
|
||||
|
||||
if ($classnamePosition === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$classname = $tokens[$classnamePosition]['content'];
|
||||
$this->addFixableError($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a mapping exists for the given $classname,
|
||||
* indicating it's legacy.
|
||||
*
|
||||
* @param string $classname
|
||||
* @return bool
|
||||
*/
|
||||
protected function isLegacyClassname($classname)
|
||||
{
|
||||
return $this->legacyMapping->isLegacyClassname($classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guesses whether the given classname is legacy. Will not check
|
||||
* isLegacyClassname
|
||||
*
|
||||
* @param string $classname
|
||||
* @return bool
|
||||
*/
|
||||
private function isMaybeLegacyClassname($classname)
|
||||
{
|
||||
if (strpos($classname, 'Tx_') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$extensionName = call_user_func(function ($classname) {
|
||||
$nameParts = explode('_', $classname);
|
||||
return $nameParts[1];
|
||||
}, $classname);
|
||||
|
||||
if (!in_array($extensionName, $this->legacyExtensions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $classname
|
||||
* @return string
|
||||
*/
|
||||
protected function getNewClassname($classname)
|
||||
{
|
||||
return $this->legacyMapping->getNewClassname($classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to add new mappings found during parsing.
|
||||
* E.g. in MissingNamespaceSniff old class definitions are fixed and a new mapping exists afterwards.
|
||||
*
|
||||
* @param string $legacyClassname
|
||||
* @param string $newClassname
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function addLegacyClassname($legacyClassname, $newClassname)
|
||||
{
|
||||
$this->legacyMapping->addLegacyClassname($legacyClassname, $newClassname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an fixable error if given $classname is legacy.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $classnamePosition
|
||||
* @param string $classname
|
||||
*/
|
||||
public function addFixableError(PhpCsFile $phpcsFile, $classnamePosition, $classname)
|
||||
{
|
||||
$classname = trim($classname, '\\\'"'); // Remove trailing slash, and quotes.
|
||||
$this->addMaybeWarning($phpcsFile, $classnamePosition, $classname);
|
||||
|
||||
if ($this->isLegacyClassname($classname) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$fix = $phpcsFile->addFixableError(
|
||||
'Legacy classes are not allowed; found "%s", use "%s" instead',
|
||||
$classnamePosition,
|
||||
'legacyClassname',
|
||||
[$classname, $this->getNewClassname($classname)]
|
||||
);
|
||||
|
||||
if ($fix === true) {
|
||||
$this->replaceLegacyClassname($phpcsFile, $classnamePosition, $classname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an warning if given $classname is maybe legacy.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $classnamePosition
|
||||
* @param string $classname
|
||||
*/
|
||||
private function addMaybeWarning(PhpCsFile $phpcsFile, $classnamePosition, $classname)
|
||||
{
|
||||
if ($this->isLegacyClassname($classname) || $this->isMaybeLegacyClassname($classname) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$phpcsFile->addWarning(
|
||||
'Legacy classes are not allowed; found %s that might be a legacy class that does not exist anymore',
|
||||
$classnamePosition,
|
||||
'mightBeLegacyClassname',
|
||||
[$classname]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the classname at $classnamePosition with $classname in $phpcsFile.
|
||||
*
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @param int $classnamePosition
|
||||
* @param string $classname
|
||||
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
|
||||
*/
|
||||
protected function replaceLegacyClassname(
|
||||
PhpCsFile $phpcsFile,
|
||||
$classnamePosition,
|
||||
$classname,
|
||||
$forceEmptyPrefix = false
|
||||
) {
|
||||
$prefix = '\\';
|
||||
if ($forceEmptyPrefix || $phpcsFile->getTokens()[$classnamePosition -1]['code'] === T_NS_SEPARATOR) {
|
||||
$prefix = '';
|
||||
}
|
||||
|
||||
$phpcsFile->fixer->replaceToken(
|
||||
$classnamePosition,
|
||||
$this->getTokenForReplacement($prefix . $this->getNewClassname($classname), $classname, $phpcsFile)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* String to use for replacing / fixing the token.
|
||||
* Default is class name itself, can be overwritten in sniff for special behaviour.
|
||||
*
|
||||
* @param string $newClassname
|
||||
* @param string $originalClassname
|
||||
* @param PhpCsFile $phpcsFile
|
||||
* @return string
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) We need to match the signature.
|
||||
*/
|
||||
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
|
||||
{
|
||||
return $newClassname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this inside your getTokenForReplacement if $classname is inside a string.
|
||||
* Strings will be converted to single quotes.
|
||||
*
|
||||
* @param string $classname
|
||||
* @return string
|
||||
*/
|
||||
protected function getTokenReplacementForString($classname)
|
||||
{
|
||||
$stringSign = $this->originalTokenContent[0];
|
||||
$token = explode($stringSign, $this->originalTokenContent);
|
||||
$token[1] = $classname;
|
||||
|
||||
// Migrate double quote to single quote.
|
||||
// This way no escaping of backslashes in class names is necessary.
|
||||
if ($stringSign === '"') {
|
||||
$stringSign = "'";
|
||||
}
|
||||
|
||||
return implode($stringSign, $token);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ use PHP_CodeSniffer_File as PhpCsFile;
|
|||
use PHP_CodeSniffer_Sniff as PhpCsSniff;
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Typo3Update\Sniffs\Options;
|
||||
use Typo3Update\Options;
|
||||
|
||||
/**
|
||||
* Contains common functionality for removed code like constants or functions.
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
|
||||
use Typo3Update\Sniffs\Options;
|
||||
use Typo3Update\Options;
|
||||
|
||||
/**
|
||||
* Sniff that handles all calls to removed constants.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use PHP_CodeSniffer_Tokens as Tokens;
|
||||
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
|
||||
use Typo3Update\Sniffs\Options;
|
||||
use Typo3Update\Options;
|
||||
|
||||
/**
|
||||
* Sniff that handles all calls to removed functions.
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
use Helmich\TypoScriptParser\Tokenizer\TokenInterface;
|
||||
use PHP_CodeSniffer_File as PhpCsFile;
|
||||
use Typo3Update\Sniffs\Options;
|
||||
use Typo3Update\Options;
|
||||
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,18 +2,14 @@
|
|||
<ruleset name="TYPO3 Update">
|
||||
<description>Provides sniffs and fixes for TYPO3 Updates.</description>
|
||||
|
||||
<rule ref="Typo3Update.LegacyClassnames.Instanceof">
|
||||
<rule ref="Typo3Update.Classname.Instanceof">
|
||||
<properties>
|
||||
<property name="legacyExtensions" type="array" value="Extbase,Fluid,Frontend,Core"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Typo3Update.LegacyClassnames.DocComment">
|
||||
<rule ref="Typo3Update.Classname.PhpDocComment">
|
||||
<properties>
|
||||
<property name="allowedTags" type="array" value="@param,@return,@var,@see,@throws"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<rule ref="Typo3Update.LegacyClassnames.MissingNamespace.legacyClassname">
|
||||
<message>Legacy class definitions are not allowed; found "%s". Wrap your class inside a namespace.</message>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InheritanceSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InheritanceSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -19,14 +19,14 @@
|
||||
* 02110-1301, USA.
|
|
@ -9,7 +9,7 @@
|
|||
"line": 22,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Inheritance.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 22,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Inheritance.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 22,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Core_BootstrapInterface\", use \"TYPO3\\CMS\\Extbase\\Core\\BootstrapInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Inheritance.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 27,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Inheritance.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
|||
"line": 28,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Inheritance.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -54,7 +54,7 @@
|
|||
"line": 29,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Core_BootstrapInterface\", use \"TYPO3\\CMS\\Extbase\\Core\\BootstrapInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Inheritance.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Inheritance.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InlineCommentSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InlineCommentSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -23,16 +23,16 @@
|
||||
{
|
|
@ -9,7 +9,7 @@
|
|||
"line": 26,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InlineComment.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 29,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InlineComment.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 32,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InlineComment.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 35,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InlineComment.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InlineComment.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstanceofSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstanceofSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -19,6 +19,6 @@
|
||||
* 02110-1301, USA.
|
|
@ -9,7 +9,7 @@
|
|||
"line": 22,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Instanceof.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Instanceof.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithMakeInstanceSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithMakeInstanceSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -19,6 +19,6 @@
|
||||
* 02110-1301, USA.
|
|
@ -9,7 +9,7 @@
|
|||
"line": 22,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithMakeInstance.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithMakeInstance.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithNewSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithNewSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -19,13 +19,13 @@
|
||||
* 02110-1301, USA.
|
|
@ -9,7 +9,7 @@
|
|||
"line": 22,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 23,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 24,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 27,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
|||
"line": 28,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -54,7 +54,7 @@
|
|||
"line": 29,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithNew.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithNew.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/InstantiationWithObjectManagerSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/InstantiationWithObjectManagerSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -21,13 +21,13 @@
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
"line": 24,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithObjectManager.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 25,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithObjectManager.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 31,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithObjectManager.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 33,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.InstantiationWithObjectManager.legacyClassname",
|
||||
"source": "Typo3Update.Classname.InstantiationWithObjectManager.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -0,0 +1,22 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/IsACallSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -23,15 +23,15 @@
|
||||
if (is_a($a, t3lib_Singleton::class)) {
|
||||
// do something
|
||||
}
|
||||
-if (is_a($a, 't3lib_Singleton')) {
|
||||
+if (is_a($a, '\TYPO3\CMS\Core\SingletonInterface')) {
|
||||
// do something
|
||||
}
|
||||
-if (is_a($a, '\t3lib_Singleton')) {
|
||||
+if (is_a($a, '\TYPO3\CMS\Core\SingletonInterface')) {
|
||||
// do something
|
||||
}
|
||||
-if (is_a($a, "t3lib_Singleton")) {
|
||||
+if (is_a($a, "\\TYPO3\\CMS\\Core\\SingletonInterface")) {
|
||||
// do something
|
||||
}
|
||||
-if (is_a($a, "\\t3lib_Singleton")) {
|
||||
+if (is_a($a, "\\TYPO3\\CMS\\Core\\SingletonInterface")) {
|
||||
// do something
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"files": {
|
||||
"InputFileForIssues.php": {
|
||||
"errors": 4,
|
||||
"messages": [
|
||||
{
|
||||
"column": 14,
|
||||
"fixable": true,
|
||||
"line": 26,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.Classname.IsACall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
"column": 14,
|
||||
"fixable": true,
|
||||
"line": 29,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.Classname.IsACall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
"column": 14,
|
||||
"fixable": true,
|
||||
"line": 32,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.Classname.IsACall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
"column": 14,
|
||||
"fixable": true,
|
||||
"line": 35,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.Classname.IsACall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
||||
"warnings": 0
|
||||
}
|
||||
},
|
||||
"totals": {
|
||||
"errors": 4,
|
||||
"fixable": 4,
|
||||
"warnings": 0
|
||||
}
|
||||
}
|
|
@ -29,3 +29,9 @@ if (is_a($a, 't3lib_Singleton')) {
|
|||
if (is_a($a, '\t3lib_Singleton')) {
|
||||
// do something
|
||||
}
|
||||
if (is_a($a, "t3lib_Singleton")) {
|
||||
// do something
|
||||
}
|
||||
if (is_a($a, "\\t3lib_Singleton")) {
|
||||
// do something
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/DocCommentSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/PhpDocCommentSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -22,19 +22,19 @@
|
||||
class InputFileForIssues
|
|
@ -9,7 +9,7 @@
|
|||
"line": 25,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Repository_CategoryRepository\", use \"TYPO3\\CMS\\Extbase\\Domain\\Repository\\CategoryRepository\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname",
|
||||
"source": "Typo3Update.Classname.PhpDocComment.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 31,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname",
|
||||
"source": "Typo3Update.Classname.PhpDocComment.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 33,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Configuration_Configurationmanager\", use \"TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname",
|
||||
"source": "Typo3Update.Classname.PhpDocComment.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 37,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.DocComment.legacyClassname",
|
||||
"source": "Typo3Update.Classname.PhpDocComment.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/StaticCallSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/StaticCallSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -19,13 +19,13 @@
|
||||
* 02110-1301, USA.
|
|
@ -9,7 +9,7 @@
|
|||
"line": 22,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Utility_Extension\", use \"TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname",
|
||||
"source": "Typo3Update.Classname.StaticCall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 27,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_div\", use \"TYPO3\\CMS\\Core\\Utility\\GeneralUtility\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname",
|
||||
"source": "Typo3Update.Classname.StaticCall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 27,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname",
|
||||
"source": "Typo3Update.Classname.StaticCall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 28,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname",
|
||||
"source": "Typo3Update.Classname.StaticCall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
|||
"line": 30,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Command_HelpCommandController\", use \"TYPO3\\CMS\\Extbase\\Command\\HelpCommandController\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname",
|
||||
"source": "Typo3Update.Classname.StaticCall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -54,7 +54,7 @@
|
|||
"line": 31,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.StaticCall.legacyClassname",
|
||||
"source": "Typo3Update.Classname.StaticCall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintCatchExceptionSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintCatchExceptionSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -21,13 +21,13 @@
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
"line": 24,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Exception\", use \"TYPO3\\CMS\\Extbase\\Exception\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.TypeHintCatchException.legacyClassname",
|
||||
"source": "Typo3Update.Classname.TypeHintCatchException.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 30,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Exception\", use \"TYPO3\\CMS\\Extbase\\Exception\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.TypeHintCatchException.legacyClassname",
|
||||
"source": "Typo3Update.Classname.TypeHintCatchException.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/TypeHintSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/TypeHintSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -25,10 +25,10 @@
|
||||
function something(\TYPO3\CMS\Extbase\Domain\Model\BackendUser $user)
|
|
@ -9,7 +9,7 @@
|
|||
"line": 28,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname",
|
||||
"source": "Typo3Update.Classname.TypeHint.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 31,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname",
|
||||
"source": "Typo3Update.Classname.TypeHint.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 43,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname",
|
||||
"source": "Typo3Update.Classname.TypeHint.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 46,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname",
|
||||
"source": "Typo3Update.Classname.TypeHint.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
|||
"line": 56,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname",
|
||||
"source": "Typo3Update.Classname.TypeHint.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -54,7 +54,7 @@
|
|||
"line": 59,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.TypeHint.legacyClassname",
|
||||
"source": "Typo3Update.Classname.TypeHint.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/UseSniff/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/Classname/UseSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -19,8 +19,8 @@
|
||||
* 02110-1301, USA.
|
|
@ -9,7 +9,7 @@
|
|||
"line": 22,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Use.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Use.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 23,
|
||||
"message": "Legacy classes are not allowed; found \"Tx_Extbase_Domain_Model_Backenduser\", use \"TYPO3\\CMS\\Extbase\\Domain\\Model\\BackendUser\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.Use.legacyClassname",
|
||||
"source": "Typo3Update.Classname.Use.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/customVendor/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/customVendor/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
|
@ -9,7 +9,7 @@
|
|||
"line": 24,
|
||||
"message": "Legacy class definitions are not allowed; found \"Tx_ExtName_Controller_Frontendcontroller\". Wrap your class inside a namespace.",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingNamespace.legacyClassname",
|
||||
"source": "Typo3Update.LegacyClassname.MissingNamespace.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingNamespaceSniff/defaultVendor/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingNamespaceSniff/defaultVendor/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
|
@ -9,7 +9,7 @@
|
|||
"line": 24,
|
||||
"message": "Legacy class definitions are not allowed; found \"Tx_ExtName_Controller_Frontendcontroller\". Wrap your class inside a namespace.",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingNamespace.legacyClassname",
|
||||
"source": "Typo3Update.LegacyClassname.MissingNamespace.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/customVendor/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
|
@ -9,7 +9,7 @@
|
|||
"line": 23,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 31,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 39,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 45,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
|||
"line": 51,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -54,7 +54,7 @@
|
|||
"line": 61,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"MyCustomVendor.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,4 +1,4 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php
|
||||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassname/MissingVendorForPluginsAndModulesSniff/defaultVendor/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
|
@ -9,7 +9,7 @@
|
|||
"line": 23,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
|||
"line": 31,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -27,7 +27,7 @@
|
|||
"line": 39,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
"line": 45,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
|||
"line": 51,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
|
@ -54,7 +54,7 @@
|
|||
"line": 61,
|
||||
"message": "No vendor is given, that will break TYPO3 handling for namespaced classes. Add vendor before Extensionkey like: \"YourCompany.\" . $_EXTKEY",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"source": "Typo3Update.LegacyClassname.MissingVendorForPluginsAndModules.missingVendor",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
|
@ -1,14 +0,0 @@
|
|||
--- tests/Fixtures/Standards/Typo3Update/Sniffs/LegacyClassnames/IsACallSniff/InputFileForIssues.php
|
||||
+++ PHP_CodeSniffer
|
||||
@@ -23,9 +23,9 @@
|
||||
if (is_a($a, t3lib_Singleton::class)) {
|
||||
// do something
|
||||
}
|
||||
-if (is_a($a, 't3lib_Singleton')) {
|
||||
+if (is_a($a, '\TYPO3\CMS\Core\SingletonInterface')) {
|
||||
// do something
|
||||
}
|
||||
-if (is_a($a, '\t3lib_Singleton')) {
|
||||
+if (is_a($a, '\TYPO3\CMS\Core\SingletonInterface')) {
|
||||
// do something
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
"files": {
|
||||
"InputFileForIssues.php": {
|
||||
"errors": 2,
|
||||
"messages": [
|
||||
{
|
||||
"column": 14,
|
||||
"fixable": true,
|
||||
"line": 26,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.IsACall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
},
|
||||
{
|
||||
"column": 14,
|
||||
"fixable": true,
|
||||
"line": 29,
|
||||
"message": "Legacy classes are not allowed; found \"t3lib_Singleton\", use \"TYPO3\\CMS\\Core\\SingletonInterface\" instead",
|
||||
"severity": 5,
|
||||
"source": "Typo3Update.LegacyClassnames.IsACall.legacyClassname",
|
||||
"type": "ERROR"
|
||||
}
|
||||
],
|
||||
"warnings": 0
|
||||
}
|
||||
},
|
||||
"totals": {
|
||||
"errors": 2,
|
||||
"fixable": 2,
|
||||
"warnings": 0
|
||||
}
|
||||
}
|
|
@ -140,8 +140,7 @@ class SniffsTest extends TestCase
|
|||
$this->getExpectedJsonOutput($folder),
|
||||
$this->getOutput($internalArguments)['output'],
|
||||
'Checking Sniff "' . $this->getSniffByFolder($folder) . '"'
|
||||
. ' did not produce expected output for input file '
|
||||
. $internalArguments['inputFile']
|
||||
. ' did not produce expected output,'
|
||||
. ' called: ' . $this->getPhpcsCall($internalArguments)
|
||||
);
|
||||
|
||||
|
@ -151,8 +150,7 @@ class SniffsTest extends TestCase
|
|||
$this->getExpectedDiffOutput($folder),
|
||||
$this->getOutput($internalArguments)['output'],
|
||||
'Fixing Sniff "' . $this->getSniffByFolder($folder) . '"'
|
||||
. ' did not produce expected diff for input file '
|
||||
. $internalArguments['inputFile']
|
||||
. ' did not produce expected diff,'
|
||||
. ' called: ' . $this->getPhpcsCall($internalArguments)
|
||||
);
|
||||
} catch (FileNotFoundException $e) {
|
||||
|
|
Loading…
Reference in a new issue