Skip to content

Commit

Permalink
add return types to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
svewap committed Apr 17, 2024
1 parent 9592e23 commit dea15b1
Show file tree
Hide file tree
Showing 37 changed files with 40 additions and 41 deletions.
3 changes: 1 addition & 2 deletions Classes/Middleware/ZabbixClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Psr\Http\Server\MiddlewareInterface;
use TYPO3\CMS\Core\TypoScript\AST\Node\RootNode;
use TYPO3\CMS\Core\TypoScript\FrontendTypoScript;
use TYPO3\CMS\Core\Utility\DebugUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
Expand Down Expand Up @@ -98,7 +97,7 @@ private function processRequest(ServerRequestInterface $request)
} catch (InvalidOperationException $ex){
return $response->withStatus(404, $ex->getMessage());
} catch (\Exception $ex) {
return $response->withStatus(500, substr(strrchr(get_class($ex), "\\"), 1) . ': '. $ex->getMessage());
return $response->withStatus(500, get_class($ex) . ': '. $ex->getMessage());
}
}

Expand Down
8 changes: 4 additions & 4 deletions Classes/Operation/CheckPathExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class CheckPathExists implements IOperation, SingletonInterface
/**
* execute operation (checkPathExists)
*
* @param array $parameter a path 'path' to a file or folder
* @param array|null $parameter a path 'path' to a file or folder
* @return OperationResult 'file' if path is a file, 'directory' if it's a directory and false if it doesn't exist
*/
public function execute($parameter = null)
public function execute(array $parameter = null): OperationResult
{
$path = $this->getPath($parameter['path']);
list($path) = glob($path);
Expand Down Expand Up @@ -61,9 +61,9 @@ public function execute($parameter = null)
* prepare path, resolve relative path and resolve EXT: path
*
* @param string $path absolute or relative path or EXT:foobar/
* @return string/bool false if path is invalid, else the absolute path
* @return false|string false if path is invalid, else the absolute path
*/
protected function getPath($path)
protected function getPath($path): false|string
{
// getFileAbsFileName can't handle directory path with trailing / correctly
if (substr($path, -1) === '/') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GetDegradedPageUids implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult The extension version
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
if (!ExtensionManagementUtility::isLoaded('pagespeedinsights')) {
return new OperationResult(false, '');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetApplicationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GetApplicationContext implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult the current application context
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

$applicationContext = Environment::getContext();
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetDatabaseAnalyzerSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GetDatabaseAnalyzerSummary implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult the current application context
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
try {
$values = [];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetDatabaseVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GetDatabaseVersion implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult the current database version
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$db = [];
foreach (GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionNames() as $connectionName) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetDiskSpace.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GetDiskSpace implements IOperation, SingletonInterface
* @param array $parameter
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$path = !empty($parameter['path']) ? $parameter['path'] : '/';

Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetExtensionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GetExtensionList implements IOperation, SingletonInterface
* @param array $parameter Array of extension locations as string (system, global, local)
* @return OperationResult The extension list
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$locations = explode(',', $parameter['scopes']);
if (is_array($locations) && count($locations) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetExtensionVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GetExtensionVersion implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult The extension version
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
if (!isset($parameter['extensionKey']) || $parameter['extensionKey'] === '') {
throw new InvalidArgumentException('no extensionKey set');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetFeatureValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GetFeatureValue implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
if (!isset($parameter['feature']) || $parameter['feature'] === '') {
throw new InvalidArgumentException('feature not set');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetFileSpoolValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GetFileSpoolValue implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$value = $parameter['value'] ?? null;
$filePath = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['transport_spool_filepath'] ?? $GLOBALS['TYPO3_CONF_VARS']['MAIL']['spool_file_path'] ?? null;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetFilesystemChecksum.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GetFilesystemChecksum implements IOperation, SingletonInterface
* @param array $parameter Path to a file or folder
* @return OperationResult The checksum of the given folder or file
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$path = $this->getPath($parameter['path']);
$getSingleChecksums = $this->getPath($parameter['getSingleChecksums']);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetInsecureExtensionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GetInsecureExtensionList implements IOperation, SingletonInterface
* @param array $parameter Array of extension locations as string (loaded, existing)
* @return OperationResult The extension list
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$scope = $parameter['scope'] ?? '';

Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetLastExtensionListUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class GetLastExtensionListUpdate implements IOperation, SingletonInterface
{

public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
if (!ExtensionManagementUtility::isLoaded('scheduler')) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetLastSchedulerRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class GetLastSchedulerRun implements IOperation, SingletonInterface
{

public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
/** @var Registry $registry */
$registry = GeneralUtility::makeInstance(Registry::class);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetLogResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GetLogResults implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

$filter = $parameter['filter'];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetOpCacheStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GetOpCacheStatus implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult the current database version
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

/** @var OpcodeCacheService $opCacheService */
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetOutdatedExtensionList.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GetOutdatedExtensionList implements IOperation, SingletonInterface
* @param array $parameter Array of extension locations as string (system, global, local)
* @return OperationResult The extension list
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$scope = $parameter['scope'] ?? '';

Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetPHPVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GetPHPVersion implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult the current PHP version
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
return new OperationResult(true, PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION);
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetProgramVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GetProgramVersion implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult the current PHP version
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

if (!isset($parameter['program']) || $parameter['program'] === '') {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class GetRecord implements IOperation, SingletonInterface
* @param array $parameter A table 'table', field name 'field' and the value 'value' to find the record
* @return OperationResult The first found record as an array or FALSE if no record was found
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$table = $parameter['table'];
$field = $parameter['field'];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class GetRecords implements IOperation, SingletonInterface
* @return OperationResult A set of records as an array or FALSE if no record was found
* @example ../services/class.FindBlacklistedBePasswordTestService.php This class tests if there are duplicate passwords, besides checking for the presence of blacklisted passwords.
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$table = $parameter['table'];
$field = $parameter['field'];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetTYPO3Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GetTYPO3Version implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult the current PHP version
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$typo3Version = GeneralUtility::makeInstance(Typo3Version::class);

Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetTotalLogFilesSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GetTotalLogFilesSize implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$totalSize = 0;
$files = GeneralUtility::getFilesInDir(Environment::getVarPath() . '/log/', 'log');
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/GetZabbixLogFileSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GetZabbixLogFileSize implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$totalSize = 0;

Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasDeprecationLogEnabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class HasDeprecationLogEnabled implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

$errorHandlerErrors = $GLOBALS['TYPO3_CONF_VARS']['SYS']['errorHandlerErrors'];
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasExtensionUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HasExtensionUpdate implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

if (!isset($parameter['extensionKey']) || $parameter['extensionKey'] === '') {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasFailedSchedulerTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HasFailedSchedulerTask implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_scheduler_task');
$queryBuilder
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasForbiddenUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HasForbiddenUsers implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

if (!isset($parameter['usernames'])) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasIPTCPreservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HasIPTCPreservation implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
return new OperationResult(true, strpos($GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_stripColorProfileCommand'] ?? '','!iptc') !== false);
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasMissingDefaultMailSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HasMissingDefaultMailSettings implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

if (empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasOutdatedVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HasOutdatedVersion implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

/** @var CoreVersionService $coreVersionService */
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasRemainingUpdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class HasRemainingUpdates implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

$upgradeWizardsService = GeneralUtility::makeInstance(UpgradeWizardsService::class);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasSecurityUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HasSecurityUpdate implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
/** @var CoreVersionService $coreVersionService */
$coreVersionService = GeneralUtility::makeInstance(CoreVersionService::class);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasStrictSyntaxEnabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HasStrictSyntaxEnabled implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{
return new OperationResult(true,
GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('TypoScript.strictSyntax'));
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/HasUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HasUpdate implements IOperation, SingletonInterface
* @param array $parameter None
* @return OperationResult
*/
public function execute($parameter = [])
public function execute(array $parameter = []): OperationResult
{

/** @var CoreVersionService $coreVersionService */
Expand Down
2 changes: 1 addition & 1 deletion Classes/Operation/IOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ interface IOperation
* @param array $parameter Parameters for the operation
* @return OperationResult The operation result
*/
public function execute($parameter = []);
public function execute(array $parameter = []): OperationResult;
}

0 comments on commit dea15b1

Please sign in to comment.