Merge branch 'develop' into 'feature/41-check-removed-classes'

# Conflicts:
#   Documentation/source/features.rst
This commit is contained in:
Daniel Hürtgen 2017-05-02 22:06:02 +02:00
commit 475e38e3fc
7 changed files with 52 additions and 16 deletions

View file

@ -0,0 +1,6 @@
* Write some info about what has been done.
* Also don't forget to mention why this has been done, e.g. introduced new
feature?
Resolves: #IssueNumber

View file

@ -310,3 +310,29 @@ Two examples::
new HRULER: new HRULER:
replacement: 'Any installation should migrate to alternatives such as F...' replacement: 'Any installation should migrate to alternatives such as F...'
docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog...' docsUrl: 'https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog...'
Features
^^^^^^^^
Configures which Features should be attached to x Sniffs, where Key is the FQCN of the feature and
the values are FQCN of the sniffs.
Works only if the sniff respects execution of features.
One example::
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

View file

@ -15,7 +15,7 @@ Possible configurations for all sniffs:
Implemented sniffs: Implemented sniffs:
- PHPDocuments, like Includes and annotations for IDEs. - PHPDocComments, like Includes and annotations for IDEs.
Possible extra configurations: Possible extra configurations:
@ -106,6 +106,15 @@ functions. For configuration options see :ref:`configuration-removedConstantConf
Check for usage of *removed PHP classes*. The classes are configured in same way as removed Check for usage of *removed PHP classes*. The classes are configured in same way as removed
functions. For configuration options see :ref:`configuration-removedClassConfigFiles`. functions. For configuration options see :ref:`configuration-removedClassConfigFiles`.
Check for usage of *removed TypoScript*. The TypoScript objects are configured in same way as
removed functions. For configuration options see :ref:`configuration-removedTypoScriptConfigFiles`.
This will check whether you are using already removed TypoScript parts, supported are:
- Objects, e.g. ``CLEARGIF``, ``FORM``
- Paths like ``styles.insertContent``
For a complete list, take a look at the corresponding YAML-Files.
Further checks Further checks
-------------- --------------

View file

@ -29,7 +29,7 @@ use Typo3Update\RemovedByYamlConfiguration;
abstract class AbstractYamlRemovedUsage abstract class AbstractYamlRemovedUsage
{ {
/** /**
* @var array * @var RemovedByYamlConfiguration
*/ */
protected $configured; protected $configured;
@ -65,19 +65,19 @@ abstract class AbstractYamlRemovedUsage
/** /**
* @param PhpCsFile $phpcsFile * @param PhpCsFile $phpcsFile
* @param int $stackPtr * @param int $stackPtr
* @param array $removed * @param array $config
*/ */
protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $removed) protected function addWarning(PhpCsFile $phpcsFile, $stackPtr, array $config)
{ {
$phpcsFile->addWarning( $phpcsFile->addWarning(
'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s', 'Calls to removed code are not allowed; found %s. Removed in %s. %s. See: %s',
$stackPtr, $stackPtr,
$removed['identifier'], $config['identifier'],
[ [
$removed['oldUsage'], $config['oldUsage'],
$removed['versionRemoved'], $config['versionRemoved'],
$this->getReplacement($removed), $this->getReplacement($config),
$removed['docsUrl'], $config['docsUrl'],
] ]
); );
} }

View file

@ -28,11 +28,6 @@ use PHP_CodeSniffer_Sniff as PhpCsSniff;
*/ */
interface FeatureInterface interface FeatureInterface
{ {
/**
* @var PhpCsSniff $sniff
*/
public function __construct(PhpCsSniff $sniff);
/** /**
* Process like a PHPCS Sniff. * Process like a PHPCS Sniff.
* *

View file

@ -27,7 +27,7 @@ class RemovedClassFeature extends AbstractYamlRemovedUsage
{ {
public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname) public function process(PhpCsFile $phpcsFile, $classnamePosition, $classname)
{ {
if (! $this->configured->isRemoved($classname)) { if ($this->configured->isRemoved($classname) === false) {
return; return;
} }
$this->addWarning( $this->addWarning(

View file

@ -33,7 +33,7 @@ class RemovedByYamlConfiguration
/** /**
* @param array $configFiles * @param array $configFiles
* @param Callable $prepareStructure * @param \Callable $prepareStructure
*/ */
public function __construct(array $configFiles, $prepareStructure) public function __construct(array $configFiles, $prepareStructure)
{ {