Commit 1eb4702e authored by Thomas Löffler's avatar Thomas Löffler Committed by Oliver Wand

Introduce test build and fix CGL issues

parent ab28aa4c
...@@ -17,7 +17,7 @@ stages: ...@@ -17,7 +17,7 @@ stages:
- layout - layout
- deploy - deploy
test: test:unit:
stage: test stage: test
image: php:7.0-alpine image: php:7.0-alpine
variables: variables:
...@@ -34,6 +34,15 @@ test: ...@@ -34,6 +34,15 @@ test:
script: script:
- ./composer.phar test:unit - ./composer.phar test:unit
test:php:
stage: test
image: ekreative/php-cs-fixer:2
variables:
GIT_STRATEGY: "clone"
script:
- php-cs-fixer fix --dry-run --config=.gitlab-ci/build/.php_cs --diff
except:
- assets
build: build:
stage: build stage: build
......
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* This file represents the configuration for Code Sniffing PSR-2-related
* automatic checks of coding guidelines
* Install @fabpot's great php-cs-fixer tool via
*
* $ composer global require friendsofphp/php-cs-fixer
*
* And then simply run
*
* $ php-cs-fixer fix --config ../Build/.php_cs
*
* inside the TYPO3 directory. Warning: This may take up to 10 minutes.
*
* For more information read:
* https://www.php-fig.org/psr/psr-2/
* https://cs.sensiolabs.org
*/
if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}
// Define in which folders to search and which folders to exclude
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->exclude('typo3temp')
->in(__DIR__ . '/../../');
// Return a Code Sniffing configuration using
// all sniffers needed for PSR-2
// and additionally:
// - Remove leading slashes in use clauses.
// - PHP single-line arrays should not have trailing comma.
// - Single-line whitespace before closing semicolon are prohibited.
// - Remove unused use statements in the PHP source code
// - Ensure Concatenation to have at least one whitespace around
// - Remove trailing whitespace at the end of blank lines.
return PhpCsFixer\Config::create()->setRiskyAllowed(true)->setRules([
'@PSR2' => true,
'@DoctrineAnnotation' => true,
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
'concat_space' => ['spacing' => 'one'],
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'single_quote' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'no_blank_lines_after_phpdoc' => true,
'array_syntax' => ['syntax' => 'short'],
'whitespace_after_comma_in_array' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'no_alias_functions' => true,
'lowercase_cast' => true,
'no_leading_namespace_whitespace' => true,
'native_function_casing' => true,
'no_short_bool_cast' => true,
'no_unneeded_control_parentheses' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_trim' => true,
'no_superfluous_elseif' => true,
'no_useless_else' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'cast_spaces' => ['space' => 'none'],
'declare_equal_normalize' => ['space' => 'single'],
'dir_constant' => true,
])->setFinder($finder);
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*';
$GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'normal'; $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'normal';
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] = 'db'; $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] = 'db';
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*'; $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*';
$GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'normal'; $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'normal';
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] = 'yourdbname'; $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] = 'yourdbname';
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ',tx_realurl_pathsegment'; $GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ',tx_realurl_pathsegment';
if (!function_exists('encodeTitleUserProc')) { if (!function_exists('encodeTitleUserProc')) {
function encodeTitleUserProc($params) { function encodeTitleUserProc($params)
{
return $params['pObj']->getUtility()->convertToSafeString($params['title'], $params['encodingConfiguration']['spaceCharacter']); return $params['pObj']->getUtility()->convertToSafeString($params['title'], $params['encodingConfiguration']['spaceCharacter']);
} }
} }
......
...@@ -62,8 +62,6 @@ class ExtConf implements SingletonInterface ...@@ -62,8 +62,6 @@ class ExtConf implements SingletonInterface
* Sets the repositoryDir * Sets the repositoryDir
* *
* @param string $repositoryDir * @param string $repositoryDir
*
* @return void
*/ */
public function setRepositoryDir(string $repositoryDir) public function setRepositoryDir(string $repositoryDir)
{ {
......
...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception; ...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
class Exception extends \Exception { class Exception extends \Exception
{
} }
...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception; ...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
class FailedDependencyException extends Exception { class FailedDependencyException extends Exception
{
} }
...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception; ...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
class InternalServerErrorException extends Exception { class InternalServerErrorException extends Exception
{
} }
...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception; ...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
class NotFoundException extends Exception { class NotFoundException extends Exception
{
} }
...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception; ...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
class UnauthorizedException extends Exception { class UnauthorizedException extends Exception
{
} }
...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception; ...@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
class VersionExistsException extends Exception { class VersionExistsException extends Exception
{
} }
...@@ -25,7 +25,7 @@ class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task ...@@ -25,7 +25,7 @@ class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task
/** /**
* Public method, usually called by scheduler * Public method, usually called by scheduler
* *
* @return boolean TRUE on success * @return bool TRUE on success
*/ */
public function execute() public function execute()
{ {
...@@ -37,7 +37,7 @@ class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task ...@@ -37,7 +37,7 @@ class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task
} }
/** /**
* @return boolean * @return bool
*/ */
protected function fetchCurrentCoreData() protected function fetchCurrentCoreData()
{ {
...@@ -52,7 +52,7 @@ class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task ...@@ -52,7 +52,7 @@ class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task
} }
/** /**
* @return boolean * @return bool
*/ */
protected function fetchCurrentDocumentationData() protected function fetchCurrentDocumentationData()
{ {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
$extensionKey = 'ter'; $extensionKey = 'ter';
return [ return [
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
$extensionKey = 'ter'; $extensionKey = 'ter';
return [ return [
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
$extensionKey = 'ter'; $extensionKey = 'ter';
return [ return [
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
$extensionKey = 'ter'; $extensionKey = 'ter';
return [ return [
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
$extensionKey = 'ter'; $extensionKey = 'ter';
return [ return [
......
...@@ -17,9 +17,8 @@ ...@@ -17,9 +17,8 @@
* *
* @author Robert Lemke <robert@typo3.org> * @author Robert Lemke <robert@typo3.org>
*/ */
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.php'); require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.php');
...@@ -27,8 +26,6 @@ require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.p ...@@ -27,8 +26,6 @@ require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.p
* TYPO3 Extension Repository, SOAP Server * TYPO3 Extension Repository, SOAP Server
* *
* @author Robert Lemke <robert@typo3.org> * @author Robert Lemke <robert@typo3.org>
* @package TYPO3
* @subpackage tx_ter_soapserver
*/ */
class tx_ter_api class tx_ter_api
{ {
...@@ -55,7 +52,7 @@ class tx_ter_api ...@@ -55,7 +52,7 @@ class tx_ter_api
/** /**
* 30MB Maximum upload size for extensions * 30MB Maximum upload size for extensions
* *
* @var integer * @var int
*/ */
protected $extensionMaxUploadSize = 31457280; protected $extensionMaxUploadSize = 31457280;
...@@ -107,7 +104,6 @@ class tx_ter_api ...@@ -107,7 +104,6 @@ class tx_ter_api
return $this->helperObj->checkValidUser($accountData); return $this->helperObj->checkValidUser($accountData);
} }
/** /**
* Method for uploading an extension to the repository * Method for uploading an extension to the repository
* *
...@@ -207,7 +203,6 @@ class tx_ter_api ...@@ -207,7 +203,6 @@ class tx_ter_api
* has to be static because uploadExtensionWithoutSoap() is static * has to be static because uploadExtensionWithoutSoap() is static
* *
* @param $extensionInfoData * @param $extensionInfoData
* @return void
* @deprecated The method used to notifiy via Tx_Amqp_Service_ProducerService, which is no longer available * @deprecated The method used to notifiy via Tx_Amqp_Service_ProducerService, which is no longer available
*/ */
protected static function notifyExtensionVersionUpload($extensionInfoData) protected static function notifyExtensionVersionUpload($extensionInfoData)
...@@ -221,7 +216,7 @@ class tx_ter_api ...@@ -221,7 +216,7 @@ class tx_ter_api
* @param object $extensionInfoData The general extension information * @param object $extensionInfoData The general extension information
* @param array $filesData The array of file data objects * @param array $filesData The array of file data objects
* *
* @return boolean TRUE on success * @return bool TRUE on success
* *
* @throws \T3o\Ter\Exception\Exception * @throws \T3o\Ter\Exception\Exception
* @throws \T3o\Ter\Exception\NotFoundException * @throws \T3o\Ter\Exception\NotFoundException
...@@ -719,12 +714,6 @@ class tx_ter_api ...@@ -719,12 +714,6 @@ class tx_ter_api
return $result; return $result;
} }
/********************************************************* /*********************************************************
* *
* uploadExtension helper functions * uploadExtension helper functions
...@@ -745,7 +734,6 @@ class tx_ter_api ...@@ -745,7 +734,6 @@ class tx_ter_api
* @param object $extensionInfoData : The general extension information as received by the SOAP server * @param object $extensionInfoData : The general extension information as received by the SOAP server
* @param object $filesData : The array of file data objects as received by the SOAP server * @param object $filesData : The array of file data objects as received by the SOAP server
* *
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException * @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\NotFoundException * @throws \T3o\Ter\Exception\NotFoundException
* @access protected * @access protected
...@@ -898,7 +886,6 @@ class tx_ter_api ...@@ -898,7 +886,6 @@ class tx_ter_api
* @param object $extensionInfoData : The general extension information as received by the SOAP server * @param object $extensionInfoData : The general extension information as received by the SOAP server
* @param array $filesData : The array of file data objects as received by the SOAP server * @param array $filesData : The array of file data objects as received by the SOAP server
* *
* @return void
* @access public * @access public
*/ */
public function uploadExtension_writeExtensionInfoToDB($accountData, $extensionInfoData, $filesData) public function uploadExtension_writeExtensionInfoToDB($accountData, $extensionInfoData, $filesData)
...@@ -1038,10 +1025,6 @@ class tx_ter_api ...@@ -1038,10 +1025,6 @@ class tx_ter_api
$this->updateOrInsertRecord($table, $extensionQueue); $this->updateOrInsertRecord($table, $extensionQueue);
} }
/********************************************************* /*********************************************************
* *
* deleteExtension helper functions * deleteExtension helper functions
...@@ -1055,7 +1038,6 @@ class tx_ter_api ...@@ -1055,7 +1038,6 @@ class tx_ter_api
* @param string $extensionKey : The extension key * @param string $extensionKey : The extension key
* @param string $version : Version number of the extension to delete * @param string $version : Version number of the extension to delete
* *
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException * @throws \T3o\Ter\Exception\InternalServerErrorException
* @access protected * @access protected
*/ */
...@@ -1121,7 +1103,7 @@ class tx_ter_api ...@@ -1121,7 +1103,7 @@ class tx_ter_api
$secondLetter = strtolower(substr($extensionKey, 1, 1)); $secondLetter = strtolower(substr($extensionKey, 1, 1));
$fullPath = $this->parentObj->repositoryDir . $firstLetter . '/' . $secondLetter . '/'; $fullPath = $this->parentObj->repositoryDir . $firstLetter . '/' . $secondLetter . '/';
list ($majorVersion, $minorVersion, $devVersion) = GeneralUtility::intExplode('.', $version); list($majorVersion, $minorVersion, $devVersion) = GeneralUtility::intExplode('.', $version);
$fullPath .= strtolower($extensionKey) . '_' . $majorVersion . '.' . $minorVersion . '.' . $devVersion; $fullPath .= strtolower($extensionKey) . '_' . $majorVersion . '.' . $minorVersion . '.' . $devVersion;
$filesToDelete = [ $filesToDelete = [
...@@ -1138,13 +1120,12 @@ class tx_ter_api ...@@ -1138,13 +1120,12 @@ class tx_ter_api
} }
} }
/** /**
* Checks if the version of the uploaded extension already exists in repository * Checks if the version of the uploaded extension already exists in repository
* *
* @param $extensionInfoData * @param $extensionInfoData
* *
* @return integer|boolean * @return int|bool
*/ */
protected function checkUploadedExtensionVersionExistsInRepository($extensionInfoData) protected function checkUploadedExtensionVersionExistsInRepository($extensionInfoData)
{ {
...@@ -1165,7 +1146,7 @@ class tx_ter_api ...@@ -1165,7 +1146,7 @@ class tx_ter_api
* *
* @param object $extensionInfoData Extension information as received from the SOAP interface * @param object $extensionInfoData Extension information as received from the SOAP interface
* *
* @return bool|integer True if success, error code in case of failure * @return bool|int True if success, error code in case of failure
*/ */
protected static function checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData) protected static function checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData)
{ {
...@@ -1273,8 +1254,6 @@ class tx_ter_api ...@@ -1273,8 +1254,6 @@ class tx_ter_api
return $result; return $result;
} }
/********************************************************* /*********************************************************
* *
* checkExtensionKey helper functions * checkExtensionKey helper functions
...@@ -1286,7 +1265,7 @@ class tx_ter_api ...@@ -1286,7 +1265,7 @@ class tx_ter_api
* *
* @param string $extensionKey : The extension key to check * @param string $extensionKey : The extension key to check
* *
* @return boolean TRUE if the extension key is valid * @return bool TRUE if the extension key is valid
* @access protected * @access protected
*/ */
protected function checkExtensionKey_extensionKeyIsFormallyValid($extensionKey) protected function checkExtensionKey_extensionKeyIsFormallyValid($extensionKey)
...@@ -1299,7 +1278,7 @@ class tx_ter_api ...@@ -1299,7 +1278,7 @@ class tx_ter_api
} }
// check for forbidden start and end characters // check for forbidden start and end characters
if (preg_match('/^[0-9_]/', $extensionKey) || preg_match("/[_]$/", $extensionKey)) { if (preg_match('/^[0-9_]/', $extensionKey) || preg_match('/[_]$/', $extensionKey)) {
$validKey = false; $validKey = false;
} }
...@@ -1321,10 +1300,6 @@ class tx_ter_api ...@@ -1321,10 +1300,6 @@ class tx_ter_api
return $validKey; return $validKey;
} }
/********************************************************* /*********************************************************
* *
* registerExtensionKey helper functions * registerExtensionKey helper functions
...@@ -1337,7 +1312,6 @@ class tx_ter_api ...@@ -1337,7 +1312,6 @@ class tx_ter_api
* @param object $accountData : A valid username and password * @param object $accountData : A valid username and password
* @param object $extensionKeyData : The extension key and other information * @param object $extensionKeyData : The extension key and other information
* *
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException * @throws \T3o\Ter\Exception\InternalServerErrorException
* @access protected * @access protected
*/ */
...@@ -1362,10 +1336,6 @@ class tx_ter_api ...@@ -1362,10 +1336,6 @@ class tx_ter_api
} }
} }
/********************************************************* /*********************************************************
* *
* modifyExtensionKey helper functions * modifyExtensionKey helper functions
...@@ -1378,7 +1348,7 @@ class tx_ter_api ...@@ -1378,7 +1348,7 @@ class tx_ter_api
* @param object $accountData : A valid username and password * @param object $accountData : A valid username and password
* @param object $modifyExtensionKeyData : The extension key field which shall be updated * @param object $modifyExtensionKeyData : The extension key field which shall be updated
* *
* @return integer the result TER result code * @return int the result TER result code
* @throws \T3o\Ter\Exception\InternalServerErrorException * @throws \T3o\Ter\Exception\InternalServerErrorException
* @access protected * @access protected
*/ */
...@@ -1418,10 +1388,6 @@ class tx_ter_api ...@@ -1418,10 +1388,6 @@ class tx_ter_api
return TX_TER_RESULT_GENERAL_OK; return TX_TER_RESULT_GENERAL_OK;
} }
/********************************************************* /*********************************************************
* *
* setReviewState helper functions * setReviewState helper functions
...@@ -1433,7 +1399,6 @@ class tx_ter_api ...@@ -1433,7 +1399,6 @@ class tx_ter_api
* *
* @param object $setReviewStateData : Extension key, version number and the new state * @param object $setReviewStateData : Extension key, version number and the new state
* *
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException * @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\NotFoundException * @throws \T3o\Ter\Exception\NotFoundException
* @access protected * @access protected
...@@ -1477,10 +1442,6 @@ class tx_ter_api ...@@ -1477,10 +1442,6 @@ class tx_ter_api
} }
} }
/********************************************************* /*********************************************************
* *
* increaseExtensionDownloadCounter helper functions * increaseExtensionDownloadCounter helper functions
...@@ -1493,7 +1454,6 @@ class tx_ter_api ...@@ -1493,7 +1454,6 @@ class tx_ter_api