From 4e0c2802e40f546ff56f4b491b703f2fa3297358 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 23 Mar 2017 09:32:12 +0100 Subject: [PATCH 1/2] FEATURE: Make path to mapping file configurable * This way one can define the path in his own ruleset.xml --- Readme.rst | 16 ++++++++++++++++ .../LegacyClassnames/ClassnameCheckerTrait.php | 7 ++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Readme.rst b/Readme.rst index 86f6a6e..6dce9d2 100644 --- a/Readme.rst +++ b/Readme.rst @@ -136,3 +136,19 @@ Typo3Update.LegacyClassnames.DocComment: ``allowedTags`` + +``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 + + + +Example: + +.. code:: bash + + --runtime-set mappingFile /projects/typo3_installation/vendor/composer/autoload_classaliasmap.php diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/ClassnameCheckerTrait.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/ClassnameCheckerTrait.php index 4297ae7..ff29014 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/ClassnameCheckerTrait.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/ClassnameCheckerTrait.php @@ -20,6 +20,7 @@ namespace Typo3Update\Sniffs\LegacyClassnames; * 02110-1301, USA. */ +use PHP_CodeSniffer as PhpCs; use PHP_CodeSniffer_File as PhpCsFile; /** @@ -46,8 +47,12 @@ trait ClassnameCheckerTrait /** * @param string $mappingFile File containing php array for mapping. */ - private function initialize($mappingFile = __DIR__ . '/../../../../../LegacyClassnames.php') + private function initialize() { + $mappingFile = PhpCs::getConfigData('mappingFile'); + if (!$mappingFile) { + $mappingFile = __DIR__ . '/../../../../../LegacyClassnames.php'; + } if ($this->legacyClassnames !== []) { return; } From 1b610844b9f71a8d59d68c45d58f5011a1ed3f63 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 23 Mar 2017 10:18:01 +0100 Subject: [PATCH 2/2] BUGFIX: PHPDoc --- .../Sniffs/LegacyClassnames/ClassnameCheckerTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/ClassnameCheckerTrait.php b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/ClassnameCheckerTrait.php index ff29014..a59f8de 100644 --- a/src/Standards/Typo3Update/Sniffs/LegacyClassnames/ClassnameCheckerTrait.php +++ b/src/Standards/Typo3Update/Sniffs/LegacyClassnames/ClassnameCheckerTrait.php @@ -45,7 +45,7 @@ trait ClassnameCheckerTrait public $legacyExtensions = ['Extbase', 'Fluid']; /** - * @param string $mappingFile File containing php array for mapping. + * Initialize, used internally, to not initialize if not needed inside __construct. */ private function initialize() {