Merge branch 'feature/45-removed-signals' into 'develop'

FEATURE: Removed signals and hooks

Closes #45

See merge request !86
This commit is contained in:
Daniel Hürtgen 2017-05-16 14:34:04 +02:00
commit 7c6fe7e83c
17 changed files with 557 additions and 0 deletions

View file

@ -143,6 +143,52 @@ Using ``runtime-set``:
--runtime-set removedFunctionConfigFiles "/Some/Absolute/Path/*.yaml" --runtime-set removedFunctionConfigFiles "/Some/Absolute/Path/*.yaml"
.. _configuration-removedSignalConfigFiles:
removedSignalConfigFiles
^^^^^^^^^^^^^^^^^^^^^^^^^^
Configure where to look for configuration files defining the removed signals. Default
is ``Configuration/Removed/Signals/*.yaml`` inside the standard itself. We already try to deliver
as much as possible.
Globing is used, so placeholders like ``*`` are possible, see
https://secure.php.net/manual/en/function.glob.php
Using :file:`ruleset.xml`:
.. code:: xml
<config name="removedSignalConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
Using ``runtime-set``:
.. code:: bash
--runtime-set removedSignalConfigFiles "/Some/Absolute/Path/*.yaml"
.. _configuration-removedHookConfigFiles:
removedHookConfigFiles
^^^^^^^^^^^^^^^^^^^^^^^^^^
Configure where to look for configuration files defining the removed hooks. Default
is ``Configuration/Removed/Hooks/*.yaml`` inside the standard itself. We already try to deliver
as much as possible.
Globing is used, so placeholders like ``*`` are possible, see
https://secure.php.net/manual/en/function.glob.php
Using :file:`ruleset.xml`:
.. code:: xml
<config name="removedHookConfigFiles" value="/Some/Absolute/Path/*.yaml"/>
Using ``runtime-set``:
.. code:: bash
--runtime-set removedHookConfigFiles "/Some/Absolute/Path/*.yaml"
.. _configuration-removedConstantConfigFiles: .. _configuration-removedConstantConfigFiles:
removedConstantConfigFiles removedConstantConfigFiles

View file

@ -106,6 +106,12 @@ 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 signals*. The signals are configured in same way as removed
functions. For configuration options see :ref:`configuration-removedSignalConfigFiles`.
Check for usage of *removed hooks*. The hooks are configured in same way as removed
functions. For configuration options see :ref:`configuration-removedHookConfigFiles`.
Check for usage of *removed TypoScript*. The TypoScript objects are configured in same way as Check for usage of *removed TypoScript*. The TypoScript objects are configured in same way as
removed functions. For configuration options see :ref:`configuration-removedTypoScriptConfigFiles`. removed functions. For configuration options see :ref:`configuration-removedTypoScriptConfigFiles`.
This will check whether you are using already removed TypoScript parts, supported are: This will check whether you are using already removed TypoScript parts, supported are:

View file

@ -0,0 +1,11 @@
# Breaking changes in 7.3: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Index.html#breaking-changes
'7.3':
typo3/index.php->loginScriptHook:
replacement: 'Use the new backend login form API'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66669-BackendLoginControllerRefactored.html
typo3/index.php->loginFormHook:
replacement: 'Use the new backend login form API'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66669-BackendLoginControllerRefactored.html
t3lib/class.t3lib_tceforms.php->getSingleFieldClass:
replacement: null
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-63846-FormEngineRefactoring.html

View file

@ -0,0 +1,5 @@
# Breaking changes in 7.5: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Index.html#breaking-changes
'7.5':
t3lib/class.t3lib_tceforms.php->getMainFieldsClass:
replacement: 'Use FormDataProvider to change data given to the render engine of FormEngine from now on'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.5/Breaking-69568-FormEngine.html

View file

@ -0,0 +1,17 @@
# Breaking changes in 7.2: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Index.html#breaking-changes
'7.2':
\TYPO3\CMS\Backend\Controller\LoginController::makeLoginBoxImage:
replacement: 'Use the introduced Fluid view to adapt the login screen to your demands'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html
\TYPO3\CMS\Backend\Controller\LoginController::wrapLoginForm:
replacement: 'Use the introduced Fluid view to adapt the login screen to your demands'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html
\TYPO3\CMS\Backend\Controller\LoginController::makeLoginNews:
replacement: 'Use the introduced Fluid view to adapt the login screen to your demands'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html
\TYPO3\CMS\Backend\Controller\LoginController::makeLoginForm:
replacement: 'Use the introduced Fluid view to adapt the login screen to your demands'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html
\TYPO3\CMS\Backend\Controller\LoginController::makeLogoutForm:
replacement: 'Use the introduced Fluid view to adapt the login screen to your demands'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html

View file

@ -0,0 +1,5 @@
# Breaking changes in 7.3: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Index.html#breaking-changes
'7.3':
\TYPO3\CMS\Lang\Service\UpdateTranslationService::postProcessMirrorUrl:
replacement: 'Change the slot to use the \TYPO3\CMS\Lang\Service\TranslationService::postProcessMirrorUrl signal'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-62983-PostProcessMirrorUrlSignalHasMoved.html

View file

@ -0,0 +1,5 @@
# Breaking changes in 7.4: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Index.html#breaking-changes
'7.4':
\TYPO3\CMS\Core\Resource\ResourceStorage::preFileAdd:
replacement: 'The signal will now receive an empty string in $sourceFilePath'
docsUrl: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.4/Breaking-67545-PreFileAddSignalBehaviourChanged.html

View file

@ -69,6 +69,32 @@ class Options
); );
} }
/**
* Returns an array of absolute file names containing removed function configurations.
*
* @return array<string>
*/
public static function getRemovedSignalConfigFiles()
{
return static::getOptionFileNames(
'removedSignalConfigFiles',
__DIR__ . '/Configuration/Removed/Signals/*.yaml'
);
}
/**
* Returns an array of absolute file names containing removed function configurations.
*
* @return array<string>
*/
public static function getRemovedHookConfigFiles()
{
return static::getOptionFileNames(
'removedHookConfigFiles',
__DIR__ . '/Configuration/Removed/Hooks/*.yaml'
);
}
/** /**
* Returns an array of absolute file names containing removed constant configurations. * Returns an array of absolute file names containing removed constant configurations.
* *

View file

@ -66,4 +66,35 @@ trait ExtendedPhpCsSupportTrait
return true; return true;
} }
/**
* Returns all parameters for function call as values.
* Quotes are removed from strings.
*
* @param PhpCsFile $phpcsFile
* @param int $stackPtr
*
* @return array<string>
*/
protected function getFunctionCallParameters(PhpCsFile $phpcsFile, $stackPtr)
{
$start = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr) + 1;
$parameters = explode(',', $phpcsFile->getTokensAsString(
$start,
$phpcsFile->findNext(T_CLOSE_PARENTHESIS, $stackPtr) - $start
));
return array_map([$this, 'getStringContent'], $parameters);
}
/**
* Remove special chars like quotes from string.
*
* @param string $string
* @return string
*/
public function getStringContent($string)
{
return trim($string, " \t\n\r\0\x0B'\"");
}
} }

View file

@ -0,0 +1,69 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use PHP_CodeSniffer_Tokens as PhpCsTokens;
use Typo3Update\Options;
use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage;
class Typo3Update_Sniffs_Removed_GenericHookSniff extends AbstractGenericPhpUsage
{
use ExtendedPhpCsSupportTrait;
public function register()
{
return PhpCsTokens::$stringTokens;
}
protected function getRemovedConfigFiles()
{
return Options::getRemovedHookConfigFiles();
}
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$firstPart = $this->getStringContent($tokens[$stackPtr]['content']);
$secondPart = $this->getStringContent($tokens[$phpcsFile->findNext(PhpCsTokens::$stringTokens, $stackPtr + 1)]['content']);
$lookup = $firstPart . '->' . $secondPart;
if ($this->configured->isRemoved($lookup) === false) {
return [];
}
return [$this->configured->getRemoved($lookup)];
}
protected function getIdentifier(array $config)
{
$search = ['/', '.'];
$replace = ['-'];
return str_replace($search, $replace, $config['fqcn']) . $config['name'];
}
protected function getOldUsage(array $config)
{
return '["' . $config['fqcn'] . '"]["' . $config['name'] . '"] = ...';
}
}

View file

@ -0,0 +1,86 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use PHP_CodeSniffer_File as PhpCsFile;
use Typo3Update\Options;
use Typo3Update\Sniffs\ExtendedPhpCsSupportTrait;
use Typo3Update\Sniffs\Removed\AbstractGenericPhpUsage;
class Typo3Update_Sniffs_Removed_GenericSignalSniff extends AbstractGenericPhpUsage
{
use ExtendedPhpCsSupportTrait;
protected function getRemovedConfigFiles()
{
return Options::getRemovedSignalConfigFiles();
}
protected function findRemoved(PhpCsFile $phpcsFile, $stackPtr)
{
if (!$this->isFunctionCall($phpcsFile, $stackPtr) || $phpcsFile->getTokens()[$stackPtr]['content'] !== 'connect') {
return [];
}
$parameters = $this->getFunctionCallParameters($phpcsFile, $stackPtr);
if (count($parameters) < 4) {
return [];
}
$lookup = $this->getClass($parameters[0]) . '::' . $parameters[1];
if ($this->configured->isRemoved($lookup) === false) {
return [];
}
return [$this->configured->getRemoved($lookup)];
}
/**
* Returns same formatted class representation for incoming strings.
*
* @param string $string
* @return string
*/
protected function getClass($string)
{
$search = [
'::class',
'\\\\',
];
$replace = [
'',
'\\',
];
$string = str_replace($search, $replace, $string);
if ($string[0] !== '\\') {
$string = '\\' . $string;
}
return $string;
}
protected function getOldUsage(array $config)
{
return $config['fqcn'] . '::' . $config['name'];
}
}

View file

@ -0,0 +1,42 @@
{
"files": {
"InputFileForIssues.php": {
"errors": 0,
"messages": [
{
"column": 43,
"fixable": false,
"line": 22,
"message": "Calls to removed code are not allowed; found [\"typo3/index.php\"][\"loginScriptHook\"] = .... Removed in 7.3. Use the new backend login form API. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66669-BackendLoginControllerRefactored.html",
"severity": 5,
"source": "Typo3Update.Removed.GenericHook.typo3-indexphploginScriptHook",
"type": "WARNING"
},
{
"column": 43,
"fixable": false,
"line": 23,
"message": "Calls to removed code are not allowed; found [\"typo3/index.php\"][\"loginFormHook\"] = .... Removed in 7.3. Use the new backend login form API. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66669-BackendLoginControllerRefactored.html",
"severity": 5,
"source": "Typo3Update.Removed.GenericHook.typo3-indexphploginFormHook",
"type": "WARNING"
},
{
"column": 9,
"fixable": false,
"line": 28,
"message": "Calls to removed code are not allowed; found [\"typo3/index.php\"][\"loginFormHook\"] = .... Removed in 7.3. Use the new backend login form API. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.3/Breaking-66669-BackendLoginControllerRefactored.html",
"severity": 5,
"source": "Typo3Update.Removed.GenericHook.typo3-indexphploginFormHook",
"type": "WARNING"
}
],
"warnings": 3
}
},
"totals": {
"errors": 0,
"fixable": 0,
"warnings": 3
}
}

View file

@ -0,0 +1,33 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'] = 'Configuration';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']["typo3/index.php"]["loginFormHook"] = 'Configuration';
array_merge(
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'],
[
'typo3/index.php' => [
'loginFormHook' => 'Configuration',
],
]
);

View file

@ -0,0 +1,60 @@
{
"files": {
"InputFileForIssues.php": {
"errors": 0,
"messages": [
{
"column": 28,
"fixable": false,
"line": 25,
"message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Backend\\Controller\\LoginController::makeLoginNews. Removed in 7.2. Use the introduced Fluid view to adapt the login screen to your demands. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html",
"severity": 5,
"source": "Typo3Update.Removed.GenericSignal.LoginController.makeLoginNews",
"type": "WARNING"
},
{
"column": 28,
"fixable": false,
"line": 32,
"message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Backend\\Controller\\LoginController::makeLoginNews. Removed in 7.2. Use the introduced Fluid view to adapt the login screen to your demands. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html",
"severity": 5,
"source": "Typo3Update.Removed.GenericSignal.LoginController.makeLoginNews",
"type": "WARNING"
},
{
"column": 28,
"fixable": false,
"line": 39,
"message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Backend\\Controller\\LoginController::makeLoginNews. Removed in 7.2. Use the introduced Fluid view to adapt the login screen to your demands. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html",
"severity": 5,
"source": "Typo3Update.Removed.GenericSignal.LoginController.makeLoginNews",
"type": "WARNING"
},
{
"column": 28,
"fixable": false,
"line": 46,
"message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Backend\\Controller\\LoginController::makeLoginNews. Removed in 7.2. Use the introduced Fluid view to adapt the login screen to your demands. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html",
"severity": 5,
"source": "Typo3Update.Removed.GenericSignal.LoginController.makeLoginNews",
"type": "WARNING"
},
{
"column": 28,
"fixable": false,
"line": 53,
"message": "Calls to removed code are not allowed; found \\TYPO3\\CMS\\Backend\\Controller\\LoginController::makeLoginNews. Removed in 7.2. Use the introduced Fluid view to adapt the login screen to your demands. See: https://docs.typo3.org/typo3cms/extensions/core/7.6/Changelog/7.2/Breaking-65939-BackendLoginRefactoring.html",
"severity": 5,
"source": "Typo3Update.Removed.GenericSignal.LoginController.makeLoginNews",
"type": "WARNING"
}
],
"warnings": 5
}
},
"totals": {
"errors": 0,
"fixable": 0,
"warnings": 5
}
}

View file

@ -0,0 +1,59 @@
<?php
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
call_user_func(function () {
$signalSlotDispatcher = GeneralUtility::makeInstance(Dispatcher::class);
$signalSlotDispatcher->connect(
\TYPO3\CMS\Backend\Controller\LoginController::class,
'makeLoginNews',
'OwnClass',
'ownMethod'
);
$signalSlotDispatcher->connect(
TYPO3\CMS\Backend\Controller\LoginController::class,
'makeLoginNews',
'OwnClass',
'ownMethod'
);
$signalSlotDispatcher->connect(
'\TYPO3\CMS\Backend\Controller\LoginController',
'makeLoginNews',
'OwnClass',
'ownMethod'
);
$signalSlotDispatcher->connect(
'TYPO3\CMS\Backend\Controller\LoginController',
'makeLoginNews',
'OwnClass',
'ownMethod'
);
$signalSlotDispatcher->connect(
"TYPO3\\CMS\\Backend\\Controller\\LoginController",
'makeLoginNews',
'OwnClass',
'ownMethod'
);
});

View file

@ -0,0 +1,28 @@
<?php
namespace Typo3Update\Tests\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use Typo3Update\Tests\SniffsTest;
class GenericHookSniffTest extends SniffsTest
{
}

View file

@ -0,0 +1,28 @@
<?php
namespace Typo3Update\Tests\Sniffs\Removed;
/*
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use Typo3Update\Tests\SniffsTest;
class GenericSignalSniffTest extends SniffsTest
{
}