Commit a8dc4ee9 authored by Stefan Froemken's avatar Stefan Froemken

Repair most of PhpStorms Inspection hints/errors

* remove unused variables
* correct Method annotations
* add @throws annotation
* correct amount of method parameters
* correct incompatible return type

I have not updated deprecation problems
parent 69a39400
Pipeline #2558 passed with stages
in 2 minutes and 13 seconds
......@@ -189,7 +189,7 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
* WORKAROUND for #33788
*
* @param string $uri The URI
* @return void
* @return string
*/
protected function addBaseUriIfNecessary($uri)
{
......
......@@ -70,6 +70,7 @@ abstract class AbstractTerBasedController extends \T3o\TerFe2\Controller\Abstrac
/**
* Initializes the view, add login state to template variables
*
* @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
* @return void
*/
public function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
......@@ -108,6 +109,7 @@ abstract class AbstractTerBasedController extends \T3o\TerFe2\Controller\Abstrac
* Create a connection to the TER server
*
* @return \T3o\TerFe2\Service\Ter The TER connection
* @throws \Exception
*/
protected function getTerConnection()
{
......
......@@ -329,6 +329,7 @@ class ExtensionController extends \T3o\TerFe2\Controller\AbstractController
* @param string $format Format of the file output
* @ignorevalidation $extension
* @return void
* @throws \Exception
*/
public function downloadAction(\T3o\TerFe2\Domain\Model\Extension $extension, $versionString = '', $format = '')
{
......
......@@ -249,7 +249,7 @@ class RegisterkeyController extends \T3o\TerFe2\Controller\AbstractTerBasedContr
*/
public function keepAction(\T3o\TerFe2\Domain\Model\Extension $extension)
{
$extension->setExpire(0);
$extension->setExpire(null);
$this->extensionRepository->update($extension);
$this->redirect('index', 'Registerkey');
}
......
......@@ -25,7 +25,6 @@ namespace T3o\TerFe2\Domain\Model;
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
use TYPO3\CMS\Extbase\Domain\Model\FrontendUser;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
......
......@@ -601,9 +601,9 @@ class Extension extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
}
/**
* @param \DateTime $expire
* @param \DateTime|null $expire
*/
public function setExpire(\DateTime $expire)
public function setExpire(\DateTime $expire = null)
{
$this->expire = $expire;
}
......
......@@ -915,7 +915,7 @@ class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Setter for softwareRelations
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage <\T3o\TerFe2\Domain\Model\Relation> $softwareRelations Relations
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $softwareRelations Relations
* @return void
*/
public function setSoftwareRelations(ObjectStorage $softwareRelations)
......@@ -926,7 +926,7 @@ class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
/**
* Getter for softwareRelations
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Relation> Relations
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage Relations
*/
public function getSoftwareRelations(): ObjectStorage
{
......
......@@ -34,8 +34,8 @@ abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Reposit
/**
* Returns a query for objects of this repository
*
* @param string $offset Offset to start with
* @param string $count Count of result
* @param int $offset Offset to start with
* @param int $count Count of result
* @param array $ordering Ordering <-> Direction
* @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
*/
......@@ -61,10 +61,10 @@ abstract class AbstractRepository extends \TYPO3\CMS\Extbase\Persistence\Reposit
/**
* Returns all objects
*
* @param string $offset Offset to start with
* @param string $count Count of result
* @param string $ordering Ordering <-> Direction
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage Objects
* @param int $offset Offset to start with
* @param int $count Count of result
* @param array $ordering Ordering <-> Direction
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface Objects
*/
public function findAll($offset = 0, $count = 0, array $ordering = array())
{
......
......@@ -44,9 +44,8 @@ class ExtensionManagerCacheEntryRepository extends \T3o\TerFe2\Domain\Repository
$query = $this->createQuery($offset, $count);
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectSysLanguage(false);
$query->getQuerySettings()->setReturnRawQueryResult(true);
$query->matching($query->greaterThan('lastuploaddate', (int)$lastUpdateDate));
return $query->execute();
return $query->execute(true);
}
......@@ -62,15 +61,14 @@ class ExtensionManagerCacheEntryRepository extends \T3o\TerFe2\Domain\Repository
$query = $this->createQuery(0, 1);
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectSysLanguage(false);
$query->getQuerySettings()->setReturnRawQueryResult(true);
$query->matching(
$query->logicalAnd(
$query->logicalAnd([
$query->equals('extkey', $extKey),
$query->equals('version', $versionString)
)
])
);
$rows = $query->execute();
$rows = $query->execute(true);
if (is_array($rows)) {
return reset($rows);
}
......
......@@ -64,7 +64,7 @@ class ExtensionRepository extends \T3o\TerFe2\Domain\Repository\AbstractReposito
*
* @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
* @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint
* @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
* @return void
*/
protected function match(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint)
{
......@@ -73,10 +73,10 @@ class ExtensionRepository extends \T3o\TerFe2\Domain\Repository\AbstractReposito
return;
}
$query->matching($query->logicalAnd(
$query->matching($query->logicalAnd([
$query->logicalNot($query->equals('lastVersion.reviewState', -1)),
$constraint
));
]));
}
......@@ -128,7 +128,7 @@ class ExtensionRepository extends \T3o\TerFe2\Domain\Repository\AbstractReposito
* Returns new and updated extensions
*
* @param integer $latestCount Count of extensions
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage Objects
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface Objects
*/
public function findLatest($latestCount = 0)
{
......@@ -153,9 +153,8 @@ class ExtensionRepository extends \T3o\TerFe2\Domain\Repository\AbstractReposito
}
/**
*
* @param string $frontendUser
* @return \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult|NULL
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function findByFrontendUserAndExpiring($frontendUser)
{
......@@ -192,14 +191,14 @@ class ExtensionRepository extends \T3o\TerFe2\Domain\Repository\AbstractReposito
$query->getQuerySettings()->setRespectSysLanguage(false);
$constraints = array(
$query->equals('frontendUser', $frontendUser),
$query->logicalAnd(
$query->logicalAnd([
$query->logicalNot(
$query->equals('uid', $extension->getUid())
),
$query->logicalNot(
$query->equals('lastVersion.state', 'obsolete')
)
),
]),
$query->greaterThanOrEqual('lastVersion.review_state', '0'),
$query->greaterThanOrEqual('versions', '1')
);
......
......@@ -52,7 +52,7 @@ class VersionRepository extends \T3o\TerFe2\Domain\Repository\AbstractRepository
*
* @param \TYPO3\CMS\Extbase\Persistence\QueryInterface $query
* @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint
* @return \TYPO3\CMS\Extbase\Persistence\QueryInterface
* @return void
*/
protected function match(\TYPO3\CMS\Extbase\Persistence\QueryInterface $query, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint)
{
......@@ -62,10 +62,10 @@ class VersionRepository extends \T3o\TerFe2\Domain\Repository\AbstractRepository
}
$query->matching(
$query->logicalAnd(
$query->logicalAnd([
$query->greaterThanOrEqual('reviewState', 0),
$constraint
)
])
);
}
......@@ -82,10 +82,10 @@ class VersionRepository extends \T3o\TerFe2\Domain\Repository\AbstractRepository
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setRespectSysLanguage(false);
$query->matching(
$query->logicalAnd(
$query->logicalAnd([
$query->equals('extension', $extension),
$query->equals('versionString', $versionString)
)
])
);
return $query->execute()->getFirst();
}
......@@ -97,7 +97,7 @@ class VersionRepository extends \T3o\TerFe2\Domain\Repository\AbstractRepository
* @param \T3o\TerFe2\Domain\Model\Extension $extension The extension object
* @param integer $count Count of versions to return
* @param boolean $skipLatest Skip latest version
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage Objects
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface Objects
*/
public function getVersionHistory($extension, $count = 0, $skipLatest = true)
{
......@@ -108,12 +108,12 @@ class VersionRepository extends \T3o\TerFe2\Domain\Repository\AbstractRepository
if (!empty($skipLatest)) {
$query->matching(
$query->logicalAnd(
$query->logicalAnd([
$query->equals('extension', $extension),
$query->logicalNot(
$query->equals('uid', (int)$extension->getLastVersion()->getUid())
)
)
])
);
} else {
$query->matching($query->equals('extension', $extension));
......
......@@ -131,6 +131,7 @@ abstract class AbstractPersistence implements \T3o\TerFe2\Persistence\Persistenc
* @param string $key Name of the value
* @param mixed $value Value content
* @return void
* @throws \Exception
*/
public function set($key, $value)
{
......@@ -163,7 +164,7 @@ abstract class AbstractPersistence implements \T3o\TerFe2\Persistence\Persistenc
/**
* Add multiple values
*
* @param array $value Key <-> value pairs
* @param array $values Key <-> value pairs
* @return void
*/
public function addMultiple(array $values)
......
......@@ -70,7 +70,7 @@ interface PersistenceInterface
/**
* Add multiple values
*
* @param array $value Key <-> value pairs
* @param array $values Key <-> value pairs
* @return void
*/
public function addMultiple(array $values);
......
......@@ -30,11 +30,11 @@ namespace T3o\TerFe2\Persistence;
*/
class Session extends \T3o\TerFe2\Persistence\AbstractPersistence
{
/**
* Load content
*
* @return void
* @throws \Exception
*/
public function load()
{
......@@ -47,11 +47,11 @@ class Session extends \T3o\TerFe2\Persistence\AbstractPersistence
}
}
/**
* Save content
*
* @return void
* @throws \Exception
*/
public function save()
{
......
......@@ -59,8 +59,6 @@ abstract class AbstractProvider implements \T3o\TerFe2\Provider\ProviderInterfac
/**
* Get or create absolute path to image cache directory
*
* @return void
*/
public function __construct()
{
......
......@@ -181,7 +181,9 @@ class FileProvider extends \T3o\TerFe2\Provider\AbstractProvider
*
* @param string $extension Extension key
* @param string $version Version string
* @param string $fileHash hash of file
* @return array Extension info array
* @throws \Exception
*/
protected function getExtensionInfo($extension, $version, $fileHash)
{
......@@ -250,7 +252,7 @@ class FileProvider extends \T3o\TerFe2\Provider\AbstractProvider
$extensionModel = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class);
$states = $extensionModel->getDefaultState(null);
$states = array_flip($states);
$categories = Category::getDefaultCategories(null);
$categories = Category::getDefaultCategories();
$categories = array_flip($categories);
$extensions = array();
......
......@@ -117,7 +117,9 @@ class MirrorProvider extends \T3o\TerFe2\Provider\FileProvider
*
* @param string $extension Extension key
* @param string $version Version string
* @param string $fileHash Hash of file
* @return array Extension info array
* @throws \Exception
*/
protected function getExtensionInfo($extension, $version, $fileHash)
{
......
......@@ -57,6 +57,7 @@ class ProviderManager implements \TYPO3\CMS\Core\SingletonInterface
*
* @param string $name Name of the provider
* @return \T3o\TerFe2\Provider\ProviderInterface Extension provider
* @throws \Exception
*/
public function getProvider($name)
{
......
......@@ -61,6 +61,7 @@ class SoapProvider extends \T3o\TerFe2\Provider\AbstractProvider
* Initialize provider
*
* @return void
* @throws \Exception
*/
public function initializeProvider()
{
......@@ -104,6 +105,7 @@ class SoapProvider extends \T3o\TerFe2\Provider\AbstractProvider
* @param integer $offset Offset to start with
* @param integer $count Extension count to load
* @return array Extension rows
* @throws \Exception
*/
public function getExtensions($lastRun, $offset, $count)
{
......@@ -126,6 +128,7 @@ class SoapProvider extends \T3o\TerFe2\Provider\AbstractProvider
* @param \T3o\TerFe2\Domain\Model\Version $version Version object
* @param string $fileType File type
* @return string Url to file
* @throws \Exception
*/
public function getFileUrl(\T3o\TerFe2\Domain\Model\Version $version, $fileType)
{
......@@ -151,6 +154,7 @@ class SoapProvider extends \T3o\TerFe2\Provider\AbstractProvider
* @param \T3o\TerFe2\Domain\Model\Version $version Version object
* @param string $fileType File type
* @return string File name
* @throws \Exception
*/
public function getFileName(\T3o\TerFe2\Domain\Model\Version $version, $fileType)
{
......@@ -175,6 +179,7 @@ class SoapProvider extends \T3o\TerFe2\Provider\AbstractProvider
*
* @param \T3o\TerFe2\Domain\Model\Version $version Version object
* @return array Version details
* @throws \Exception
*/
public function getVersionDetails(\T3o\TerFe2\Domain\Model\Version $version)
{
......
......@@ -126,6 +126,7 @@ class Mirror implements \TYPO3\CMS\Core\SingletonInterface
*
* @param boolean $refresh Generate new mirror url
* @return string Mirror url
* @throws \Exception
*/
public function getMirror($refresh = false)
{
......@@ -183,6 +184,7 @@ class Mirror implements \TYPO3\CMS\Core\SingletonInterface
*
* @param string $filename File name to check
* @return string Url to file on mirror server
* @throws \Exception
*/
public function getUrlToFile($filename)
{
......@@ -215,6 +217,7 @@ class Mirror implements \TYPO3\CMS\Core\SingletonInterface
*
* @param string $filename File name to fetch
* @return string File content
* @throws \Exception
*/
public function getFile($filename)
{
......
......@@ -145,7 +145,7 @@ class Soap implements \TYPO3\CMS\Core\SingletonInterface
/**
* Set authentication header
*
* @param \SoapHeader $soapHeader SOAP header
* @param \SoapHeader $authenticationHeader SOAP header
* @return void
*/
public function setAuthenticationHeader(\SoapHeader $authenticationHeader)
......
......@@ -77,6 +77,7 @@ class Ter
* Check if an extension key is valid
*
* @param string $extensionKey Extension key
* @param string $error Error key
* @return boolean TRUE if extension key is valid
*/
public function checkExtensionKey($extensionKey, &$error)
......@@ -117,18 +118,15 @@ class Ter
// if the result is empty
if (empty($result['resultCode'])) {
$error = 'result_empty';
return false;
}
// result code invalid 10502 = TX_TER_RESULT_EXTENSIONKEYNOTVALID
if ($result['resultCode'] === '10502') {
$error = 'key_invalid';
return false;
}
// key exists 10500 = TX_TER_RESULT_EXTENSIONKEYALREADYEXISTS
if ($result['resultCode'] === '10500') {
$error = 'key_exists';
return false;
}
......@@ -228,7 +226,7 @@ class Ter
try {
$this->soapService->setReviewState($this->userData, $parameters);
} catch (SoapFault $exception) {
} catch (\SoapFault $exception) {
$error = $exception->faultstring;
return false;
}
......
......@@ -106,6 +106,7 @@ class ImportAllExtensionsTask extends \TYPO3\CMS\Extbase\Scheduler\Task
/**
* Gets the extension data out of ter tables
*
* @param int $extUid
* @return array $extData
*/
public function getExtensionDataOfExtUid($extUid)
......@@ -114,7 +115,7 @@ class ImportAllExtensionsTask extends \TYPO3\CMS\Extbase\Scheduler\Task
'tx_ter_extensions.*, tx_ter_extensiondetails.*',
'tx_ter_extensions
LEFT JOIN tx_ter_extensiondetails ON tx_ter_extensions.uid = tx_ter_extensiondetails.extensionuid',
'tx_ter_extensiondetails.extensionuid = ' . $extUid
'tx_ter_extensiondetails.extensionuid = ' . (int)$extUid
);
return $extData;
}
......@@ -203,11 +204,12 @@ class ImportAllExtensionsTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/
public function createVersion($extUid, $extData)
{
/** @var \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extensionModel */
$extensionModel = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class);
$states = $extensionModel->getDefaultState(null);
$categories = Category::getDefaultCategories(null);
$states = $extensionModel->getDefaultState();
$categories = Category::getDefaultCategories();
$insertVersion = array(
$insertVersion = [
'pid' => $this->pid,
'extension' => $extUid,
'title' => $extData['title'],
......@@ -241,7 +243,7 @@ class ImportAllExtensionsTask extends \TYPO3\CMS\Extbase\Scheduler\Task
'has_images' => 0,
't3x_file_size' => @filesize(PATH_site . 'fileadmin/ter/' . $extData['extensionkey'] . '_' . $extData['version_string'] . '.t3x'),
'zip_file_size' => 0
);
];
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_terfe2_domain_model_version', $insertVersion);
return $GLOBALS['TYPO3_DB']->sql_insert_id();
......
......@@ -39,8 +39,9 @@ class Archive
*
* @param string $filename File name of the archive
* @param array $files All files to insert
* @param string $overwrite Overwrite file if exists
* @param bool $overwrite Overwrite file if exists
* @return boolean TRUE if success
* @throws \Exception
*/
public static function createZipArchive($filename, array $files, $overwrite = false)
{
......@@ -86,6 +87,7 @@ class Archive
* @param string $path Path to extract into
* @param mixed $files Single filename or array of filenames to extract
* @return boolean TRUE if success
* @throws \Exception
*/
public static function extractZipArchive($filename, $path, $files = null)
{
......@@ -129,6 +131,7 @@ class Archive
*
* @param string $filename File name
* @return array File informations
* @throws \Exception
*/
public static function getZipArchiveContent($filename)
{
......@@ -177,10 +180,10 @@ class Archive
/**
* Creates a zip file from given extension T3X file
*
* @throws Exception
* @param string $t3xFile Path to the t3x file
* @param string $zipFile Path to the zip file
* @return boolean TRUE if success
* @throws \Exception
*/
public static function convertT3xToZip($t3xFile, $zipFile)
{
......@@ -279,7 +282,7 @@ class Archive
*
* @param string $filename Path to zip file
* @param array $files Reference to files
* @return stdClass Extension information
* @return \stdClass Extension information
* @see tx_em_Extensions_Details::uploadToTER
*/
public static function getExtensionDetailsFromZipArchive($filename, array &$files = array())
......
......@@ -189,7 +189,7 @@ class File
* This function must be called before any HTTP headers have been sent
*
* @param string $content File content
* @param string $visibleFileName File name for downloaded file
* @param string $fileName File name for downloaded file
* @return boolean FALSE if something wents wrong
*/
public static function transferFileContent($content, $fileName)
......@@ -382,7 +382,7 @@ class File
* Move a directory
*
* @param string $fromDirectory Existing directory
* @param string $toParentDirectory Name of the new directory
* @param string $toDirectory Name of the new directory
* @param boolean $overwrite A directory with new name will be overwritten if set
* @return boolean TRUE if success
*/
......@@ -401,7 +401,7 @@ class File
* @param string $tempname Temporary file name
* @param string $filename Original file name
* @param string $directory Directory path
* @return New file name
* @return string New file name
*/
public static function moveUploadedFile($tempname, $filename, $directory = 'uploads/')
{
......@@ -414,7 +414,6 @@ class File
return '';
}
/**
* Remove a file
*
......
......@@ -37,7 +37,6 @@ class Log
* @param string $message The log message
* @param string $extensionKey The extension
* @param integer $severity The severity of the event
* @param string $target Target of the logging
* @return void
*/
public static function addMessage($message, $extensionKey, $severity = 0)
......@@ -57,7 +56,6 @@ class Log
* @param string $message The log message
* @param string $extensionKey The extension
* @param integer $severity The severity of the event
* @param string $target Target of the logging
* @return void
*/
public static function addSystemMessage($message, $extensionKey, $severity = 0)
......
......@@ -47,7 +47,6 @@ class UrlValidator extends \TYPO3\CMS\Extbase\Validation\Validator\AbstractValid
*/
public function isValid($value)
{
$this->errors = array();
$value = (string)$value;
if ($value !== '' && ($value !== filter_var($value, FILTER_SANITIZE_URL) || !$this->hasValidScheme($value))) {
$this->addError('The given subject was not a valid url.', 1364118054);
......
......@@ -36,13 +36,13 @@ class FormatViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelp
*/
protected $escapingInterceptorEnabled = false;
/**
* Formats content with given function
*
* @param string $function Function to format the content
* @param mixed $content Content
* @return string Formated content
* @throws \Exception
*/
public function render($function, $content = null)
{
......
......@@ -15,7 +15,7 @@
/**
* Class Tx_TerFe2_Utility_ArchiveTest
*/
class Tx_TerFe2_Utility_ArchiveTest extends tx_phpunit_testcase
class Tx_TerFe2_Utility_ArchiveTest extends \tx_phpunit_testcase
{
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment