TASK: Update PHP CS

* Use hash, not version, as version contains bug that not a single
  custom sniff can be executed. That would break our tests.
* Also add auto loading for tests to work, as phpcs removed autoloading
  support for composer.
* Move all sniffs to namespace to allow processing through phpcs.
* Adjust already some class names of phpcs to new conventions.

Relates: #82
This commit is contained in:
Daniel Siepmann 2017-05-30 14:47:46 +02:00
parent 0c91d7b22c
commit ded389aeca
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
35 changed files with 115 additions and 94 deletions

View file

@ -11,7 +11,8 @@
],
"autoload-dev": {
"psr-4": {
"Typo3Update\\Tests\\": "tests/"
"Typo3Update\\Tests\\": "tests/",
"PHP_CodeSniffer\\": "vendor/squizlabs/php_codesniffer/src/"
}
},
"autoload": {
@ -26,9 +27,8 @@
"require": {
"php": ">=5.6",
"helmich/typo3-typoscript-parser": "1.1.*",
"squizlabs/php_codesniffer": "2.8.*",
"symfony/yaml": "3.2.*",
"higidi/composer-phpcodesniffer-standards-plugin": "*"
"squizlabs/php_codesniffer": "dev-master#92a902f",
"symfony/yaml": "3.2.*"
},
"require-dev": {
"phpunit/phpunit": "5.7.*",

View file

@ -20,7 +20,7 @@ namespace Typo3Update;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use Typo3Update\RemovedByYamlConfiguration;
/**

View file

@ -20,7 +20,7 @@ namespace Typo3Update\Feature;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage;
abstract class AbstractYamlRemovedUsage extends BaseAbstractYamlRemovedUsage implements FeatureInterface

View file

@ -20,8 +20,8 @@ namespace Typo3Update\Feature;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
/**
* See "Features" in documentation.

View file

@ -20,7 +20,7 @@ namespace Typo3Update\Feature;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use Typo3Update\Options;
/**

View file

@ -20,7 +20,7 @@ namespace Typo3Update\Feature;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer\Files\File as PhpCsFile;
/**
* Provides "feature" support for sniffs.

View file

@ -20,9 +20,9 @@ namespace Typo3Update\Feature;
* 02110-1301, USA.
*/
use PHP_CodeSniffer as PhpCs;
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer\Util\Common as PhpCs;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use Typo3Update_Sniffs_Classname_StringSniff as StringSniff;
/**

View file

@ -20,7 +20,7 @@ namespace Typo3Update\Feature;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use Typo3Update\Options;
class RemovedClassFeature extends AbstractYamlRemovedUsage

View file

@ -20,7 +20,7 @@ namespace Typo3Update;
* 02110-1301, USA.
*/
use PHP_CodeSniffer as PhpCs;
use PHP_CodeSniffer\Config as Config;
use Symfony\Component\Yaml\Yaml;
/**
@ -157,7 +157,7 @@ class Options
*/
private static function getOptionWithDefault($optionName, $default)
{
$option = PhpCs::getConfigData($optionName);
$option = Config::getConfigData($optionName);
if (!$option) {
$option = $default;
}

View file

@ -20,8 +20,8 @@ namespace Typo3Update\Sniffs\Classname;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use Typo3Update\Feature\FeaturesSupport;
/**

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,10 +21,9 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
use PHP_CodeSniffer\Files\File as PhpCsFile;
class Typo3Update_Sniffs_Classname_InheritanceSniff extends AbstractClassnameChecker
class InheritanceSniff extends AbstractClassnameChecker
{
/**
* Returns the token types that this sniff is interested in.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,10 +21,9 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
use PHP_CodeSniffer\Files\File as PhpCsFile;
class Typo3Update_Sniffs_Classname_InlineCommentSniff extends AbstractClassnameChecker
class InlineCommentSniff extends AbstractClassnameChecker
{
/**
* Returns the token types that this sniff is interested in.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,9 +21,7 @@
* 02110-1301, USA.
*/
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
class Typo3Update_Sniffs_Classname_InstanceofSniff extends AbstractClassnameChecker
class InstanceofSniff extends AbstractClassnameChecker
{
/**
* Returns the token types that this sniff is interested in.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,11 +21,10 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Tokens as Tokens;
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Util\Tokens as Tokens;
class Typo3Update_Sniffs_Classname_InstantiationWithMakeInstanceSniff extends AbstractClassnameChecker
class InstantiationWithMakeInstanceSniff extends AbstractClassnameChecker
{
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,9 +21,7 @@
* 02110-1301, USA.
*/
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
class Typo3Update_Sniffs_Classname_InstantiationWithNewSniff extends AbstractClassnameChecker
class InstantiationWithNewSniff extends AbstractClassnameChecker
{
/**
* Returns the token types that this sniff is interested in.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,11 +21,10 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Tokens as Tokens;
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Util\Tokens as Tokens;
class Typo3Update_Sniffs_Classname_InstantiationWithObjectManagerSniff extends AbstractClassnameChecker
class InstantiationWithObjectManagerSniff extends AbstractClassnameChecker
{
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,10 +21,9 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpcsFile;
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
use PHP_CodeSniffer\Files\File as PhpcsFile;
class Typo3Update_Sniffs_Classname_IsACallSniff extends AbstractClassnameChecker
class IsACallSniff extends AbstractClassnameChecker
{
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,8 +21,8 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use Typo3Update\Feature\FeaturesSupport;
/**
@ -30,7 +32,7 @@ use Typo3Update\Feature\FeaturesSupport;
*
* Will do nothing itself, but call features.
*/
class Typo3Update_Sniffs_Classname_PhpDocCommentSniff implements PhpCsSniff
class PhpDocCommentSniff implements PhpCsSniff
{
use FeaturesSupport;

View file

@ -1,5 +1,6 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,9 +20,7 @@
* 02110-1301, USA.
*/
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
class Typo3Update_Sniffs_Classname_StaticCallSniff extends AbstractClassnameChecker
class StaticCallSniff extends AbstractClassnameChecker
{
/**
* Define whether the T_STRING default behaviour should be checked before

View file

@ -19,9 +19,9 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer_Tokens as PhpCsTokens;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use PHP_CodeSniffer\Util\Tokens as PhpCsTokens;
use Typo3Update\Feature\FeaturesSupport;
class Typo3Update_Sniffs_Classname_StringSniff implements PhpCsSniff

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,9 +21,7 @@
* 02110-1301, USA.
*/
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
class Typo3Update_Sniffs_Classname_TypeHintCatchExceptionSniff extends AbstractClassnameChecker
class TypeHintCatchExceptionSniff extends AbstractClassnameChecker
{
/**
* Returns the token types that this sniff is interested in.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,10 +21,9 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
use PHP_CodeSniffer\Files\File as PhpCsFile;
class Typo3Update_Sniffs_Classname_TypeHintSniff extends AbstractClassnameChecker
class TypeHintSniff extends AbstractClassnameChecker
{
/**
* Returns the token types that this sniff is interested in.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Classname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,10 +21,9 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Sniffs\Classname\AbstractClassnameChecker;
use PHP_CodeSniffer\Files\File as PhpCsFile;
class Typo3Update_Sniffs_Classname_UseSniff extends AbstractClassnameChecker
class UseSniff extends AbstractClassnameChecker
{
/**
* Returns the token types that this sniff is interested in.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Deprecated;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,16 +21,16 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer_Tokens as PhpCsTokens;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use PHP_CodeSniffer\Util\Tokens as PhpCsTokens;
/**
* Analyses feature 6991.
*
* @see https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.6/Feature-69916-PSR-7-basedRoutingForBackendAJAXRequests.html
*/
class Typo3Update_Sniffs_Deprecated_AjaxRegistrationSniff implements PhpCsSniff
class AjaxRegistrationSniff implements PhpCsSniff
{
/**
* Defines files to check.
@ -88,7 +90,7 @@ class Typo3Update_Sniffs_Deprecated_AjaxRegistrationSniff implements PhpCsSniff
. ' Since TYPO3 7.6, use PSR-7-based Routing for Backend AJAX Requests.'
. ' See: %s',
$tokenToCheck,
'',
'6991',
[
"\$GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX'][\$ajaxID]",
$token['content'],

View file

@ -20,8 +20,8 @@ namespace Typo3Update\Sniffs;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpcsFile;
use PHP_CodeSniffer_Tokens as Tokens;
use PHP_CodeSniffer\Files\File as PhpcsFile;
use PHP_CodeSniffer\Util\Tokens as Tokens;
/**
* Provide common uses for all sniffs.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\LegacyClassname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,15 +21,15 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use Typo3Update\Feature\LegacyClassnameMapping;
use Typo3Update\Options;
/**
* Detect missing namespaces for class definitions.
*/
class Typo3Update_Sniffs_LegacyClassname_MissingNamespaceSniff implements PhpCsSniff
class MissingNamespaceSniff implements PhpCsSniff
{
/**
* Returns the token types that this sniff is interested in.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\LegacyClassname;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,15 +21,15 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer_Tokens as Tokens;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use PHP_CodeSniffer\Util\Tokens as Tokens;
use Typo3Update\Options;
/**
* Detect whether vendor is missing for plugins and modules registrations and configurations.
*/
class Typo3Update_Sniffs_LegacyClassname_MissingVendorForPluginsAndModulesSniff implements PhpCsSniff
class MissingVendorForPluginsAndModulesSniff implements PhpCsSniff
{
use \Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;

View file

@ -20,7 +20,7 @@ namespace Typo3Update\Sniffs\Removed;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer\Files\File as PhpCsFile;
abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
{
@ -142,7 +142,7 @@ abstract class AbstractGenericPhpUsage extends AbstractGenericUsage
{
$name = $config['name'];
if ($config['class']) {
$name = $config['class'] . '.' . $name;
$name = $config['class'] . ':' . $name;
}
return $name;

View file

@ -20,8 +20,8 @@ namespace Typo3Update\Sniffs\Removed;
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Sniff as PhpCsSniff;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Sniffs\Sniff as PhpCsSniff;
use Typo3Update\AbstractYamlRemovedUsage as BaseAbstractYamlRemovedUsage;
abstract class AbstractGenericUsage extends BaseAbstractYamlRemovedUsage implements PhpCsSniff

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -22,7 +24,7 @@
use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage;
use Typo3Update\Options;
class Typo3Update_Sniffs_Removed_GenericConstantUsageSniff extends AbstractGenericPhpUsage
class GenericConstantUsageSniff extends AbstractGenericPhpUsage
{
protected function getOldUsage(array $config)
{

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,12 +21,11 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use Typo3Update\Options;
use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage;
class Typo3Update_Sniffs_Removed_GenericFunctionCallSniff extends AbstractGenericPhpUsage
class GenericFunctionCallSniff extends AbstractGenericPhpUsage
{
use ExtendedPhpCsSupportTrait;

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,13 +21,12 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Tokens as PhpCsTokens;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use PHP_CodeSniffer\Util\Tokens as PhpCsTokens;
use Typo3Update\Options;
use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage;
class Typo3Update_Sniffs_Removed_GenericHookSniff extends AbstractGenericPhpUsage
class GenericHookSniff extends AbstractGenericPhpUsage
{
use ExtendedPhpCsSupportTrait;

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -19,12 +21,11 @@
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use Typo3Update\Options;
use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage;
class Typo3Update_Sniffs_Removed_GenericSignalSniff extends AbstractGenericPhpUsage
class GenericSignalSniff extends AbstractGenericPhpUsage
{
use ExtendedPhpCsSupportTrait;

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -20,11 +22,10 @@
*/
use Helmich\TypoScriptParser\Tokenizer\TokenInterface;
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use Typo3Update\Options;
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
class Typo3Update_Sniffs_Removed_TypoScriptConstantSniff extends AbstractGenericUsage
class TypoScriptConstantSniff extends AbstractGenericUsage
{
/**
* Register sniff only for TypoScript.

View file

@ -1,5 +1,7 @@
<?php
namespace Typo3Update\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
@ -20,12 +22,11 @@
*/
use Helmich\TypoScriptParser\Tokenizer\TokenInterface;
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer\Files\File as PhpCsFile;
use Typo3Update\CodeSniffer\Tokenizers\FQObjectIdentifier;
use Typo3Update\Options;
use Typo3Update\Sniffs\Removed\AbstractGenericUsage;
class Typo3Update_Sniffs_Removed_TypoScriptSniff extends AbstractGenericUsage
class TypoScriptSniff extends AbstractGenericUsage
{
/**
* Register sniff only for TypoScript.