diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon
index 4114d9a5821d..0ad3063df1a8 100644
--- a/Build/phpstan/phpstan-baseline.neon
+++ b/Build/phpstan/phpstan-baseline.neon
@@ -2634,8 +2634,3 @@ parameters:
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: ../../typo3/sysext/webhooks/Tests/Functional/WebhookExecutionTest.php
-
- -
- message: "#^Else branch is unreachable because previous condition is always true\\.$#"
- count: 1
- path: ../../typo3/sysext/workspaces/Classes/Service/GridDataService.php
diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
index d895f8185f42..7ec03406a08d 100644
--- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php
+++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
@@ -821,7 +821,7 @@ protected static function getRecordsSortedByTitle(array $fields, $table, $titleF
while ($record = $res->fetchAssociative()) {
// store the uid, because it might be unset if it's not among the requested $fields
- $recordId = $record['uid'];
+ $recordId = (int)$record['uid'];
$record[$titleField] = self::getRecordTitle($table, $record);
// include only the requested fields in the result
diff --git a/typo3/sysext/workspaces/Classes/Command/AutoPublishCommand.php b/typo3/sysext/workspaces/Classes/Command/AutoPublishCommand.php
index b326f6476251..61650489a6e5 100644
--- a/typo3/sysext/workspaces/Classes/Command/AutoPublishCommand.php
+++ b/typo3/sysext/workspaces/Classes/Command/AutoPublishCommand.php
@@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);
// Get CMD array
- $cmd = $this->workspaceService->getCmdArrayForPublishWS($workspaceRecord['uid']);
+ $cmd = $this->workspaceService->getCmdArrayForPublishWS((int)$workspaceRecord['uid']);
$tce = GeneralUtility::makeInstance(DataHandler::class);
$tce->start([], $cmd);
$tce->process_cmdmap();
diff --git a/typo3/sysext/workspaces/Classes/Controller/AjaxDispatcher.php b/typo3/sysext/workspaces/Classes/Controller/AjaxDispatcher.php
index 7a1300a3460b..2f49200701fe 100644
--- a/typo3/sysext/workspaces/Classes/Controller/AjaxDispatcher.php
+++ b/typo3/sysext/workspaces/Classes/Controller/AjaxDispatcher.php
@@ -33,10 +33,7 @@
*/
class AjaxDispatcher
{
- /**
- * @var array
- */
- protected $classMap = [
+ protected array $classMap = [
'RemoteServer' => RemoteServer::class,
'MassActions' => MassActionHandler::class,
'Actions' => ActionHandler::class,
diff --git a/typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php b/typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php
index dc32f4ac1410..9307fd22c995 100644
--- a/typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php
+++ b/typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php
@@ -208,6 +208,7 @@ public function loadColumnModel()
*/
public function sendToNextStageWindow($uid, $table, $t3ver_oid)
{
+ $uid = (int)$uid;
$elementRecord = BackendUtility::getRecord($table, $uid);
if (is_array($elementRecord)) {
$workspaceRecord = WorkspaceRecord::get($elementRecord['t3ver_wsid']);
@@ -239,6 +240,7 @@ public function sendToNextStageWindow($uid, $table, $t3ver_oid)
*/
public function sendToPrevStageWindow($uid, $table)
{
+ $uid = (int)$uid;
$elementRecord = BackendUtility::getRecord($table, $uid);
if (is_array($elementRecord)) {
$workspaceRecord = WorkspaceRecord::get($elementRecord['t3ver_wsid']);
@@ -282,7 +284,7 @@ public function sendToSpecificStageWindow($nextStageId, array $elements)
foreach ($elements as $element) {
$this->stagesService->getRecordService()->add(
$element->table,
- $element->uid
+ (int)$element->uid
);
}
@@ -616,7 +618,7 @@ public function sendToSpecificStageExecute(\stdClass $parameters)
protected function getSentToStageWindow($nextStage)
{
if (!$nextStage instanceof StageRecord) {
- $nextStage = WorkspaceRecord::get($this->getCurrentWorkspace())->getStage($nextStage);
+ $nextStage = WorkspaceRecord::get($this->getCurrentWorkspace())->getStage((int)$nextStage);
}
$result = [];
diff --git a/typo3/sysext/workspaces/Classes/Controller/Remote/MassActionHandler.php b/typo3/sysext/workspaces/Classes/Controller/Remote/MassActionHandler.php
index 914b0df2a3ba..05c325824db3 100644
--- a/typo3/sysext/workspaces/Classes/Controller/Remote/MassActionHandler.php
+++ b/typo3/sysext/workspaces/Classes/Controller/Remote/MassActionHandler.php
@@ -32,10 +32,7 @@ class MassActionHandler
{
public const MAX_RECORDS_TO_PROCESS = 30;
- /**
- * @var WorkspaceService
- */
- protected $workspaceService;
+ protected WorkspaceService $workspaceService;
public function __construct()
{
@@ -44,10 +41,8 @@ public function __construct()
/**
* Publishes the current workspace.
- *
- * @return array
*/
- public function publishWorkspace(\stdClass $parameters)
+ public function publishWorkspace(\stdClass $parameters): array
{
$result = [
'init' => false,
@@ -72,10 +67,8 @@ public function publishWorkspace(\stdClass $parameters)
/**
* Flushes the current workspace.
- *
- * @return array
*/
- public function flushWorkspace(\stdClass $parameters)
+ public function flushWorkspace(\stdClass $parameters): array
{
$result = [
'init' => false,
@@ -99,15 +92,11 @@ public function flushWorkspace(\stdClass $parameters)
/**
* Initializes the command map to be used for publishing.
- *
- * @param int $workspace
- * @param int $language
- * @return int
*/
- protected function initPublishData($workspace, $language = null)
+ protected function initPublishData(int $workspace, int $language = null): int
{
- // workspace might be -98 a.k.a "All Workspaces but that's save here
- $publishData = $this->workspaceService->getCmdArrayForPublishWS($workspace, false, 0, $language);
+ // workspace might be -98 a.k.a "All Workspaces" but that's safe here
+ $publishData = $this->workspaceService->getCmdArrayForPublishWS($workspace, false, $language);
$recordCount = 0;
foreach ($publishData as $table => $recs) {
$recordCount += count($recs);
@@ -122,15 +111,11 @@ protected function initPublishData($workspace, $language = null)
/**
* Initializes the command map to be used for flushing.
- *
- * @param int $workspace
- * @param int $language
- * @return int
*/
- protected function initFlushData($workspace, $language = null)
+ protected function initFlushData(int $workspace, int $language = null): int
{
- // workspace might be -98 a.k.a "All Workspaces but that's save here
- $flushData = $this->workspaceService->getCmdArrayForFlushWS($workspace, true, 0, $language);
+ // workspace might be -98 a.k.a "All Workspaces" but that's safe here
+ $flushData = $this->workspaceService->getCmdArrayForFlushWS($workspace, $language);
$recordCount = 0;
foreach ($flushData as $table => $recs) {
$recordCount += count($recs);
@@ -145,10 +130,8 @@ protected function initFlushData($workspace, $language = null)
/**
* Processes the data.
- *
- * @return int
*/
- protected function processData()
+ protected function processData(): int
{
$processData = $this->getBackendUser()->getSessionData('workspaceMassAction');
$recordsProcessed = $this->getBackendUser()->getSessionData('workspaceMassAction_processed');
@@ -195,10 +178,8 @@ protected function processData()
/**
* Validates whether the submitted language parameter can be
* interpreted as integer value.
- *
- * @return int|null
*/
- protected function validateLanguageParameter(\stdClass $parameters)
+ protected function validateLanguageParameter(\stdClass $parameters): ?int
{
$language = null;
if (isset($parameters->language) && MathUtility::canBeInterpretedAsInteger($parameters->language)) {
@@ -209,8 +190,6 @@ protected function validateLanguageParameter(\stdClass $parameters)
/**
* Gets the current workspace ID.
- *
- * @return int The current workspace ID
*/
protected function getCurrentWorkspace(): int
{
diff --git a/typo3/sysext/workspaces/Classes/Controller/Remote/RemoteServer.php b/typo3/sysext/workspaces/Classes/Controller/Remote/RemoteServer.php
index c84e65476b54..8757bade02b3 100644
--- a/typo3/sysext/workspaces/Classes/Controller/Remote/RemoteServer.php
+++ b/typo3/sysext/workspaces/Classes/Controller/Remote/RemoteServer.php
@@ -99,11 +99,11 @@ public function getWorkspaceInfos($parameter, ServerRequestInterface $request)
}
$versions = $this->workspaceService->selectVersionsInWorkspace(
$this->getCurrentWorkspace(),
- $parameter->stage,
+ (int)$parameter->stage,
$pageId,
- $parameter->depth,
+ (int)$parameter->depth,
'tables_select',
- $parameter->language
+ $parameter->language !== null ? (int)$parameter->language : null
);
$data = $this->gridDataService->generateGridListFromVersions($versions, $parameter, $this->getCurrentWorkspace(), $request);
return $data;
@@ -389,8 +389,8 @@ protected function getCommentsForRecord(array $historyEntries, array $additional
foreach ($historyEntries as $entry) {
$preparedEntry = [];
$beUserRecord = BackendUtility::getRecord('be_users', $entry['userid']);
- $preparedEntry['stage_title'] = htmlspecialchars($this->stagesService->getStageTitle($entry['history_data']['next']));
- $preparedEntry['previous_stage_title'] = htmlspecialchars($this->stagesService->getStageTitle($entry['history_data']['current']));
+ $preparedEntry['stage_title'] = htmlspecialchars($this->stagesService->getStageTitle((int)$entry['history_data']['next']));
+ $preparedEntry['previous_stage_title'] = htmlspecialchars($this->stagesService->getStageTitle((int)$entry['history_data']['current']));
$preparedEntry['user_uid'] = (int)$entry['userid'];
$preparedEntry['user_username'] = is_array($beUserRecord) ? htmlspecialchars($beUserRecord['username']) : '';
$preparedEntry['tstamp'] = htmlspecialchars(BackendUtility::datetime($entry['tstamp']));
@@ -404,7 +404,7 @@ protected function getCommentsForRecord(array $historyEntries, array $additional
$sysLogEntry = [];
$data = $this->unserializeLogData($sysLogRow['log_data'] ?? '');
$beUserRecord = BackendUtility::getRecord('be_users', $sysLogRow['userid']);
- $sysLogEntry['stage_title'] = htmlspecialchars($this->stagesService->getStageTitle($data['stage']));
+ $sysLogEntry['stage_title'] = htmlspecialchars($this->stagesService->getStageTitle((int)$data['stage']));
$sysLogEntry['previous_stage_title'] = '';
$sysLogEntry['user_uid'] = (int)$sysLogRow['userid'];
$sysLogEntry['user_username'] = is_array($beUserRecord) ? htmlspecialchars($beUserRecord['username']) : '';
@@ -467,10 +467,9 @@ protected function getLanguageService(): LanguageService
* given set of affected elements.
*
* @param CombinedRecord[] $affectedElements
- * @return IntegrityService
* @see getAffectedElements
*/
- protected function createIntegrityService(array $affectedElements)
+ protected function createIntegrityService(array $affectedElements): IntegrityService
{
$integrityService = GeneralUtility::makeInstance(IntegrityService::class);
$integrityService->setAffectedElements($affectedElements);
@@ -482,15 +481,13 @@ protected function createIntegrityService(array $affectedElements)
* Affected elements have a dependency, e.g. translation overlay
* and the default origin record - thus, the default record would be
* affected if the translation overlay shall be published.
- *
- * @return array
*/
- protected function getAffectedElements(\stdClass $parameters)
+ protected function getAffectedElements(\stdClass $parameters): array
{
$affectedElements = [];
if ($parameters->type === 'selection') {
foreach ((array)$parameters->selection as $element) {
- $affectedElements[] = CombinedRecord::create($element->table, $element->liveId, $element->versionId);
+ $affectedElements[] = CombinedRecord::create($element->table, (int)$element->liveId, (int)$element->versionId);
}
} elseif ($parameters->type === 'all') {
$versions = $this->workspaceService->selectVersionsInWorkspace(
@@ -503,7 +500,7 @@ protected function getAffectedElements(\stdClass $parameters)
);
foreach ($versions as $table => $tableElements) {
foreach ($tableElements as $element) {
- $affectedElement = CombinedRecord::create($table, $element['t3ver_oid'], $element['uid']);
+ $affectedElement = CombinedRecord::create($table, (int)$element['t3ver_oid'], (int)$element['uid']);
$affectedElement->getVersionRecord()->setRow($element);
$affectedElements[] = $affectedElement;
}
@@ -515,10 +512,8 @@ protected function getAffectedElements(\stdClass $parameters)
/**
* Validates whether the submitted language parameter can be
* interpreted as integer value.
- *
- * @return int|null
*/
- protected function validateLanguageParameter(\stdClass $parameters)
+ protected function validateLanguageParameter(\stdClass $parameters): ?int
{
$language = null;
if (isset($parameters->language) && MathUtility::canBeInterpretedAsInteger($parameters->language)) {
@@ -529,10 +524,8 @@ protected function validateLanguageParameter(\stdClass $parameters)
/**
* Gets the current workspace ID.
- *
- * @return int The current workspace ID
*/
- protected function getCurrentWorkspace()
+ protected function getCurrentWorkspace(): int
{
return $this->workspaceService->getCurrentWorkspace();
}
diff --git a/typo3/sysext/workspaces/Classes/DataHandler/CommandMap.php b/typo3/sysext/workspaces/Classes/DataHandler/CommandMap.php
index 6abe64acf6a6..1fb728c31711 100644
--- a/typo3/sysext/workspaces/Classes/DataHandler/CommandMap.php
+++ b/typo3/sysext/workspaces/Classes/DataHandler/CommandMap.php
@@ -1,5 +1,7 @@
set($commandMap);
$this->setWorkspace($workspace);
@@ -71,20 +56,16 @@ public function __construct(array $commandMap, $workspace)
/**
* Gets the command map.
- *
- * @return array
*/
- public function get()
+ public function get(): array
{
return $this->commandMap;
}
/**
* Sets the command map.
- *
- * @return CommandMap
*/
- public function set(array $commandMap)
+ public function set(array $commandMap): self
{
$this->commandMap = $commandMap;
return $this;
@@ -92,12 +73,10 @@ public function set(array $commandMap)
/**
* Sets the current workspace.
- *
- * @param int $workspace
*/
- public function setWorkspace($workspace)
+ public function setWorkspace(int $workspace): void
{
- $this->workspace = (int)$workspace;
+ $this->workspace = $workspace;
}
/**
@@ -110,10 +89,8 @@ public function getWorkspace(): int
/**
* Gets the element entity processor.
- *
- * @return ElementEntityProcessor
*/
- protected function getElementEntityProcessor()
+ protected function getElementEntityProcessor(): ElementEntityProcessor
{
if (!isset($this->elementEntityProcessor)) {
$this->elementEntityProcessor = GeneralUtility::makeInstance(ElementEntityProcessor::class);
@@ -124,10 +101,8 @@ protected function getElementEntityProcessor()
/**
* Processes the command map.
- *
- * @return CommandMap
*/
- public function process()
+ public function process(): self
{
$this->resolveWorkspacesSwapDependencies();
$this->resolveWorkspacesSetStageDependencies();
@@ -141,7 +116,7 @@ public function process()
* but not published with this request, are removed from the command map. Otherwise
* this would produce hanging record sets and lost references.
*/
- protected function resolveWorkspacesSwapDependencies()
+ protected function resolveWorkspacesSwapDependencies(): void
{
$scope = self::SCOPE_WorkspacesSwap;
$dependency = $this->getDependencyUtility($scope);
@@ -162,22 +137,18 @@ protected function resolveWorkspacesSwapDependencies()
/**
* Adds workspaces elements for swapping/publishing.
- *
- * @param string $table
- * @param int $liveId
*/
- protected function addWorkspacesSwapElements(DependencyResolver $dependency, $table, $liveId, array $properties)
+ protected function addWorkspacesSwapElements(DependencyResolver $dependency, string $table, int $liveId, array $properties): void
{
- $dependency->addElement($table, $properties['swapWith'], ['liveId' => $liveId, 'properties' => $properties]);
+ $dependency->addElement($table, (int)$properties['swapWith'], ['liveId' => $liveId, 'properties' => $properties]);
}
/**
* Invokes all items for staging with a callback method.
*
- * @param string $callbackMethod
* @param array $arguments Optional leading arguments for the callback method
*/
- protected function invokeWorkspacesSetStageItems($callbackMethod, array $arguments = [])
+ protected function invokeWorkspacesSetStageItems(string $callbackMethod, array $arguments = []): void
{
// Traverses the cmd[] array and fetches the accordant actions:
foreach ($this->commandMap as $table => $versionIdCollection) {
@@ -198,7 +169,7 @@ protected function invokeWorkspacesSetStageItems($callbackMethod, array $argumen
* Workspaces records that have children or (relative) parents which are versionized
* but not staged with this request, are removed from the command map.
*/
- protected function resolveWorkspacesSetStageDependencies()
+ protected function resolveWorkspacesSetStageDependencies(): void
{
$scope = self::SCOPE_WorkspacesSetStage;
$dependency = $this->getDependencyUtility($scope);
@@ -209,11 +180,8 @@ protected function resolveWorkspacesSetStageDependencies()
/**
* Adds workspaces elements for staging.
- *
- * @param string $table
- * @param int $versionId
*/
- protected function addWorkspacesSetStageElements(DependencyResolver $dependency, $table, $versionId, array $properties)
+ protected function addWorkspacesSetStageElements(DependencyResolver $dependency, string $table, int $versionId, array $properties): void
{
$dependency->addElement($table, $versionId, ['versionId' => $versionId, 'properties' => $properties]);
}
@@ -223,7 +191,7 @@ protected function addWorkspacesSetStageElements(DependencyResolver $dependency,
* Workspaces records that have children or (relative) parents which are versionized
* but not cleared/flushed with this request, are removed from the command map.
*/
- protected function resolveWorkspacesClearDependencies()
+ protected function resolveWorkspacesClearDependencies(): void
{
$scope = self::SCOPE_WorkspacesClear;
$dependency = $this->getDependencyUtility($scope);
@@ -242,15 +210,11 @@ protected function resolveWorkspacesClearDependencies()
/**
* Explodes id-lists in the command map for staging actions.
- *
- * @throws \RuntimeException
- * @param string $table
- * @param string $versionIdList
*/
- protected function explodeSetStage($table, $versionIdList, array $properties)
+ protected function explodeSetStage(string $table, string|int $versionIdList, array $properties): void
{
$extractedCommandMap = [];
- $versionIds = GeneralUtility::trimExplode(',', $versionIdList, true);
+ $versionIds = GeneralUtility::trimExplode(',', (string)$versionIdList, true);
if (count($versionIds) > 1) {
foreach ($versionIds as $versionId) {
if (isset($this->commandMap[$table][$versionId]['version'])) {
@@ -266,10 +230,8 @@ protected function explodeSetStage($table, $versionIdList, array $properties)
/**
* Applies the workspaces dependencies and removes incomplete structures or automatically
* completes them
- *
- * @param string $scope
*/
- protected function applyWorkspacesDependencies(DependencyResolver $dependency, $scope)
+ protected function applyWorkspacesDependencies(DependencyResolver $dependency, string $scope): void
{
$transformDependentElementsToUseLiveId = $this->getScopeData($scope, self::KEY_TransformDependentElementsToUseLiveId);
$elementsToBeVersioned = $dependency->getElements();
@@ -295,10 +257,8 @@ protected function applyWorkspacesDependencies(DependencyResolver $dependency, $
/**
* Updates the command map accordant to valid structures and takes care of the correct order.
- *
- * @param string $scope
*/
- protected function update(ElementEntity $intersectingElement, array $elements, $scope)
+ protected function update(ElementEntity $intersectingElement, array $elements, string $scope): void
{
$orderedCommandMap = [];
$commonProperties = [];
@@ -323,9 +283,9 @@ protected function update(ElementEntity $intersectingElement, array $elements, $
}
/**
- * Merges command map elements to the top of the current command map..
+ * Merges command map elements to the top of the current command map.
*/
- protected function mergeToTop(array $commandMap)
+ protected function mergeToTop(array $commandMap): void
{
ArrayUtility::mergeRecursiveWithOverrule($commandMap, $this->commandMap);
$this->commandMap = $commandMap;
@@ -334,19 +294,15 @@ protected function mergeToTop(array $commandMap)
/**
* Merges command map elements to the bottom of the current command map.
*/
- protected function mergeToBottom(array $commandMap)
+ protected function mergeToBottom(array $commandMap): void
{
ArrayUtility::mergeRecursiveWithOverrule($this->commandMap, $commandMap);
}
/**
* Removes an element from the command map.
- *
- * @param string $table
- * @param string $id
- * @param string $command (optional)
*/
- protected function remove($table, $id, $command = null)
+ protected function remove(string $table, int|string $id, string $command = null): void
{
if (is_string($command)) {
unset($this->commandMap[$table][$id][$command]);
@@ -357,30 +313,24 @@ protected function remove($table, $id, $command = null)
/**
* Callback to get the liveId of a dependent element.
- *
- * @return int
*/
- protected function getElementLiveIdCallback(ElementEntity $element)
+ protected function getElementLiveIdCallback(ElementEntity $element): int
{
return $element->getDataValue('liveId');
}
/**
* Callback to get the real id of a dependent element.
- *
- * @return int
*/
- protected function getElementIdCallback(ElementEntity $element)
+ protected function getElementIdCallback(ElementEntity $element): int
{
return $element->getId();
}
/**
* Callback to get the specific properties of a dependent element for swapping/publishing.
- *
- * @return array
*/
- protected function getElementSwapPropertiesCallback(ElementEntity $element)
+ protected function getElementSwapPropertiesCallback(ElementEntity $element): array
{
return [
'swapWith' => $element->getId(),
@@ -404,10 +354,8 @@ protected function getCommonClearPropertiesCallback(ElementEntity $element)
/**
* Callback to get common properties of dependent elements for swapping/publishing.
- *
- * @return array
*/
- protected function getCommonSwapPropertiesCallback(ElementEntity $element)
+ protected function getCommonSwapPropertiesCallback(ElementEntity $element): array
{
$commonSwapProperties = [];
$elementProperties = $element->getDataValue('properties');
@@ -426,20 +374,16 @@ protected function getCommonSwapPropertiesCallback(ElementEntity $element)
/**
* Callback to get the specific properties of a dependent element for staging.
- *
- * @return array
*/
- protected function getElementSetStagePropertiesCallback(ElementEntity $element)
+ protected function getElementSetStagePropertiesCallback(ElementEntity $element): array
{
return $this->getCommonSetStagePropertiesCallback($element);
}
/**
* Callback to get common properties of dependent elements for staging.
- *
- * @return array
*/
- protected function getCommonSetStagePropertiesCallback(ElementEntity $element)
+ protected function getCommonSetStagePropertiesCallback(ElementEntity $element): array
{
$commonSetStageProperties = [];
$elementProperties = $element->getDataValue('properties');
@@ -482,9 +426,9 @@ protected function getDependencyUtility(string $scope): DependencyResolver
/**
* Constructs the scope settings.
- * Currently the scopes for swapping/publishing and staging are available.
+ * Currently, the scopes for swapping/publishing and staging are available.
*/
- protected function constructScopes()
+ protected function constructScopes(): void
{
$this->scopes = [
// settings for publishing and swapping:
@@ -544,12 +488,9 @@ protected function constructScopes()
/**
* Gets data for a particular scope.
*
- * @throws \RuntimeException
* @param string $scope Scope identifier
- * @param string $key
- * @return string
*/
- protected function getScopeData($scope, $key)
+ protected function getScopeData(string $scope, string $key): null|bool|string
{
if (!isset($this->scopes[$scope])) {
throw new \RuntimeException('Scope "' . $scope . '" is not defined.', 1289342187);
@@ -559,11 +500,8 @@ protected function getScopeData($scope, $key)
/**
* Gets a new callback to be used in the dependency resolver utility.
- *
- * @param string $method
- * @return EventCallback
*/
- protected function getDependencyCallback($method, array $targetArguments = [])
+ protected function getDependencyCallback(string $method, array $targetArguments = []): EventCallback
{
return GeneralUtility::makeInstance(
EventCallback::class,
@@ -575,11 +513,8 @@ protected function getDependencyCallback($method, array $targetArguments = [])
/**
* Processes a local callback inside this object.
- *
- * @param string $method
- * @return mixed
*/
- protected function processCallback($method, array $callbackArguments)
+ protected function processCallback(string $method, array $callbackArguments): mixed
{
return $this->$method(...$callbackArguments);
}
diff --git a/typo3/sysext/workspaces/Classes/Dependency/DependencyEntityFactory.php b/typo3/sysext/workspaces/Classes/Dependency/DependencyEntityFactory.php
index 471dd3822473..4828d8e94826 100644
--- a/typo3/sysext/workspaces/Classes/Dependency/DependencyEntityFactory.php
+++ b/typo3/sysext/workspaces/Classes/Dependency/DependencyEntityFactory.php
@@ -1,5 +1,7 @@
__toString();
@@ -52,11 +42,8 @@ public function getElement($table, $id, array $data, DependencyResolver $depende
/**
* Gets and registers a new reference.
- *
- * @param string $field
- * @return ReferenceEntity
*/
- public function getReference(ElementEntity $element, $field)
+ public function getReference(ElementEntity $element, string $field): ReferenceEntity
{
$referenceName = $element->__toString() . '.' . $field;
if (!isset($this->references[$referenceName][$field])) {
@@ -68,15 +55,10 @@ public function getReference(ElementEntity $element, $field)
/**
* Gets and registers a new reference.
*
- * @param string $table
- * @param int $id
- * @param string $field
- * @param array $data (optional)
- * @return ReferenceEntity
* @see getElement
* @see getReference
*/
- public function getReferencedElement($table, $id, $field, array $data, DependencyResolver $dependency)
+ public function getReferencedElement(string $table, int $id, string $field, array $data, DependencyResolver $dependency): ReferenceEntity
{
return $this->getReference($this->getElement($table, $id, $data, $dependency), $field);
}
diff --git a/typo3/sysext/workspaces/Classes/Dependency/DependencyResolver.php b/typo3/sysext/workspaces/Classes/Dependency/DependencyResolver.php
index 4afd8a935591..5b0011c9a090 100644
--- a/typo3/sysext/workspaces/Classes/Dependency/DependencyResolver.php
+++ b/typo3/sysext/workspaces/Classes/Dependency/DependencyResolver.php
@@ -1,5 +1,7 @@
workspace = (int)$workspace;
+ $this->workspace = $workspace;
}
/**
* Gets the current workspace.
- *
- * @return int
*/
- public function getWorkspace()
+ public function getWorkspace(): int
{
return $this->workspace;
}
/**
* Sets a callback for a particular event.
- *
- * @param string $eventName
- * @return DependencyResolver
*/
- public function setEventCallback($eventName, EventCallback $callback)
+ public function setEventCallback(string $eventName, EventCallback $callback): self
{
$this->eventCallbacks[$eventName] = $callback;
return $this;
@@ -86,12 +58,8 @@ public function setEventCallback($eventName, EventCallback $callback)
/**
* Executes a registered callback (if any) for a particular event.
- *
- * @param string $eventName
- * @param object $caller
- * @return mixed
*/
- public function executeEventCallback($eventName, $caller, array $callerArguments = [])
+ public function executeEventCallback(string $eventName, object $caller, array $callerArguments = []): mixed
{
if (isset($this->eventCallbacks[$eventName])) {
/** @var EventCallback $callback */
@@ -103,11 +71,8 @@ public function executeEventCallback($eventName, $caller, array $callerArguments
/**
* Sets the condition that outermost parents required at least one child or parent reference.
- *
- * @param bool $outerMostParentsRequireReferences
- * @return DependencyResolver
*/
- public function setOuterMostParentsRequireReferences($outerMostParentsRequireReferences)
+ public function setOuterMostParentsRequireReferences(bool $outerMostParentsRequireReferences): self
{
$this->outerMostParentsRequireReferences = (bool)$outerMostParentsRequireReferences;
return $this;
@@ -115,12 +80,8 @@ public function setOuterMostParentsRequireReferences($outerMostParentsRequireRef
/**
* Adds an element to be checked for dependent references.
- *
- * @param string $table
- * @param int $id
- * @return ElementEntity
*/
- public function addElement($table, $id, array $data = [])
+ public function addElement(string $table, int $id, array $data = []): ElementEntity
{
$element = $this->getFactory()->getElement($table, $id, $data, $this);
$elementName = $element->__toString();
@@ -131,9 +92,9 @@ public function addElement($table, $id, array $data = [])
/**
* Gets the outermost parents that define complete dependent structure each.
*
- * @return array|ElementEntity[]
+ * @return ElementEntity[]
*/
- public function getOuterMostParents()
+ public function getOuterMostParents(): array
{
if (!isset($this->outerMostParents)) {
$this->outerMostParents = [];
@@ -148,7 +109,7 @@ public function getOuterMostParents()
/**
* Processes and registers the outermost parents accordant to the registered elements.
*/
- protected function processOuterMostParent(ElementEntity $element)
+ protected function processOuterMostParent(ElementEntity $element): void
{
if ($this->outerMostParentsRequireReferences === false || $element->hasReferences()) {
$outerMostParent = $element->getOuterMostParent();
@@ -163,11 +124,8 @@ protected function processOuterMostParent(ElementEntity $element)
/**
* Gets all nested elements (including the parent) of a particular outermost parent element.
- *
- * @throws \RuntimeException
- * @return array
*/
- public function getNestedElements(ElementEntity $outerMostParent)
+ public function getNestedElements(ElementEntity $outerMostParent): array
{
$outerMostParentName = $outerMostParent->__toString();
if (!isset($this->outerMostParents[$outerMostParentName])) {
@@ -179,20 +137,16 @@ public function getNestedElements(ElementEntity $outerMostParent)
/**
* Gets the registered elements.
- *
- * @return array
*/
- public function getElements()
+ public function getElements(): array
{
return $this->elements;
}
/**
* Gets an instance of the factory to keep track of element or reference entities.
- *
- * @return DependencyEntityFactory
*/
- public function getFactory()
+ public function getFactory(): DependencyEntityFactory
{
if (!isset($this->factory)) {
$this->factory = GeneralUtility::makeInstance(DependencyEntityFactory::class);
diff --git a/typo3/sysext/workspaces/Classes/Dependency/ElementEntity.php b/typo3/sysext/workspaces/Classes/Dependency/ElementEntity.php
index 86cf1f53f3b1..2c48398839a0 100644
--- a/typo3/sysext/workspaces/Classes/Dependency/ElementEntity.php
+++ b/typo3/sysext/workspaces/Classes/Dependency/ElementEntity.php
@@ -1,5 +1,7 @@
skip';
- /**
- * @var bool
- */
- protected $invalid = false;
-
- /**
- * @var string
- */
- protected $table;
-
- /**
- * @var int
- */
- protected $id;
-
- /**
- * @var array
- */
- protected $data;
-
- /**
- * @var array
- */
- protected $record;
-
- /**
- * @var DependencyResolver
- */
- protected $dependency;
-
- /**
- * @var array|null
- */
- protected $children;
-
- /**
- * @var array|null
- */
- protected $parents;
-
- /**
- * @var bool
- */
- protected $traversingParents = false;
-
- /**
- * @var ElementEntity|false|null
- */
- protected $outerMostParent;
+ protected bool $invalid = false;
+ protected string $table;
+ protected int $id;
+ protected array $data;
+ protected array $record;
+ protected DependencyResolver $dependency;
+ protected ?array $children;
+ protected ?array $parents;
+ protected ElementEntity|false|null $outerMostParent;
- /**
- * @var array|null
- */
- protected $nestedChildren;
+ protected ?array $nestedChildren;
- /**
- * Creates this object.
- *
- * @param string $table
- * @param int $id
- * @param array $data (optional)
- */
- public function __construct($table, $id, array $data, DependencyResolver $dependency)
+ public function __construct(string $table, int $id, array $data, DependencyResolver $dependency)
{
$this->table = $table;
- $this->id = (int)$id;
+ $this->id = $id;
$this->data = $data;
$this->dependency = $dependency;
$this->dependency->executeEventCallback(self::EVENT_Construct, $this);
}
- /**
- * @param bool $invalid
- */
- public function setInvalid($invalid)
+ public function setInvalid(bool $invalid): void
{
- $this->invalid = (bool)$invalid;
+ $this->invalid = $invalid;
}
- /**
- * @return bool
- */
- public function isInvalid()
+ public function isInvalid(): bool
{
return $this->invalid;
}
/**
* Gets the table.
- *
- * @return string
*/
- public function getTable()
+ public function getTable(): string
{
return $this->table;
}
/**
* Gets the id.
- *
- * @return int
*/
- public function getId()
+ public function getId(): int
{
return $this->id;
}
/**
* Sets the id.
- *
- * @param int $id
*/
- public function setId($id)
+ public function setId(int $id): void
{
- $this->id = (int)$id;
+ $this->id = $id;
}
/**
* Gets the data.
- *
- * @return array
*/
- public function getData()
+ public function getData(): array
{
return $this->data;
}
/**
* Gets a value for a particular key from the data.
- *
- * @param string $key
- * @return mixed
*/
- public function getDataValue($key)
+ public function getDataValue(string $key): mixed
{
$result = null;
if ($this->hasDataValue($key)) {
@@ -175,42 +110,32 @@ public function getDataValue($key)
/**
* Sets a value for a particular key in the data.
- *
- * @param string $key
- * @param mixed $value
*/
- public function setDataValue($key, $value)
+ public function setDataValue(string $key, mixed $value): void
{
$this->data[$key] = $value;
}
/**
* Determines whether a particular key holds data.
- *
- * @param string $key
- * @return bool
*/
- public function hasDataValue($key)
+ public function hasDataValue(string $key): bool
{
return isset($this->data[$key]);
}
/**
* Converts this object for string representation.
- *
- * @return string
*/
- public function __toString()
+ public function __toString(): string
{
return self::getIdentifier($this->table, $this->id);
}
/**
* Gets the parent dependency object.
- *
- * @return DependencyResolver
*/
- public function getDependency()
+ public function getDependency(): DependencyResolver
{
return $this->dependency;
}
@@ -218,9 +143,9 @@ public function getDependency()
/**
* Gets all child references.
*
- * @return array|ReferenceEntity[]
+ * @return ReferenceEntity[]
*/
- public function getChildren()
+ public function getChildren(): array
{
if (!isset($this->children)) {
$this->children = [];
@@ -280,9 +205,9 @@ public function getChildren()
/**
* Gets all parent references.
*
- * @return array|ReferenceEntity[]
+ * @return ReferenceEntity[]
*/
- public function getParents()
+ public function getParents(): array
{
if (!isset($this->parents)) {
$this->parents = [];
@@ -338,20 +263,16 @@ public function getParents()
/**
* Determines whether there are child or parent references.
- *
- * @return bool
*/
- public function hasReferences()
+ public function hasReferences(): bool
{
return !empty($this->getChildren()) || !empty($this->getParents());
}
/**
* Gets the outermost parent element.
- *
- * @return ElementEntity|bool
*/
- public function getOuterMostParent()
+ public function getOuterMostParent(): false|ElementEntity
{
if (!isset($this->outerMostParent)) {
$parents = $this->getParents();
@@ -378,9 +299,9 @@ public function getOuterMostParent()
/**
* Gets nested children accumulated.
*
- * @return array|ReferenceEntity[]
+ * @return ReferenceEntity[]
*/
- public function getNestedChildren()
+ public function getNestedChildren(): array
{
if (!isset($this->nestedChildren)) {
$this->nestedChildren = [];
@@ -395,22 +316,16 @@ public function getNestedChildren()
/**
* Converts the object for string representation.
- *
- * @param string $table
- * @param int $id
- * @return string
*/
- public static function getIdentifier($table, $id)
+ public static function getIdentifier(string $table, int $id): string
{
return $table . ':' . $id;
}
/**
* Gets the database record of this element.
- *
- * @return array
*/
- public function getRecord()
+ public function getRecord(): array
{
if (empty($this->record['uid']) || (int)$this->record['uid'] !== $this->getId()) {
$this->record = [];
diff --git a/typo3/sysext/workspaces/Classes/Dependency/ElementEntityProcessor.php b/typo3/sysext/workspaces/Classes/Dependency/ElementEntityProcessor.php
index f7edf3131af0..72c1f4a63c71 100644
--- a/typo3/sysext/workspaces/Classes/Dependency/ElementEntityProcessor.php
+++ b/typo3/sysext/workspaces/Classes/Dependency/ElementEntityProcessor.php
@@ -1,5 +1,7 @@
workspace = (int)$workspace;
+ $this->workspace = $workspace;
}
/**
* Gets the current workspace.
- *
- * @return int
*/
- public function getWorkspace()
+ public function getWorkspace(): int
{
return $this->workspace;
}
- /**
- * @return DataHandler
- */
- public function getDataHandler()
+ public function getDataHandler(): DataHandler
{
if (!isset($this->dataHandler)) {
$this->dataHandler = GeneralUtility::makeInstance(DataHandler::class);
@@ -69,13 +57,11 @@ public function getDataHandler()
/**
* Transforms dependent elements to use the liveId as array key.
*
- * @param array|ElementEntity[] $elements
- * @return array
+ * @param ElementEntity[] $elements
*/
- public function transformDependentElementsToUseLiveId(array $elements)
+ public function transformDependentElementsToUseLiveId(array $elements): array
{
$transformedElements = [];
- /** @var ElementEntity $element */
foreach ($elements as $element) {
$elementName = ElementEntity::getIdentifier($element->getTable(), $element->getDataValue('liveId'));
$transformedElements[$elementName] = $element;
@@ -86,10 +72,9 @@ public function transformDependentElementsToUseLiveId(array $elements)
/**
* Callback to determine whether a new child reference shall be considered in the dependency resolver utility.
*
- * @param string $eventName
* @return string|null Skip response (if required)
*/
- public function createNewDependentElementChildReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, $eventName)
+ public function createNewDependentElementChildReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, string $eventName): ?string
{
// skip children in case ancestor is invalid
if ($caller->isInvalid()) {
@@ -106,10 +91,9 @@ public function createNewDependentElementChildReferenceCallback(array $callerArg
/**
* Callback to determine whether a new parent reference shall be considered in the dependency resolver utility.
*
- * @param string $eventName
* @return string|null Skip response (if required)
*/
- public function createNewDependentElementParentReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, $eventName)
+ public function createNewDependentElementParentReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, string $eventName): ?string
{
$fieldConfiguration = BackendUtility::getTcaFieldConfiguration($callerArguments['table'], $callerArguments['field']);
$inlineFieldType = $this->getDataHandler()->getRelationFieldType($fieldConfiguration);
@@ -123,10 +107,9 @@ public function createNewDependentElementParentReferenceCallback(array $callerAr
* Callback to determine whether a new child reference shall be considered in the dependency resolver utility.
* Only elements that are a delete placeholder are considered.
*
- * @param string $eventName
* @return string|null Skip response (if required)
*/
- public function createClearDependentElementChildReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, $eventName)
+ public function createClearDependentElementChildReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, string $eventName): ?string
{
$response = $this->createNewDependentElementChildReferenceCallback($callerArguments, $targetArgument, $caller, $eventName);
if (empty($response)) {
@@ -142,10 +125,9 @@ public function createClearDependentElementChildReferenceCallback(array $callerA
* Callback to determine whether a new parent reference shall be considered in the dependency resolver utility.
* Only elements that are a delete placeholder are considered.
*
- * @param string $eventName
* @return string|null Skip response (if required)
*/
- public function createClearDependentElementParentReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, $eventName)
+ public function createClearDependentElementParentReferenceCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, string $eventName): ?string
{
$response = $this->createNewDependentElementParentReferenceCallback($callerArguments, $targetArgument, $caller, $eventName);
if (empty($response)) {
@@ -159,11 +141,8 @@ public function createClearDependentElementParentReferenceCallback(array $caller
/**
* Callback to add additional data to new elements created in the dependency resolver utility.
- *
- * @throws \RuntimeException
- * @param string $eventName
*/
- public function createNewDependentElementCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, $eventName)
+ public function createNewDependentElementCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, string $eventName): void
{
if (!BackendUtility::isTableWorkspaceEnabled($caller->getTable())) {
$caller->setInvalid(true);
diff --git a/typo3/sysext/workspaces/Classes/Dependency/EventCallback.php b/typo3/sysext/workspaces/Classes/Dependency/EventCallback.php
index e7a7655c2af1..7f6a2a125a9d 100644
--- a/typo3/sysext/workspaces/Classes/Dependency/EventCallback.php
+++ b/typo3/sysext/workspaces/Classes/Dependency/EventCallback.php
@@ -1,5 +1,7 @@
object = $object;
$this->method = $method;
@@ -52,12 +36,8 @@ public function __construct($object, $method, array $targetArguments = [])
/**
* Executes the callback.
- *
- * @param object $caller
- * @param string $eventName
- * @return mixed
*/
- public function execute(array $callerArguments, $caller, $eventName)
+ public function execute(array $callerArguments, object $caller, string $eventName): mixed
{
$callable = [$this->object, $this->method];
if (is_callable($callable)) {
diff --git a/typo3/sysext/workspaces/Classes/Dependency/ReferenceEntity.php b/typo3/sysext/workspaces/Classes/Dependency/ReferenceEntity.php
index f93f0ccbb8e9..da2e5e4d85a8 100644
--- a/typo3/sysext/workspaces/Classes/Dependency/ReferenceEntity.php
+++ b/typo3/sysext/workspaces/Classes/Dependency/ReferenceEntity.php
@@ -1,5 +1,7 @@
element = $element;
$this->field = $field;
@@ -43,30 +33,24 @@ public function __construct(ElementEntity $element, $field)
/**
* Gets the elements.
- *
- * @return ElementEntity
*/
- public function getElement()
+ public function getElement(): ElementEntity
{
return $this->element;
}
/**
* Gets the field.
- *
- * @return string
*/
- public function getField()
+ public function getField(): string
{
return $this->field;
}
/**
* Converts this object for string representation.
- *
- * @return string
*/
- public function __toString()
+ public function __toString(): string
{
return $this->element . '.' . $this->field;
}
diff --git a/typo3/sysext/workspaces/Classes/Domain/Model/CombinedRecord.php b/typo3/sysext/workspaces/Classes/Domain/Model/CombinedRecord.php
index 37492b7eed63..b14a5a110d67 100644
--- a/typo3/sysext/workspaces/Classes/Domain/Model/CombinedRecord.php
+++ b/typo3/sysext/workspaces/Classes/Domain/Model/CombinedRecord.php
@@ -1,5 +1,7 @@
setTable($table);
$this->setLiveRecord($liveRecord);
@@ -81,30 +65,24 @@ public function __construct($table, DatabaseRecord $liveRecord, DatabaseRecord $
/**
* Gets the name of the database table.
- *
- * @return string
*/
- public function getTable()
+ public function getTable(): string
{
return $this->table;
}
/**
* Sets the name of the database table.
- *
- * @param string $table
*/
- public function setTable($table)
+ public function setTable(string $table): void
{
$this->table = $table;
}
/**
* Gets the live-record object.
- *
- * @return DatabaseRecord
*/
- public function getLiveRecord()
+ public function getLiveRecord(): DatabaseRecord
{
return $this->liveRecord;
}
@@ -112,17 +90,15 @@ public function getLiveRecord()
/**
* Sets the live-record object.
*/
- public function setLiveRecord(DatabaseRecord $liveRecord)
+ public function setLiveRecord(DatabaseRecord $liveRecord): void
{
$this->liveRecord = $liveRecord;
}
/**
* Gets the version-record object.
- *
- * @return DatabaseRecord
*/
- public function getVersionRecord()
+ public function getVersionRecord(): DatabaseRecord
{
return $this->versionRecord;
}
@@ -130,27 +106,23 @@ public function getVersionRecord()
/**
* Sets the version-record object.
*/
- public function setVersionRecord(DatabaseRecord $versionRecord)
+ public function setVersionRecord(DatabaseRecord $versionRecord): void
{
$this->versionRecord = $versionRecord;
}
/**
* Gets the id of the live-record.
- *
- * @return int
*/
- public function getLiveId()
+ public function getLiveId(): int
{
return $this->getLiveRecord()->getUid();
}
/**
* Gets the id of version-record.
- *
- * @return int
*/
- public function getVersiondId()
+ public function getVersiondId(): int
{
return $this->getVersionRecord()->getUid();
}
diff --git a/typo3/sysext/workspaces/Classes/Domain/Model/DatabaseRecord.php b/typo3/sysext/workspaces/Classes/Domain/Model/DatabaseRecord.php
index a67f9ca625ab..63cbdb360cd9 100644
--- a/typo3/sysext/workspaces/Classes/Domain/Model/DatabaseRecord.php
+++ b/typo3/sysext/workspaces/Classes/Domain/Model/DatabaseRecord.php
@@ -1,5 +1,7 @@
setTable($table);
$this->setUid($uid);
@@ -78,50 +62,40 @@ public function __construct($table, $uid, array $row = null)
/**
* Gets the name of the database table.
- *
- * @return string
*/
- public function getTable()
+ public function getTable(): string
{
return $this->table;
}
/**
* Sets the name of the database table.
- *
- * @param string $table
*/
- public function setTable($table)
+ public function setTable(string $table): void
{
$this->table = $table;
}
/**
* Gets the id of the database record row.
- *
- * @return int
*/
- public function getUid()
+ public function getUid(): int
{
return $this->uid;
}
/**
* Sets the id of the database record row.
- *
- * @param int $uid
*/
- public function setUid($uid)
+ public function setUid(int $uid): void
{
- $this->uid = (int)$uid;
+ $this->uid = $uid;
}
/**
* Gets the database record row.
- *
- * @return array
*/
- public function getRow()
+ public function getRow(): array
{
$this->loadRow();
return $this->row;
@@ -130,17 +104,15 @@ public function getRow()
/**
* Sets the database record row.
*/
- public function setRow(array $row)
+ public function setRow(array $row): void
{
$this->row = $row;
}
/**
* Gets the record identifier (table:id).
- *
- * @return string
*/
- public function getIdentifier()
+ public function getIdentifier(): string
{
return implode(':', [$this->getTable(), $this->getUid()]);
}
diff --git a/typo3/sysext/workspaces/Classes/Domain/Record/AbstractRecord.php b/typo3/sysext/workspaces/Classes/Domain/Record/AbstractRecord.php
index 8867bf881cc0..b4d49954a0c9 100644
--- a/typo3/sysext/workspaces/Classes/Domain/Record/AbstractRecord.php
+++ b/typo3/sysext/workspaces/Classes/Domain/Record/AbstractRecord.php
@@ -1,5 +1,7 @@
getQueryBuilderForTable($tableName);
$queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
@@ -68,34 +67,22 @@ public function __construct(array $record)
$this->record = $record;
}
- /**
- * @return string
- */
- public function __toString()
+ public function __toString(): string
{
return (string)$this->getUid();
}
- /**
- * @return int
- */
- public function getUid()
+ public function getUid(): int
{
return (int)$this->record['uid'];
}
- /**
- * @return string
- */
- public function getTitle()
+ public function getTitle(): string
{
return (string)$this->record['title'];
}
- /**
- * @return StagesService
- */
- protected function getStagesService()
+ protected function getStagesService(): StagesService
{
return GeneralUtility::makeInstance(StagesService::class);
}
diff --git a/typo3/sysext/workspaces/Classes/Domain/Record/StageRecord.php b/typo3/sysext/workspaces/Classes/Domain/Record/StageRecord.php
index e1d6a6551ab9..a2297b5c54d6 100644
--- a/typo3/sysext/workspaces/Classes/Domain/Record/StageRecord.php
+++ b/typo3/sysext/workspaces/Classes/Domain/Record/StageRecord.php
@@ -1,5 +1,7 @@
getStage($uid);
}
- /**
- * @param int $uid
- * @return StageRecord
- */
- public static function build(WorkspaceRecord $workspace, $uid, array $record = null)
+ public static function build(WorkspaceRecord $workspace, int $uid, array $record = null): StageRecord
{
if (empty($record)) {
$record = static::fetch('sys_workspace_stage', $uid);
@@ -82,34 +50,22 @@ public function __construct(WorkspaceRecord $workspace, array $record)
$this->workspace = $workspace;
}
- /**
- * @return WorkspaceRecord
- */
- public function getWorkspace()
+ public function getWorkspace(): WorkspaceRecord
{
return $this->workspace;
}
- /**
- * @return StageRecord|null
- */
- public function getPrevious()
+ public function getPrevious(): ?StageRecord
{
return $this->getWorkspace()->getPreviousStage($this->getUid());
}
- /**
- * @return StageRecord|null
- */
- public function getNext()
+ public function getNext(): ?StageRecord
{
return $this->getWorkspace()->getNextStage($this->getUid());
}
- /**
- * @return int
- */
- public function determineOrder(StageRecord $stageRecord)
+ public function determineOrder(StageRecord $stageRecord): int
{
if ($this->getUid() === $stageRecord->getUid()) {
return 0;
@@ -125,10 +81,8 @@ public function determineOrder(StageRecord $stageRecord)
/**
* Determines whether $this is in a previous stage compared to $stageRecord.
- *
- * @return bool
*/
- public function isPreviousTo(StageRecord $stageRecord)
+ public function isPreviousTo(StageRecord $stageRecord): bool
{
$current = $stageRecord;
while ($previous = $current->getPrevious()) {
@@ -142,10 +96,8 @@ public function isPreviousTo(StageRecord $stageRecord)
/**
* Determines whether $this is in a later stage compared to $stageRecord.
- *
- * @return bool
*/
- public function isNextTo(StageRecord $stageRecord)
+ public function isNextTo(StageRecord $stageRecord): bool
{
$current = $stageRecord;
while ($next = $current->getNext()) {
@@ -157,10 +109,7 @@ public function isNextTo(StageRecord $stageRecord)
return false;
}
- /**
- * @return string
- */
- public function getDefaultComment()
+ public function getDefaultComment(): string
{
$defaultComment = '';
if (isset($this->record['default_mailcomment'])) {
@@ -169,90 +118,57 @@ public function getDefaultComment()
return $defaultComment;
}
- /**
- * @param bool $internal
- */
- public function setInternal($internal = true)
+ public function setInternal(bool $internal): void
{
- $this->internal = (bool)$internal;
+ $this->internal = $internal;
}
- /**
- * @return bool
- */
- public function isInternal()
+ public function isInternal(): bool
{
return $this->internal;
}
- /**
- * @return bool
- */
- public function isEditStage()
+ public function isEditStage(): bool
{
return $this->getUid() === StagesService::STAGE_EDIT_ID;
}
- /**
- * @return bool
- */
- public function isPublishStage()
+ public function isPublishStage(): bool
{
return $this->getUid() === StagesService::STAGE_PUBLISH_ID;
}
- /**
- * @return bool
- */
- public function isExecuteStage()
+ public function isExecuteStage(): bool
{
return $this->getUid() === StagesService::STAGE_PUBLISH_EXECUTE_ID;
}
- /**
- * @return bool
- */
- public function isDialogEnabled()
+ public function isDialogEnabled(): bool
{
return ((int)$this->record['allow_notificaton_settings'] & 1) > 0;
}
- /**
- * @return bool
- */
- public function isPreselectionChangeable()
+ public function isPreselectionChangeable(): bool
{
return ((int)$this->record['allow_notificaton_settings'] & 2) > 0;
}
- /**
- * @return bool
- */
- public function areOwnersPreselected()
+ public function areOwnersPreselected(): bool
{
return ((int)$this->record['notification_preselection'] & 1) > 0;
}
- /**
- * @return bool
- */
- public function areMembersPreselected()
+ public function areMembersPreselected(): bool
{
return ((int)$this->record['notification_preselection'] & 2) > 0;
}
- /**
- * @return bool
- */
- public function areEditorsPreselected()
+ public function areEditorsPreselected(): bool
{
return ((int)$this->record['notification_preselection'] & 4) > 0;
}
- /**
- * @return bool
- */
- public function areResponsiblePersonsPreselected()
+ public function areResponsiblePersonsPreselected(): bool
{
return ((int)$this->record['notification_preselection'] & 8) > 0;
}
@@ -262,10 +178,7 @@ public function hasDefaultRecipients(): bool
return $this->record['notification_defaults'] !== '';
}
- /**
- * @return bool
- */
- public function hasPreselection()
+ public function hasPreselection(): bool
{
return
$this->areOwnersPreselected()
@@ -276,10 +189,7 @@ public function hasPreselection()
;
}
- /**
- * @return array
- */
- public function getResponsiblePersons()
+ public function getResponsiblePersons(): array
{
if (!isset($this->responsiblePersons)) {
$this->responsiblePersons = [];
@@ -290,10 +200,7 @@ public function getResponsiblePersons()
return $this->responsiblePersons;
}
- /**
- * @return array
- */
- public function getDefaultRecipients()
+ public function getDefaultRecipients(): array
{
if (!isset($this->defaultRecipients)) {
$this->defaultRecipients = $this->getStagesService()->resolveBackendUserIds($this->record['notification_defaults']);
@@ -303,10 +210,8 @@ public function getDefaultRecipients()
/**
* Gets all recipients (backend user ids).
- *
- * @return array
*/
- public function getAllRecipients()
+ public function getAllRecipients(): array
{
if (!isset($this->allRecipients)) {
$allRecipients = $this->getDefaultRecipients();
@@ -330,7 +235,7 @@ public function getAllRecipients()
/**
* @return int[]
*/
- public function getPreselectedRecipients()
+ public function getPreselectedRecipients(): array
{
if (!isset($this->preselectedRecipients)) {
$preselectedRecipients = $this->getDefaultRecipients();
@@ -351,10 +256,7 @@ public function getPreselectedRecipients()
return $this->preselectedRecipients;
}
- /**
- * @return bool
- */
- public function isAllowed()
+ public function isAllowed(): bool
{
return
$this->isEditStage()
diff --git a/typo3/sysext/workspaces/Classes/Domain/Record/WorkspaceRecord.php b/typo3/sysext/workspaces/Classes/Domain/Record/WorkspaceRecord.php
index 5011df5ec9a7..5881a52c2405 100644
--- a/typo3/sysext/workspaces/Classes/Domain/Record/WorkspaceRecord.php
+++ b/typo3/sysext/workspaces/Classes/Domain/Record/WorkspaceRecord.php
@@ -1,5 +1,7 @@
[
'name' => 'edit',
'label' => 'LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_editing',
@@ -43,35 +42,21 @@ class WorkspaceRecord extends AbstractRecord
],
];
- /**
- * @var array
- */
- protected $internalStageFieldNames = [
+ protected array $internalStageFieldNames = [
'notification_defaults',
'notification_preselection',
'allow_notificaton_settings',
];
- /**
- * @var array|null
- */
- protected $owners;
-
- /**
- * @var array|null
- */
- protected $members;
+ protected ?array $owners;
+ protected ?array $members;
/**
* @var StageRecord[]|null
*/
- protected $stages;
+ protected ?array $stages;
- /**
- * @param int $uid
- * @return WorkspaceRecord
- */
- public static function get($uid, array $record = null)
+ public static function get(int $uid, array $record = null): WorkspaceRecord
{
if (empty($uid)) {
$record = [];
@@ -82,10 +67,7 @@ public static function get($uid, array $record = null)
return GeneralUtility::makeInstance(self::class, $record);
}
- /**
- * @return array
- */
- public function getOwners()
+ public function getOwners(): array
{
if (!isset($this->owners)) {
$this->owners = $this->getStagesService()->resolveBackendUserIds($this->record['adminusers']);
@@ -93,10 +75,7 @@ public function getOwners()
return $this->owners;
}
- /**
- * @return array
- */
- public function getMembers()
+ public function getMembers(): array
{
if (!isset($this->members)) {
$this->members = $this->getStagesService()->resolveBackendUserIds($this->record['members']);
@@ -107,7 +86,7 @@ public function getMembers()
/**
* @return StageRecord[]
*/
- public function getStages()
+ public function getStages(): array
{
if (!isset($this->stages)) {
$this->stages = [];
@@ -139,13 +118,8 @@ public function getStages()
return $this->stages;
}
- /**
- * @param int $stageId
- * @return StageRecord|null
- */
- public function getStage($stageId)
+ public function getStage(int $stageId): ?StageRecord
{
- $stageId = (int)$stageId;
$this->getStages();
if (!isset($this->stages[$stageId])) {
return null;
@@ -153,13 +127,8 @@ public function getStage($stageId)
return $this->stages[$stageId];
}
- /**
- * @param int $stageId
- * @return StageRecord|null
- */
- public function getPreviousStage($stageId)
+ public function getPreviousStage(int $stageId): ?StageRecord
{
- $stageId = (int)$stageId;
$stageIds = array_keys($this->getStages());
$stageIndex = array_search($stageId, $stageIds);
@@ -172,13 +141,8 @@ public function getPreviousStage($stageId)
return $this->stages[$previousStageId];
}
- /**
- * @param int $stageId
- * @return StageRecord|null
- */
- public function getNextStage($stageId)
+ public function getNextStage(int $stageId): ?StageRecord
{
- $stageId = (int)$stageId;
$stageIds = array_keys($this->getStages());
$stageIndex = array_search($stageId, $stageIds);
@@ -190,20 +154,13 @@ public function getNextStage($stageId)
return $this->stages[$nextStageId];
}
- protected function addStage(StageRecord $stage)
+ protected function addStage(StageRecord $stage): void
{
$this->stages[$stage->getUid()] = $stage;
}
- /**
- * @param int $stageId
- * @return StageRecord
- * @throws \RuntimeException
- */
- protected function createInternalStage($stageId)
+ protected function createInternalStage(int $stageId): StageRecord
{
- $stageId = (int)$stageId;
-
if (!isset($this->internalStages[$stageId])) {
throw new \RuntimeException('Invalid internal stage "' . $stageId . '"', 1476048246);
}
diff --git a/typo3/sysext/workspaces/Classes/Hook/BackendUtilityHook.php b/typo3/sysext/workspaces/Classes/Hook/BackendUtilityHook.php
index 8b1b42a21408..9ade13c69bac 100644
--- a/typo3/sysext/workspaces/Classes/Hook/BackendUtilityHook.php
+++ b/typo3/sysext/workspaces/Classes/Hook/BackendUtilityHook.php
@@ -78,7 +78,7 @@ public function displayEditingStagedElementInformation(ModifyEditFormUserAccessE
}
$stages = GeneralUtility::makeInstance(StagesService::class);
- $stageName = $stages->getStageTitle($record['t3ver_stage']);
+ $stageName = $stages->getStageTitle((int)$record['t3ver_stage']);
$editingName = $stages->getStageTitle(StagesService::STAGE_EDIT_ID);
$message = ($languageService = $this->getLanguageService()) !== null
? $languageService->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:info.elementAlreadyModified')
diff --git a/typo3/sysext/workspaces/Classes/Service/Dependency/CollectionService.php b/typo3/sysext/workspaces/Classes/Service/Dependency/CollectionService.php
index b74bb00684c1..c2794e0f52fd 100644
--- a/typo3/sysext/workspaces/Classes/Service/Dependency/CollectionService.php
+++ b/typo3/sysext/workspaces/Classes/Service/Dependency/CollectionService.php
@@ -1,5 +1,7 @@
dependencyResolver)) {
$this->dependencyResolver = GeneralUtility::makeInstance(DependencyResolver::class);
@@ -87,11 +65,8 @@ public function getDependencyResolver()
/**
* Gets a new callback to be used in the dependency resolver utility.
- *
- * @param string $method
- * @return Dependency\EventCallback
*/
- protected function getDependencyCallback($method, array $targetArguments = [])
+ protected function getDependencyCallback(string $method, array $targetArguments = []): EventCallback
{
return GeneralUtility::makeInstance(
EventCallback::class,
@@ -103,10 +78,8 @@ protected function getDependencyCallback($method, array $targetArguments = [])
/**
* Gets the element entity processor.
- *
- * @return Dependency\ElementEntityProcessor
*/
- protected function getElementEntityProcessor()
+ protected function getElementEntityProcessor(): ElementEntityProcessor
{
if (!isset($this->elementEntityProcessor)) {
$this->elementEntityProcessor = GeneralUtility::makeInstance(ElementEntityProcessor::class);
@@ -117,10 +90,8 @@ protected function getElementEntityProcessor()
/**
* Processes the data array
- *
- * @return array
*/
- public function process(array $dataArray)
+ public function process(array $dataArray): array
{
$collection = 0;
$this->dataArray = $dataArray;
@@ -151,10 +122,8 @@ public function process(array $dataArray)
/**
* Applies structures to instance data array and
* ensures children are added below accordant parent
- *
- * @return array
*/
- protected function finalize(array $dataArray)
+ protected function finalize(array $dataArray): array
{
$processedDataArray = [];
foreach ($dataArray as $dataElement) {
@@ -175,12 +144,8 @@ protected function finalize(array $dataArray)
/**
* Resolves nested child dependencies.
- *
- * @param int $collection
- * @param string $nextParentIdentifier
- * @param int $collectionLevel
*/
- protected function resolveDataArrayChildDependencies(ElementEntity $parent, $collection, $nextParentIdentifier = '', $collectionLevel = 0)
+ protected function resolveDataArrayChildDependencies(ElementEntity $parent, int $collection, string $nextParentIdentifier = '', int $collectionLevel = 0): void
{
$parentIdentifier = $parent->__toString();
$parentIsSet = isset($this->dataArray[$parentIdentifier]);
diff --git a/typo3/sysext/workspaces/Classes/Service/GridDataService.php b/typo3/sysext/workspaces/Classes/Service/GridDataService.php
index a929b3f20651..cedae0640713 100644
--- a/typo3/sysext/workspaces/Classes/Service/GridDataService.php
+++ b/typo3/sysext/workspaces/Classes/Service/GridDataService.php
@@ -1,5 +1,7 @@
filterTxt ?? '';
@@ -113,11 +96,7 @@ public function generateGridListFromVersions($versions, $parameter, $currentWork
$limit = isset($parameter->limit) ? (int)$parameter->limit : 30;
$this->sort = $parameter->sort ?? 't3ver_oid';
$this->sortDir = $parameter->dir ?? 'ASC';
- if (is_int($currentWorkspace)) {
- $this->currentWorkspace = $currentWorkspace;
- } else {
- throw new \InvalidArgumentException('No such workspace defined', 1476048304);
- }
+ $this->currentWorkspace = $currentWorkspace;
$this->generateDataArray($versions, $filterTxt, $request);
return [
// Only count parent records for pagination
@@ -134,7 +113,7 @@ public function generateGridListFromVersions($versions, $parameter, $currentWork
* @param array $versions All available version records
* @param string $filterTxt Text to be used to filter record result
*/
- protected function generateDataArray(array $versions, $filterTxt, ServerRequestInterface $request)
+ protected function generateDataArray(array $versions, string $filterTxt, ServerRequestInterface $request): void
{
$backendUser = $this->getBackendUser();
$workspaceAccess = $backendUser->checkWorkspace($backendUser->workspace);
@@ -165,7 +144,7 @@ protected function generateDataArray(array $versions, $filterTxt, ServerRequestI
$this->getIntegrityService()->checkElement($combinedRecord);
if ($hiddenField !== null) {
- $recordState = $this->workspaceState($versionRecord['t3ver_state'], $origRecord[$hiddenField], $versionRecord[$hiddenField], $hasDiff);
+ $recordState = $this->workspaceState($versionRecord['t3ver_state'], (bool)$origRecord[$hiddenField], (bool)$versionRecord[$hiddenField], $hasDiff);
} else {
$recordState = $this->workspaceState($versionRecord['t3ver_state'], $hasDiff);
}
@@ -199,12 +178,12 @@ protected function generateDataArray(array $versions, $filterTxt, ServerRequestI
$versionArray['label_Workspace_crop'] = htmlspecialchars(GeneralUtility::fixed_lgd_cs($workspaceRecordLabel, (int)$backendUser->uc['titleLen']));
$versionArray['label_Live'] = htmlspecialchars($liveRecordLabel);
$versionArray['label_Live_crop'] = htmlspecialchars(GeneralUtility::fixed_lgd_cs($liveRecordLabel, (int)$backendUser->uc['titleLen']));
- $versionArray['label_Stage'] = htmlspecialchars($stagesObj->getStageTitle($versionRecord['t3ver_stage']));
+ $versionArray['label_Stage'] = htmlspecialchars($stagesObj->getStageTitle((int)$versionRecord['t3ver_stage']));
$tempStage = $stagesObj->getNextStage($versionRecord['t3ver_stage']);
- $versionArray['label_nextStage'] = htmlspecialchars($stagesObj->getStageTitle($tempStage['uid']));
+ $versionArray['label_nextStage'] = htmlspecialchars($stagesObj->getStageTitle((int)$tempStage['uid']));
$versionArray['value_nextStage'] = (int)$tempStage['uid'];
$tempStage = $stagesObj->getPrevStage($versionRecord['t3ver_stage']);
- $versionArray['label_prevStage'] = htmlspecialchars($stagesObj->getStageTitle($tempStage['uid'] ?? 0));
+ $versionArray['label_prevStage'] = htmlspecialchars($stagesObj->getStageTitle((int)($tempStage['uid'] ?? 0)));
$versionArray['value_prevStage'] = (int)($tempStage['uid'] ?? 0);
$versionArray['path_Live'] = htmlspecialchars(BackendUtility::getRecordPath($record['livepid'], '', 999));
$versionArray['path_Workspace'] = htmlspecialchars($pathWorkspace);
@@ -259,9 +238,10 @@ protected function generateDataArray(array $versions, $filterTxt, ServerRequestI
// Enrich elements after everything has been processed:
foreach ($this->dataArray as &$element) {
$identifier = $element['table'] . ':' . $element['t3ver_oid'];
+ $messages = $this->getIntegrityService()->getIssueMessages($identifier);
$element['integrity'] = [
'status' => $this->getIntegrityService()->getStatusRepresentation($identifier),
- 'messages' => htmlspecialchars((string)$this->getIntegrityService()->getIssueMessages($identifier, true)),
+ 'messages' => htmlspecialchars(implode('
', $messages)),
];
}
$this->setDataArrayIntoCache($versions, $filterTxt);
@@ -279,8 +259,8 @@ protected function versionIsModified(CombinedRecord $combinedRecord, ServerReque
{
$remoteServer = GeneralUtility::makeInstance(RemoteServer::class);
- $params = new \StdClass();
- $params->stage = $combinedRecord->getVersionRecord()->getRow()['t3ver_stage'];
+ $params = new \stdClass();
+ $params->stage = (int)$combinedRecord->getVersionRecord()->getRow()['t3ver_stage'];
$params->t3ver_oid = $combinedRecord->getLiveRecord()->getUid();
$params->table = $combinedRecord->getLiveRecord()->getTable();
$params->uid = $combinedRecord->getVersionRecord()->getUid();
@@ -293,7 +273,7 @@ protected function versionIsModified(CombinedRecord $combinedRecord, ServerReque
* Resolves dependencies of nested structures
* and sort data elements considering these dependencies.
*/
- protected function resolveDataArrayDependencies()
+ protected function resolveDataArrayDependencies(): void
{
$collectionService = $this->getDependencyCollectionService();
$dependencyResolver = $collectionService->getDependencyResolver();
@@ -307,12 +287,8 @@ protected function resolveDataArrayDependencies()
/**
* Gets the data array by considering the page to be shown in the grid view.
- *
- * @param int $start
- * @param int $limit
- * @return array
*/
- protected function getDataArray($start, $limit)
+ protected function getDataArray(int $start, int $limit): array
{
$dataArrayCount = count($this->dataArray);
$start = $this->calculateStartWithCollections($start);
@@ -333,7 +309,7 @@ protected function getDataArray($start, $limit)
/**
* Initializes the workspace cache
*/
- protected function initializeWorkspacesCachingFramework()
+ protected function initializeWorkspacesCachingFramework(): void
{
$this->workspacesCache = GeneralUtility::makeInstance(CacheManager::class)->getCache('workspaces_cache');
}
@@ -344,7 +320,7 @@ protected function initializeWorkspacesCachingFramework()
* @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
* @param string $filterTxt The given filter text from the grid.
*/
- protected function setDataArrayIntoCache(array $versions, $filterTxt)
+ protected function setDataArrayIntoCache(array $versions, string $filterTxt): void
{
$hash = $this->calculateHash($versions, $filterTxt);
$this->workspacesCache->set(
@@ -364,7 +340,7 @@ protected function setDataArrayIntoCache(array $versions, $filterTxt)
* @param string $filterTxt The given filter text from the grid.
* @return bool TRUE if cache entry was successfully fetched from cache and content put to $this->dataArray
*/
- protected function getDataArrayFromCache(array $versions, $filterTxt)
+ protected function getDataArrayFromCache(array $versions, string $filterTxt): bool
{
$cacheEntry = false;
$hash = $this->calculateHash($versions, $filterTxt);
@@ -381,9 +357,8 @@ protected function getDataArrayFromCache(array $versions, $filterTxt)
*
* @param array $versions All records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
* @param string $filterTxt The given filter text from the grid.
- * @return string
*/
- protected function calculateHash(array $versions, $filterTxt)
+ protected function calculateHash(array $versions, string $filterTxt): string
{
$backendUser = $this->getBackendUser();
$hashArray = [
@@ -403,7 +378,7 @@ protected function calculateHash(array $versions, $filterTxt)
* Performs sorting on the data array accordant to the
* selected column in the grid view to be used for sorting.
*/
- protected function sortDataArray()
+ protected function sortDataArray(): void
{
switch ($this->sort) {
case 'uid':
@@ -437,12 +412,8 @@ protected function sortDataArray()
/**
* Implements individual sorting for columns based on integer comparison.
- *
- * @param array $a First value
- * @param array $b Second value
- * @return int
*/
- protected function intSort(array $a, array $b)
+ protected function intSort(array $a, array $b): int
{
if (!$this->isSortable($a, $b)) {
return 0;
@@ -469,12 +440,8 @@ protected function intSort(array $a, array $b)
/**
* Implements individual sorting for columns based on string comparison.
- *
- * @param array $a First value
- * @param array $b Second value
- * @return int
*/
- protected function stringSort($a, $b)
+ protected function stringSort(array $a, array $b): int
{
if (!$this->isSortable($a, $b)) {
return 0;
@@ -503,10 +470,8 @@ protected function stringSort($a, $b)
* Determines whether dataArray elements are sortable.
* Only elements on the first level (0) or below the same
* parent element are directly sortable.
- *
- * @return bool
*/
- protected function isSortable(array $a, array $b)
+ protected function isSortable(array $a, array $b): bool
{
return
$a[self::GridColumn_CollectionLevel] === 0 && $b[self::GridColumn_CollectionLevel] === 0
@@ -529,11 +494,8 @@ protected function isPageModuleAllowed(): bool
/**
* Determines whether the text used to filter the results is part of
* a column that is visible in the grid view.
- *
- * @param string $filterText
- * @return bool
*/
- protected function isFilterTextInVisibleColumns($filterText, array $versionArray)
+ protected function isFilterTextInVisibleColumns(string $filterText, array $versionArray): bool
{
$backendUser = $this->getBackendUser();
if (is_array($backendUser->uc['moduleData']['Workspaces'][$backendUser->workspace]['columns'] ?? false)) {
@@ -581,15 +543,13 @@ protected function isFilterTextInVisibleColumns($filterText, array $versionArray
* @param bool $hiddenOnline hidden status of online record
* @param bool $hiddenOffline hidden status of offline record
* @param bool $hasDiff whether the version has any changes
- *
- * @return string
*/
- protected function workspaceState($stateId, $hiddenOnline = false, $hiddenOffline = false, $hasDiff = true)
+ protected function workspaceState(int $stateId, bool $hiddenOnline = false, bool $hiddenOffline = false, bool $hasDiff = true): string
{
$hiddenState = null;
- if ($hiddenOnline == 0 && $hiddenOffline == 1) {
+ if (!$hiddenOnline && $hiddenOffline) {
$hiddenState = 'hidden';
- } elseif ($hiddenOnline == 1 && $hiddenOffline == 0) {
+ } elseif ($hiddenOnline && !$hiddenOffline) {
$hiddenState = 'unhidden';
}
switch (VersionState::tryFrom($stateId)) {
@@ -620,7 +580,7 @@ protected function workspaceState($stateId, $hiddenOnline = false, $hiddenOfflin
* @param string $type Type to be fetches (e.g. 'disabled', 'starttime', 'endtime', 'fe_group)
* @return string|null The accordant field name or NULL if not defined
*/
- protected function getTcaEnableColumnsFieldName($table, $type)
+ protected function getTcaEnableColumnsFieldName(string $table, string $type): ?string
{
$fieldName = null;
@@ -638,13 +598,13 @@ protected function getTcaEnableColumnsFieldName($table, $type)
* @param array $record Database record
* @return int
*/
- protected function getLanguageValue($table, array $record)
+ protected function getLanguageValue(string $table, array $record): int
{
$languageValue = 0;
if (BackendUtility::isTableLocalizable($table)) {
$languageField = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
if (!empty($record[$languageField])) {
- $languageValue = $record[$languageField];
+ $languageValue = (int)$record[$languageField];
}
}
return $languageValue;
@@ -659,10 +619,10 @@ protected function getLanguageValue($table, array $record)
* @return string|null
* @see getSystemLanguages
*/
- protected function getSystemLanguageValue($id, $pageId, $key)
+ protected function getSystemLanguageValue(int $id, int $pageId, string $key): ?string
{
$value = null;
- $systemLanguages = $this->getSystemLanguages((int)$pageId);
+ $systemLanguages = $this->getSystemLanguages($pageId);
if (!empty($systemLanguages[$id][$key])) {
$value = $systemLanguages[$id][$key];
}
@@ -772,20 +732,16 @@ protected function addCollectionChildrenRecursive(array $item, int &$recordsCoun
/**
* Gets all available system languages.
- *
- * @return array
*/
- protected function getSystemLanguages(int $pageId)
+ protected function getSystemLanguages(int $pageId): array
{
return GeneralUtility::makeInstance(TranslationConfigurationProvider::class)->getSystemLanguages($pageId);
}
/**
* Gets an instance of the integrity service.
- *
- * @return IntegrityService
*/
- protected function getIntegrityService()
+ protected function getIntegrityService(): IntegrityService
{
if (!isset($this->integrityService)) {
$this->integrityService = GeneralUtility::makeInstance(IntegrityService::class);
@@ -793,10 +749,7 @@ protected function getIntegrityService()
return $this->integrityService;
}
- /**
- * @return Dependency\CollectionService
- */
- protected function getDependencyCollectionService()
+ protected function getDependencyCollectionService(): CollectionService
{
return GeneralUtility::makeInstance(CollectionService::class);
}
diff --git a/typo3/sysext/workspaces/Classes/Service/HistoryService.php b/typo3/sysext/workspaces/Classes/Service/HistoryService.php
index caaececd7fcd..3bb5709fb233 100644
--- a/typo3/sysext/workspaces/Classes/Service/HistoryService.php
+++ b/typo3/sysext/workspaces/Classes/Service/HistoryService.php
@@ -1,5 +1,7 @@
backendUserNames = BackendUtility::getUserNames();
@@ -56,7 +45,7 @@ public function __construct()
* @param int $id Uid of the record
* @return array Record history entries
*/
- public function getHistory($table, $id)
+ public function getHistory(string $table, int $id): array
{
$history = [];
$i = 0;
@@ -90,10 +79,9 @@ public function getStageChanges(string $table, int $id): array
* record history entry.
*
* @param array $entry Record history entry
- * @return array
* @see getHistory
*/
- protected function getHistoryEntry(array $entry)
+ protected function getHistoryEntry(array $entry): array
{
if (!empty($entry['action'])) {
$differences = $entry['action'];
@@ -117,9 +105,8 @@ protected function getHistoryEntry(array $entry)
* of one record history entry.
*
* @param array $entry Record history entry
- * @return array
*/
- protected function getDifferences(array $entry)
+ protected function getDifferences(array $entry): array
{
$diffUtility = GeneralUtility::makeInstance(DiffUtility::class);
$differences = [];
@@ -158,11 +145,8 @@ protected function getDifferences(array $entry)
/**
* Gets the username of a backend user.
- *
- * @param string $user
- * @return string
*/
- protected function getUserName($user)
+ protected function getUserName(int $user): string
{
$userName = 'unknown';
if (!empty($this->backendUserNames[$user]['username'])) {
@@ -176,9 +160,8 @@ protected function getUserName($user)
*
* @param string $table Name of the table
* @param int $id Uid of the record
- * @return array
*/
- protected function getHistoryEntries($table, $id)
+ protected function getHistoryEntries(string $table, int $id): array
{
if (!isset($this->historyEntries[$table][$id])) {
$this->historyEntries[$table][$id] = GeneralUtility::makeInstance(RecordHistory::class)
diff --git a/typo3/sysext/workspaces/Classes/Service/IntegrityService.php b/typo3/sysext/workspaces/Classes/Service/IntegrityService.php
index be62569f109b..f9d5255cf5f0 100644
--- a/typo3/sysext/workspaces/Classes/Service/IntegrityService.php
+++ b/typo3/sysext/workspaces/Classes/Service/IntegrityService.php
@@ -1,5 +1,7 @@
'success',
+
+ protected array $statusRepresentation = [
+ self::STATUS_Success => 'success',
self::STATUS_Info => 'info',
self::STATUS_Warning => 'warning',
self::STATUS_Error => 'error',
@@ -62,30 +59,28 @@ class IntegrityService
/**
* @var CombinedRecord[]
*/
- protected $affectedElements;
+ protected array $affectedElements = [];
/**
* Array storing all issues that have been checked and
* found during runtime in this object. The array keys
* are identifiers of table and the version-id.
*
- * 'tx_table:123' => array(
- * array(
- * 'status' => 'warning',
- * 'message' => 'Element cannot be...',
- * )
- * )
- *
- * @var array
+ * 'tx_table:123' => [
+ * [
+ * 'status' => 102,
+ * 'message' => 'Element cannot be...',
+ * ]
+ * ]
*/
- protected $issues = [];
+ protected array $issues = [];
/**
* Sets the affected elements.
*
* @param CombinedRecord[] $affectedElements
*/
- public function setAffectedElements(array $affectedElements)
+ public function setAffectedElements(array $affectedElements): void
{
$this->affectedElements = $affectedElements;
}
@@ -93,7 +88,7 @@ public function setAffectedElements(array $affectedElements)
/**
* Checks integrity of affected records.
*/
- public function check()
+ public function check(): void
{
foreach ($this->affectedElements as $affectedElement) {
$this->checkElement($affectedElement);
@@ -103,7 +98,7 @@ public function check()
/**
* Checks a single element.
*/
- public function checkElement(CombinedRecord $element)
+ public function checkElement(CombinedRecord $element): void
{
$this->checkLocalization($element);
}
@@ -114,7 +109,7 @@ public function checkElement(CombinedRecord $element)
* is new in this workspace,
* then both (localization and localization parent) should be published.
*/
- protected function checkLocalization(CombinedRecord $element)
+ protected function checkLocalization(CombinedRecord $element): void
{
$table = $element->getTable();
if (BackendUtility::isTableLocalizable($table)) {
@@ -150,12 +145,11 @@ protected function checkLocalization(CombinedRecord $element)
* Gets the status of the most important severity.
* (low << success, info, warning, error >> high)
*
- * @param string $identifier Record identifier (table:id) for look-ups
- * @return string
+ * @param string|null $identifier Record identifier (table:id) for look-ups
*/
- public function getStatus($identifier = null)
+ public function getStatus(string $identifier = null): int
{
- $status = self::STATUS_Succes;
+ $status = self::STATUS_Success;
if ($identifier === null) {
foreach ($this->issues as $idenfieriferIssues) {
foreach ($idenfieriferIssues as $issue) {
@@ -175,13 +169,13 @@ public function getStatus($identifier = null)
}
/**
- * Gets the (human readable) representation of the status with the most
+ * Gets the (human-readable) representation of the status with the most
* important severity (wraps $this->getStatus() and translates the result).
*
- * @param string $identifier Record identifier (table:id) for look-ups
+ * @param string|null $identifier Record identifier (table:id) for look-ups
* @return string One out of success, info, warning, error
*/
- public function getStatusRepresentation($identifier = null)
+ public function getStatusRepresentation(string $identifier = null): string
{
return $this->statusRepresentation[$this->getStatus($identifier)];
}
@@ -189,10 +183,9 @@ public function getStatusRepresentation($identifier = null)
/**
* Gets issues, all or specific for one identifier.
*
- * @param string $identifier Record identifier (table:id) for look-ups
- * @return array
+ * @param string|null $identifier Record identifier (table:id) for look-ups
*/
- public function getIssues($identifier = null)
+ public function getIssues(string $identifier = null): array
{
if ($identifier === null) {
return $this->issues;
@@ -206,11 +199,9 @@ public function getIssues($identifier = null)
/**
* Gets the message of all issues.
*
- * @param string $identifier Record identifier (table:id) for look-ups
- * @param bool $asString Return results as string instead of array
- * @return array|string
+ * @param string|null $identifier Record identifier (table:id) for look-ups
*/
- public function getIssueMessages($identifier = null, $asString = false)
+ public function getIssueMessages(string $identifier = null): array
{
$messages = [];
if ($identifier === null) {
@@ -224,9 +215,6 @@ public function getIssueMessages($identifier = null, $asString = false)
$messages[] = $issue['message'];
}
}
- if ($asString) {
- $messages = implode('
', $messages);
- }
return $messages;
}
@@ -237,7 +225,7 @@ public function getIssueMessages($identifier = null, $asString = false)
* @param int $status Status code (see constants)
* @param string $message Message/description of the issue
*/
- protected function addIssue($identifier, $status, $message)
+ protected function addIssue(string $identifier, int $status, string $message): void
{
if (!isset($this->issues[$identifier])) {
$this->issues[$identifier] = [];
diff --git a/typo3/sysext/workspaces/Classes/Service/RecordService.php b/typo3/sysext/workspaces/Classes/Service/RecordService.php
index 19cfb89ec191..9646ecefb90c 100644
--- a/typo3/sysext/workspaces/Classes/Service/RecordService.php
+++ b/typo3/sysext/workspaces/Classes/Service/RecordService.php
@@ -1,5 +1,7 @@
records[$databaseRecord->getIdentifier()])) {
@@ -42,10 +37,7 @@ public function add($tableName, $id)
}
}
- /**
- * @return array
- */
- public function getIdsPerTable()
+ public function getIdsPerTable(): array
{
$idsPerTable = [];
foreach ($this->records as $databaseRecord) {
diff --git a/typo3/sysext/workspaces/Classes/Service/StagesService.php b/typo3/sysext/workspaces/Classes/Service/StagesService.php
index 6f21394c61df..1dfd0a75beb8 100644
--- a/typo3/sysext/workspaces/Classes/Service/StagesService.php
+++ b/typo3/sysext/workspaces/Classes/Service/StagesService.php
@@ -1,5 +1,7 @@
workspaceStageCache[$this->getWorkspaceId()])) {
$stages = $this->workspaceStageCache[$this->getWorkspaceId()];
@@ -183,7 +169,7 @@ public function getStagesForWS()
*
* @return array id and title of stages
*/
- public function getStagesForWSUser()
+ public function getStagesForWSUser(): array
{
if ($this->getBackendUser()->isAdmin()) {
return $this->getStagesForWS();
@@ -226,9 +212,8 @@ public function getStagesForWSUser()
* Prepares simplified stages array
*
* @param StageRecord[] $stageRecords
- * @return array
*/
- protected function prepareStagesArray(array $stageRecords)
+ protected function prepareStagesArray(array $stageRecords): array
{
$stagesArray = [];
foreach ($stageRecords as $stageRecord) {
@@ -247,14 +232,11 @@ protected function prepareStagesArray(array $stageRecords)
}
/**
- * Gets the title of a stage.
- *
- * @param int $ver_stage
- * @return string
+ * Gets the title of a stage
*/
- public function getStageTitle($ver_stage)
+ public function getStageTitle(int $stageId): string
{
- switch ($ver_stage) {
+ switch ($stageId) {
case self::STAGE_PUBLISH_EXECUTE_ID:
$stageTitle = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_publish');
break;
@@ -265,8 +247,8 @@ public function getStageTitle($ver_stage)
$stageTitle = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_mod_user_ws.xlf:stage_editing');
break;
default:
- $stageTitle = $this->getPropertyOfCurrentWorkspaceStage($ver_stage, 'title');
- if ($stageTitle == null) {
+ $stageTitle = $this->getPropertyOfCurrentWorkspaceStage($stageId, 'title');
+ if ($stageTitle === null) {
$stageTitle = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:error.getStageTitle.stageNotFound');
}
}
@@ -275,13 +257,10 @@ public function getStageTitle($ver_stage)
/**
* Gets a particular stage record.
- *
- * @param int $stageid
- * @return array|null
*/
- public function getStageRecord($stageid)
+ public function getStageRecord(int $stageId): ?array
{
- return BackendUtility::getRecord('sys_workspace_stage', $stageid);
+ return BackendUtility::getRecord('sys_workspace_stage', $stageId);
}
/**
@@ -289,9 +268,8 @@ public function getStageRecord($stageid)
*
* @param int $stageId Id of the stage to fetch the next one for
* @return array The next stage (id + details)
- * @throws \InvalidArgumentException
*/
- public function getNextStage($stageId)
+ public function getNextStage(int $stageId): array
{
if (!MathUtility::canBeInterpretedAsInteger($stageId)) {
throw new \InvalidArgumentException(
@@ -331,7 +309,7 @@ public function getNextStage($stageId)
* @param int $stageId Current stage id of the record
* @return array Next stages
*/
- public function getNextStages(array &$nextStageArray, $stageId)
+ protected function getNextStages(array &$nextStageArray, int $stageId): array
{
// Current stage is "Ready to publish" - there is no next stage
if ($stageId == self::STAGE_PUBLISH_ID) {
@@ -357,10 +335,9 @@ public function getNextStages(array &$nextStageArray, $stageId)
* Get next stage in process for given stage id
*
* @param int $stageId Id of the stage to fetch the previous one for
- * @return bool|array The previous stage or false
- * @throws \InvalidArgumentException
+ * @return false|array The previous stage or false
*/
- public function getPrevStage($stageId)
+ public function getPrevStage(int $stageId): false|array
{
if (!MathUtility::canBeInterpretedAsInteger($stageId)) {
throw new \InvalidArgumentException(
@@ -392,7 +369,7 @@ public function getPrevStage($stageId)
* @param int $stageId Current stage id of the record
* @return array prev stages
*/
- public function getPrevStages(array &$prevStageArray, $stageId)
+ protected function getPrevStages(array &$prevStageArray, int $stageId): array
{
// Current stage is "Editing" - there is no prev stage
if ($stageId != self::STAGE_EDIT_ID) {
@@ -414,11 +391,10 @@ public function getPrevStages(array &$prevStageArray, $stageId)
* Gets all backend user records that are considered to be responsible
* for a particular stage or workspace.
*
- * @param StageRecord|int $stageRecord Stage
* @param bool $selectDefaultUserField If field notification_defaults should be selected instead of responsible users
* @return array be_users with e-mail and name
*/
- public function getResponsibleBeUser($stageRecord, $selectDefaultUserField = false)
+ public function getResponsibleBeUser(StageRecord|int $stageRecord, bool $selectDefaultUserField = false): array
{
if (!$stageRecord instanceof StageRecord) {
$stageRecord = $this->getWorkspaceRecord()->getStage($stageRecord);
@@ -443,11 +419,8 @@ public function getResponsibleBeUser($stageRecord, $selectDefaultUserField = fal
/**
* Resolves backend user ids from a mixed list of backend users
* and backend user groups (e.g. "be_users_1,be_groups_3,be_users_4,...")
- *
- * @param string $backendUserGroupList
- * @return array
*/
- public function resolveBackendUserIds($backendUserGroupList)
+ public function resolveBackendUserIds(string $backendUserGroupList): array
{
$elements = GeneralUtility::trimExplode(',', $backendUserGroupList, true);
$backendUserIds = [];
@@ -477,32 +450,21 @@ public function resolveBackendUserIds($backendUserGroupList)
/**
* Gets backend user records from a given list of ids.
- *
- * @param string $backendUserList
- * @return array
*/
- public function getBackendUsers($backendUserList)
+ public function getBackendUsers(string $backendUserList): array
{
if (empty($backendUserList)) {
return [];
}
$backendUserList = implode(',', GeneralUtility::intExplode(',', $backendUserList));
- $backendUsers = BackendUtility::getUserNames(
+ return BackendUtility::getUserNames(
'username, uid, email, realName, lang, uc',
'AND uid IN (' . $backendUserList . ')' . BackendUtility::BEenableFields('be_users')
);
-
- if (empty($backendUsers)) {
- $backendUsers = [];
- }
- return $backendUsers;
}
- /**
- * @return array
- */
- public function getPreselectedRecipients(StageRecord $stageRecord)
+ public function getPreselectedRecipients(StageRecord $stageRecord): array
{
if ($stageRecord->areEditorsPreselected()) {
return array_merge(
@@ -513,23 +475,15 @@ public function getPreselectedRecipients(StageRecord $stageRecord)
return $stageRecord->getPreselectedRecipients();
}
- /**
- * @return WorkspaceRecord
- */
- protected function getWorkspaceRecord()
+ protected function getWorkspaceRecord(): WorkspaceRecord
{
return WorkspaceRecord::get($this->getWorkspaceId());
}
/**
* Gets a property of a workspaces stage.
- *
- * @param int $stageId
- * @param string $property
- * @return string
- * @throws \InvalidArgumentException
*/
- public function getPropertyOfCurrentWorkspaceStage($stageId, $property)
+ public function getPropertyOfCurrentWorkspaceStage(int $stageId, string $property): ?string
{
$result = null;
if (!MathUtility::canBeInterpretedAsInteger($stageId)) {
@@ -549,10 +503,9 @@ public function getPropertyOfCurrentWorkspaceStage($stageId, $property)
* Gets the position of the given workspace in the hole process
* f.e. 3 means step 3 of 20, by which 1 is edit and 20 is ready to publish
*
- * @param int $stageId
* @return array position => 3, count => 20
*/
- public function getPositionOfCurrentStage($stageId)
+ public function getPositionOfCurrentStage(int $stageId): array
{
$stagesOfWS = $this->getStagesForWS();
$countOfStages = count($stagesOfWS);
@@ -577,11 +530,8 @@ public function getPositionOfCurrentStage($stageId)
/**
* Check if the user has access to the previous stage, relative to the given stage
- *
- * @param int $stageId
- * @return bool
*/
- public function isPrevStageAllowedForUser($stageId)
+ public function isPrevStageAllowedForUser(int $stageId): bool
{
$isAllowed = false;
try {
@@ -599,11 +549,8 @@ public function isPrevStageAllowedForUser($stageId)
/**
* Check if the user has access to the next stage, relative to the given stage
- *
- * @param int $stageId
- * @return bool
*/
- public function isNextStageAllowedForUser($stageId)
+ public function isNextStageAllowedForUser(int $stageId): bool
{
$isAllowed = false;
try {
@@ -619,11 +566,7 @@ public function isNextStageAllowedForUser($stageId)
return $isAllowed;
}
- /**
- * @param int $stageId
- * @return bool
- */
- protected function isStageAllowedForUser($stageId)
+ protected function isStageAllowedForUser(int $stageId): bool
{
$cacheKey = $this->getWorkspaceId() . '_' . $stageId;
if (isset($this->workspaceStageAllowedCache[$cacheKey])) {
@@ -635,12 +578,9 @@ protected function isStageAllowedForUser($stageId)
}
/**
- * Determines whether a stage Id is valid.
- *
- * @param int $stageId The stage Id to be checked
- * @return bool
+ * Determines whether a stageId is valid.
*/
- public function isValid($stageId)
+ public function isValid(int $stageId): bool
{
$isValid = false;
$stages = $this->getStagesForWS();
@@ -653,10 +593,7 @@ public function isValid($stageId)
return $isValid;
}
- /**
- * @return RecordService
- */
- public function getRecordService()
+ public function getRecordService(): RecordService
{
if (!isset($this->recordService)) {
$this->recordService = GeneralUtility::makeInstance(RecordService::class);
diff --git a/typo3/sysext/workspaces/Classes/Service/WorkspaceService.php b/typo3/sysext/workspaces/Classes/Service/WorkspaceService.php
index 3e1e336401c7..54ebd168a662 100644
--- a/typo3/sysext/workspaces/Classes/Service/WorkspaceService.php
+++ b/typo3/sysext/workspaces/Classes/Service/WorkspaceService.php
@@ -1,5 +1,7 @@
getBackendUser();
$availableWorkspaces = [];
@@ -113,8 +105,6 @@ public function getPreviewLinkLifetime(): int
/**
* Find the title for the requested workspace.
- *
- * @throws \InvalidArgumentException
*/
public function getWorkspaceTitle(int $wsId): string
{
@@ -140,14 +130,12 @@ public function getWorkspaceTitle(int $wsId): string
* Building DataHandler CMD-array for publishing all versions in a workspace.
*
* @param int $wsid Real workspace ID, cannot be ONLINE (zero).
- * @param bool $_ Unused, previously used to choose between swapping and publishing
- * @param int $pageId The page id
+ * @param bool $_ Dummy parameter, only there because testing framework is calling it with 2 parameters
* @param int|null $language Select specific language only
* @return array Command array for DataHandler
*/
- public function getCmdArrayForPublishWS($wsid, $_ = false, $pageId = 0, $language = null)
+ public function getCmdArrayForPublishWS(int $wsid, bool $_ = false, int $language = null): array
{
- $wsid = (int)$wsid;
$cmd = [];
if ($wsid > 0) {
// Define stage to select:
@@ -160,7 +148,7 @@ public function getCmdArrayForPublishWS($wsid, $_ = false, $pageId = 0, $languag
$versions = $this->selectVersionsInWorkspace(
$wsid,
$stage,
- $pageId ?: -1,
+ -1,
999,
'tables_modify',
$language
@@ -181,14 +169,11 @@ public function getCmdArrayForPublishWS($wsid, $_ = false, $pageId = 0, $languag
* Building DataHandler CMD-array for releasing all versions in a workspace.
*
* @param int $wsid Real workspace ID, cannot be ONLINE (zero).
- * @param bool $flush Run Flush (TRUE) or ClearWSID (FALSE) command
- * @param int $pageId The page id
- * @param int $language Select specific language only
+ * @param int|null $language Select specific language only
* @return array Command array for DataHandler
*/
- public function getCmdArrayForFlushWS($wsid, $flush = true, $pageId = 0, $language = null)
+ public function getCmdArrayForFlushWS(int $wsid, int $language = null)
{
- $wsid = (int)$wsid;
$cmd = [];
if ($wsid > 0) {
// Define stage to select:
@@ -197,7 +182,7 @@ public function getCmdArrayForFlushWS($wsid, $flush = true, $pageId = 0, $langua
$versions = $this->selectVersionsInWorkspace(
$wsid,
$stage,
- $pageId ?: -1,
+ -1,
999,
'tables_modify',
$language
@@ -205,8 +190,7 @@ public function getCmdArrayForFlushWS($wsid, $flush = true, $pageId = 0, $langua
// Traverse the selection to build CMD array:
foreach ($versions as $table => $records) {
foreach ($records as $rec) {
- // Build the cmd Array:
- $cmd[$table][$rec['uid']]['version'] = ['action' => $flush ? 'flush' : 'clearWSID'];
+ $cmd[$table][$rec['uid']]['version'] = ['action' => 'flush'];
}
}
}
@@ -226,10 +210,9 @@ public function getCmdArrayForFlushWS($wsid, $flush = true, $pageId = 0, $langua
* @param int $language Select specific language only
* @return array Array of all records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oidfields. The pid of the online record is found as "livepid" the pid of the offline record is found in "wspid
*/
- public function selectVersionsInWorkspace($wsid, $stage = -99, $pageId = -1, $recursionLevel = 0, $selectionType = 'tables_select', $language = null)
+ public function selectVersionsInWorkspace(int $wsid, int $stage = -99, int $pageId = -1, int $recursionLevel = 0, string $selectionType = 'tables_select', int $language = null): array
{
$backendUser = $this->getBackendUser();
- $wsid = (int)$wsid;
$output = [];
// Contains either nothing or a list with live-uids
if ($pageId != -1 && $recursionLevel > 0) {
@@ -258,7 +241,7 @@ public function selectVersionsInWorkspace($wsid, $stage = -99, $pageId = -1, $re
}
if (BackendUtility::isTableWorkspaceEnabled($table)) {
$recs = $this->selectAllVersionsFromPages($table, $pageList, $wsid, $stage, $language);
- $newRecords = $this->getNewVersionsForPages($table, $pageList, $wsid, (int)$stage, $language);
+ $newRecords = $this->getNewVersionsForPages($table, $pageList, $wsid, $stage, $language);
foreach ($newRecords as &$newRecord) {
// If we're dealing with a 'new' record, this one has no t3ver_oid. On publish, there is no
// live counterpart, but the publish methods later need a live uid to publish to. We thus
@@ -279,15 +262,8 @@ public function selectVersionsInWorkspace($wsid, $stage = -99, $pageId = -1, $re
/**
* Find all versionized elements except moved and new records.
- *
- * @param string $table
- * @param string $pageList
- * @param int $wsid
- * @param int $stage
- * @param int $language
- * @return array
*/
- protected function selectAllVersionsFromPages($table, $pageList, $wsid, $stage, $language = null)
+ protected function selectAllVersionsFromPages(string $table, string $pageList, int $wsid, int $stage, int $language = null): array
{
// Include root level page as there might be some records with where root level
// restriction is ignored (e.g. FAL records)
@@ -517,14 +493,8 @@ protected function getNewVersionsForPages(
/**
* Find all moved records at their new position.
- *
- * @param string $table
- * @param string $pageList
- * @param int $wsid
- * @param int $stage
- * @return array
*/
- protected function getMovedRecordsFromPages($table, $pageList, $wsid, $stage)
+ protected function getMovedRecordsFromPages(string $table, string $pageList, int $wsid, int $stage): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()->removeAll()
@@ -621,12 +591,9 @@ protected function getMovedRecordsFromPages($table, $pageList, $wsid, $stage)
/**
* Find all page uids recursive starting from a specific page
*
- * @param int $pageId
- * @param int $wsid
- * @param int $recursionLevel
* @return string Comma sep. uid list
*/
- protected function getTreeUids($pageId, $wsid, $recursionLevel)
+ protected function getTreeUids(int $pageId, int $wsid, int $recursionLevel): string
{
$backendUser = $this->getBackendUser();
// Reusing existing functionality with the drawback that
@@ -778,19 +745,13 @@ protected function getPageChildrenRecursive(int $pid, int $depth, int $begin, st
/**
* Remove all records which are not permitted for the user
- *
- * @param array $recs
- * @param string $table
- * @return array
*/
- protected function filterPermittedElements($recs, $table)
+ protected function filterPermittedElements(array $recs, string $table): array
{
$permittedElements = [];
- if (is_array($recs)) {
- foreach ($recs as $rec) {
- if ($this->isPageAccessibleForCurrentUser($table, $rec) && $this->isLanguageAccessibleForCurrentUser($table, $rec)) {
- $permittedElements[] = $rec;
- }
+ foreach ($recs as $rec) {
+ if ($this->isPageAccessibleForCurrentUser($table, $rec) && $this->isLanguageAccessibleForCurrentUser($table, $rec)) {
+ $permittedElements[] = $rec;
}
}
return $permittedElements;
@@ -801,9 +762,8 @@ protected function filterPermittedElements($recs, $table)
*
* @param string $table Name of the table
* @param array $record Record row to be checked
- * @return bool
*/
- protected function isPageAccessibleForCurrentUser($table, array $record)
+ protected function isPageAccessibleForCurrentUser(string $table, array $record): bool
{
$pageIdField = $table === 'pages' ? 'uid' : 'wspid';
$pageId = isset($record[$pageIdField]) ? (int)$record[$pageIdField] : null;
@@ -823,9 +783,8 @@ protected function isPageAccessibleForCurrentUser($table, array $record)
*
* @param string $table Name of the table
* @param array $record Record row to be checked
- * @return bool
*/
- protected function isLanguageAccessibleForCurrentUser($table, array $record)
+ protected function isLanguageAccessibleForCurrentUser(string $table, array $record): bool
{
if (BackendUtility::isTableLocalizable($table)) {
$languageUid = $record[$GLOBALS['TCA'][$table]['ctrl']['languageField']] ?? 0;
@@ -841,7 +800,7 @@ protected function isLanguageAccessibleForCurrentUser($table, array $record)
* @param int $id Primary key of the page to check
* @param int $language Language for which to check the page
*/
- public function isNewPage($id, $language = 0): bool
+ public function isNewPage(int $id, int $language = 0): bool
{
$isNewPage = false;
// If the language is not default, check state of overlay
@@ -890,9 +849,9 @@ public function isNewPage($id, $language = 0): bool
* @param int $pageId
* @return bool
*/
- public function hasPageRecordVersions($workspaceId, $pageId)
+ public function hasPageRecordVersions(int $workspaceId, int $pageId): bool
{
- if ((int)$workspaceId === 0 || (int)$pageId === 0) {
+ if ($workspaceId === 0 || $pageId === 0) {
return false;
}
@@ -936,12 +895,8 @@ public function hasPageRecordVersions($workspaceId, $pageId)
* 21 => true
* ],
* ]
- *
- * @param int $workspaceId
- *
- * @return array
*/
- public function getPagesWithVersionsInTable($workspaceId)
+ public function getPagesWithVersionsInTable(int $workspaceId): array
{
foreach ($GLOBALS['TCA'] as $tableName => $tableConfiguration) {
if ($tableName === 'pages' || !BackendUtility::isTableWorkspaceEnabled($tableName)) {
@@ -964,12 +919,8 @@ public function getPagesWithVersionsInTable($workspaceId)
* 13 => true,
* 15 => true
* ],
- *
- * @param int $workspaceId
- * @param string $tableName
- * @return array
*/
- protected function fetchPagesWithVersionsInTable($workspaceId, $tableName)
+ protected function fetchPagesWithVersionsInTable(int $workspaceId, string $tableName): array
{
if ((int)$workspaceId === 0) {
return [];