Merge remote-tracking branch 'origin/develop' into feature/36-namespace-migration

* Make mapping file path configurable

Relates: #36, #37
This commit is contained in:
Daniel Siepmann 2017-03-23 13:34:12 +01:00
commit 5a8260815c
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
4 changed files with 33 additions and 4 deletions

View file

@ -176,3 +176,19 @@ Example:
.. code:: bash
--runtime-set vendor YourVendor
``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.
*/
use PHP_CodeSniffer as PhpCs;
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use Typo3Update\Sniffs\LegacyClassnames\Mapping;

View file

@ -50,8 +50,7 @@ class Mapping
}
private function __construct()
{
// $mappingFile = $this->getMappingFile();
$mappingFile = __DIR__ . '/../../../../../LegacyClassnames.php';
$mappingFile = $this->getMappingFile();
$this->mappings = require $mappingFile;
}
@ -113,8 +112,7 @@ class Mapping
return;
}
// $mappingFile = $this->getMappingFile();
$mappingFile = __DIR__ . '/../../../../../LegacyClassnames.php';
$mappingFile = $this->getMappingFile();
file_put_contents(
$mappingFile,

View file

@ -40,4 +40,18 @@ trait OptionsAccessTrait
}
return trim($vendor, '\\/');
}
/**
* Returns the configured file path containing the mappings for classes, interfaced and traits.
*
* @return string
*/
public function getMappingFile()
{
$mappingFile = PhpCs::getConfigData('mappingFile');
if (!$mappingFile) {
$mappingFile = __DIR__ . '/../../../../LegacyClassnames.php';
}
return $mappingFile;
}
}