FEATURE: Make path to mapping file configurable

* This way one can define the path in his own ruleset.xml
This commit is contained in:
Daniel Siepmann 2017-03-23 09:32:12 +01:00
parent 5a70f8458c
commit 4e0c2802e4
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 22 additions and 1 deletions

View file

@ -136,3 +136,19 @@ Typo3Update.LegacyClassnames.DocComment: ``allowedTags``
<property name="allowedTags" type="array" value="@param,@return,@var,@see,@throws"/> <property name="allowedTags" type="array" value="@param,@return,@var,@see,@throws"/>
</properties> </properties>
</rule> </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

View file

@ -20,6 +20,7 @@ namespace Typo3Update\Sniffs\LegacyClassnames;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use PHP_CodeSniffer as PhpCs;
use PHP_CodeSniffer_File as PhpCsFile; use PHP_CodeSniffer_File as PhpCsFile;
/** /**
@ -46,8 +47,12 @@ trait ClassnameCheckerTrait
/** /**
* @param string $mappingFile File containing php array for mapping. * @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 !== []) { if ($this->legacyClassnames !== []) {
return; return;
} }