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:
- layout
- deploy
test:
test:unit:
stage: test
image: php:7.0-alpine
variables:
......@@ -34,6 +34,15 @@ test:
script:
- ./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:
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 @@
*
* The TYPO3 project - inspiring people to share!
*/
$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*';
$GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'normal';
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] = 'db';
......
......@@ -11,7 +11,6 @@
*
* The TYPO3 project - inspiring people to share!
*/
$GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*';
$GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'] = 'normal';
$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['dbname'] = 'yourdbname';
......
......@@ -3,7 +3,8 @@
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ',tx_realurl_pathsegment';
if (!function_exists('encodeTitleUserProc')) {
function encodeTitleUserProc($params) {
function encodeTitleUserProc($params)
{
return $params['pObj']->getUtility()->convertToSafeString($params['title'], $params['encodingConfiguration']['spaceCharacter']);
}
}
......
......@@ -62,8 +62,6 @@ class ExtConf implements SingletonInterface
* Sets the repositoryDir
*
* @param string $repositoryDir
*
* @return void
*/
public function setRepositoryDir(string $repositoryDir)
{
......
......@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share!
*/
class Exception extends \Exception {
class Exception extends \Exception
{
}
......@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share!
*/
class FailedDependencyException extends Exception {
class FailedDependencyException extends Exception
{
}
......@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share!
*/
class InternalServerErrorException extends Exception {
class InternalServerErrorException extends Exception
{
}
......@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share!
*/
class NotFoundException extends Exception {
class NotFoundException extends Exception
{
}
......@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* The TYPO3 project - inspiring people to share!
*/
class UnauthorizedException extends Exception {
class UnauthorizedException extends Exception
{
}
......@@ -15,6 +15,6 @@ namespace T3o\Ter\Exception;
* 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
/**
* Public method, usually called by scheduler
*
* @return boolean TRUE on success
* @return bool TRUE on success
*/
public function execute()
{
......@@ -37,7 +37,7 @@ class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task
}
/**
* @return boolean
* @return bool
*/
protected function fetchCurrentCoreData()
{
......@@ -52,7 +52,7 @@ class UpdateCurrentVersionListTask extends \TYPO3\CMS\Extbase\Scheduler\Task
}
/**
* @return boolean
* @return bool
*/
protected function fetchCurrentDocumentationData()
{
......
......@@ -11,7 +11,6 @@
*
* The TYPO3 project - inspiring people to share!
*/
$extensionKey = 'ter';
return [
......
......@@ -11,7 +11,6 @@
*
* The TYPO3 project - inspiring people to share!
*/
$extensionKey = 'ter';
return [
......
......@@ -11,7 +11,6 @@
*
* The TYPO3 project - inspiring people to share!
*/
$extensionKey = 'ter';
return [
......
......@@ -11,7 +11,6 @@
*
* The TYPO3 project - inspiring people to share!
*/
$extensionKey = 'ter';
return [
......
......@@ -11,7 +11,6 @@
*
* The TYPO3 project - inspiring people to share!
*/
$extensionKey = 'ter';
return [
......
......@@ -17,9 +17,8 @@
*
* @author Robert Lemke <robert@typo3.org>
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.php');
......@@ -27,8 +26,6 @@ require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_helper.p
* TYPO3 Extension Repository, SOAP Server
*
* @author Robert Lemke <robert@typo3.org>
* @package TYPO3
* @subpackage tx_ter_soapserver
*/
class tx_ter_api
{
......@@ -55,7 +52,7 @@ class tx_ter_api
/**
* 30MB Maximum upload size for extensions
*
* @var integer
* @var int
*/
protected $extensionMaxUploadSize = 31457280;
......@@ -107,7 +104,6 @@ class tx_ter_api
return $this->helperObj->checkValidUser($accountData);
}
/**
* Method for uploading an extension to the repository
*
......@@ -207,7 +203,6 @@ class tx_ter_api
* has to be static because uploadExtensionWithoutSoap() is static
*
* @param $extensionInfoData
* @return void
* @deprecated The method used to notifiy via Tx_Amqp_Service_ProducerService, which is no longer available
*/
protected static function notifyExtensionVersionUpload($extensionInfoData)
......@@ -221,7 +216,7 @@ class tx_ter_api
* @param object $extensionInfoData The general extension information
* @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\NotFoundException
......@@ -719,12 +714,6 @@ class tx_ter_api
return $result;
}
/*********************************************************
*
* uploadExtension helper functions
......@@ -745,7 +734,6 @@ class tx_ter_api
* @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
*
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\NotFoundException
* @access protected
......@@ -898,7 +886,6 @@ class tx_ter_api
* @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
*
* @return void
* @access public
*/
public function uploadExtension_writeExtensionInfoToDB($accountData, $extensionInfoData, $filesData)
......@@ -1038,10 +1025,6 @@ class tx_ter_api
$this->updateOrInsertRecord($table, $extensionQueue);
}
/*********************************************************
*
* deleteExtension helper functions
......@@ -1055,7 +1038,6 @@ class tx_ter_api
* @param string $extensionKey : The extension key
* @param string $version : Version number of the extension to delete
*
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @access protected
*/
......@@ -1121,7 +1103,7 @@ class tx_ter_api
$secondLetter = strtolower(substr($extensionKey, 1, 1));
$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;
$filesToDelete = [
......@@ -1138,13 +1120,12 @@ class tx_ter_api
}
}
/**
* Checks if the version of the uploaded extension already exists in repository
*
* @param $extensionInfoData
*
* @return integer|boolean
* @return int|bool
*/
protected function checkUploadedExtensionVersionExistsInRepository($extensionInfoData)
{
......@@ -1165,7 +1146,7 @@ class tx_ter_api
*
* @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)
{
......@@ -1273,8 +1254,6 @@ class tx_ter_api
return $result;
}
/*********************************************************
*
* checkExtensionKey helper functions
......@@ -1286,7 +1265,7 @@ class tx_ter_api
*
* @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
*/
protected function checkExtensionKey_extensionKeyIsFormallyValid($extensionKey)
......@@ -1299,7 +1278,7 @@ class tx_ter_api
}
// 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;
}
......@@ -1321,10 +1300,6 @@ class tx_ter_api
return $validKey;
}
/*********************************************************
*
* registerExtensionKey helper functions
......@@ -1337,7 +1312,6 @@ class tx_ter_api
* @param object $accountData : A valid username and password
* @param object $extensionKeyData : The extension key and other information
*
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @access protected
*/
......@@ -1362,10 +1336,6 @@ class tx_ter_api
}
}
/*********************************************************
*
* modifyExtensionKey helper functions
......@@ -1378,7 +1348,7 @@ class tx_ter_api
* @param object $accountData : A valid username and password
* @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
* @access protected
*/
......@@ -1418,10 +1388,6 @@ class tx_ter_api
return TX_TER_RESULT_GENERAL_OK;
}
/*********************************************************
*
* setReviewState helper functions
......@@ -1433,7 +1399,6 @@ class tx_ter_api
*
* @param object $setReviewStateData : Extension key, version number and the new state
*
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\NotFoundException
* @access protected
......@@ -1477,10 +1442,6 @@ class tx_ter_api
}
}
/*********************************************************
*
* increaseExtensionDownloadCounter helper functions
......@@ -1493,7 +1454,6 @@ class tx_ter_api
*
* @param object $extensionVersionDataAndIncrementor : Extension key and version number and the download count incrementor
*
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException
* @throws \T3o\Ter\Exception\NotFoundException
* @access protected
......@@ -1583,7 +1543,6 @@ class tx_ter_api
}
}
/**
* Update an existing or create a new database record
*
......@@ -1591,7 +1550,7 @@ class tx_ter_api
* @param array $recordData Record key <-> value pairs
* @param string $where Where statement
*
* @return integer UID of the new or updated record
* @return int UID of the new or updated record
*/
public function updateOrInsertRecord($table, array $recordData, $where = '')
{
......@@ -1643,11 +1602,8 @@ class tx_ter_api
return (int)$key;
}
/**
* Load an instance of the TCEMAIN object
*
* @return void
*/
public function loadTceForm()
{
......@@ -1665,7 +1621,6 @@ class tx_ter_api
* @param string $imageBaseName The prefix for each image, is also the name for the ext_icon file
* @param string $fullPath The full path to the image folder
*
* @return void
* @throws \T3o\Ter\Exception\InternalServerErrorException
*/
protected function saveImages(&$preparedFilesDataArr, $imageBaseName, $fullPath)
......
......@@ -36,9 +36,7 @@
*
* TOTAL FUNCTIONS: 8
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
// Make sure that we are executed only in TYPO3 context
......@@ -99,24 +97,19 @@ define('TX_TER_RESULT_EXTENSIONKEYSUCCESSFULLYREGISTERED', '10503');
define('TX_TER_RESULT_EXTENSIONSUCCESSFULLYUPLOADED', '10504');
define('TX_TER_RESULT_EXTENSIONSUCCESSFULLYDELETED', '10505');
/**
* TYPO3 Extension Repository, helper functions
*
* @author Robert Lemke <robert@typo3.org>
* @package TYPO3
* @subpackage tx_ter_helper
*/
class tx_ter_helper
{
protected $pluginObj;
/**
* Constructor
*
* @param object $pluginObj : Reference to parent object
* @return void
* @access public
*/
public function __construct($pluginObj)
......@@ -124,7 +117,6 @@ class tx_ter_helper
$this->pluginObj = $pluginObj;
}
/**
* This verifies the given fe_users username/password.
* Either the fe_user row is returned or an exception is thrown.
......@@ -147,8 +139,8 @@ class tx_ter_helper
);
if ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
if (!$this->userIsAlreadyLoggedIn( $accountData
if (!$this->userIsAlreadyLoggedIn(
$accountData
) && !$this->ldapValidationSucceeded($accountData)
) {
throw new \T3o\Ter\Exception\UnauthorizedException('Wrong password.', TX_TER_ERROR_GENERAL_WRONGPASSWORD);
......@@ -224,7 +216,7 @@ class tx_ter_helper
* It just returns TRUE / FALSE
*
* @param object $accountData
* @return boolean
* @return bool
*/
public function checkValidUser($accountData)
{
......@@ -242,8 +234,7 @@ class tx_ter_helper
);
if ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
if ($this->ldapValidationSucceeded( $accountData)
if ($this->ldapValidationSucceeded($accountData)
) {
$success = true;
}
......@@ -260,7 +251,7 @@ class tx_ter_helper
* if "te_rt_er" or "terter" already exist.
*
* @param string $extensionKey : The extension key to check
* @return boolean Returns TRUE if the extension key is unique and not used yet, otherwise FALSE
* @return bool Returns TRUE if the extension key is unique and not used yet, otherwise FALSE
* @access public
* @author Elmar Hinz
*/
......@@ -339,7 +330,6 @@ class tx_ter_helper
* Note: Depending on the cron job it might take a while until the index file really
* has been updated. See "cli/build-extension-index.php" for more information
*
* @return void
* @access public
*/
public function requestUpdateOfExtensionIndexFile()
......@@ -356,7 +346,6 @@ class tx_ter_helper
* Updates the "extensions.xml" file which contains an index of all uploaded
* extensions in the TER.
*
* @return void
* @access public
* @throws \T3o\Ter\Exception\InternalServerErrorException
*/
......@@ -505,7 +494,6 @@ class tx_ter_helper
md5_file($this->pluginObj->repositoryDir . 'extensions.xml.gz')
);
// Write serialized array file to disk:
$fh = fopen($this->pluginObj->repositoryDir . 'new-extensions.bin', 'wb');
if (!$fh) {
......@@ -544,7 +532,6 @@ class tx_ter_helper
return str_replace(['&', '"', "'", '<', '>'], ['&amp;', '&quot;', '&apos;', '&lt;', '&gt;'], $string);
}
/***
* Load an instance of the BE_USER to use with TCEFORM
*
......@@ -567,12 +554,10 @@ class tx_ter_helper
];
}
/**
* Load an instance of the LANG object
*
* @param string $language Used language ident
* @return void
*/
public function loadLang($lang = 'default')
{
......
......@@ -16,8 +16,6 @@
* TCA label provider
*
* @author Kai Vogel <kai.vogel@speedprogs.de>
* @package TYPO3
* @subpackage tx_ter
*/
class tx_ter_tcaLabel
{
......
<?php
########################################################################
# Extension Manager/Repository config file for ext "ter".
#
# Auto generated 19-08-2010 20:25
#
# Manual updates:
# Only the data in the array - everything else is removed by next
# writing. "version" and "dependencies" must not be touched!
########################################################################
//#######################################################################
// Extension Manager/Repository config file for ext "ter".
//
// Auto generated 19-08-2010 20:25
//
// Manual updates:
// Only the data in the array - everything else is removed by next
// writing. "version" and "dependencies" must not be touched!
//#######################################################################
$EM_CONF[$_EXTKEY] = [
'title' => 'TYPO3 Extension Repository',
......
......@@ -29,9 +29,7 @@
*
* TOTAL FUNCTIONS: 1
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
......@@ -41,8 +39,6 @@ require_once(ExtensionManagementUtility::extPath('ter') . 'class.tx_ter_api.php'
* TYPO3 Extension Repository, frontend plugin for SOAP service
*