Commit cc6329b5 authored by Daniel Goerz's avatar Daniel Goerz
Browse files

[BUGFIX] Fix phpstan errors from TypesAssignedToPropertiesRule

* EXT: backend
* EXT: belog
* EXT: beuser

In addition an adjustment is added that was forgotten in
https://review.typo3.org/c/Packages/TYPO3.CMS/+/69038

Resolves: #94126
Releases: master
Change-Id: I610b39268d417344517e76d7cc436da50d3db898
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69134

Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
parent 1181b126
......@@ -34,7 +34,7 @@ class ReferenceIndexProgressListener implements ProgressListenerInterface
protected $io;
/**
* @var ProgressBar
* @var ProgressBar|null
*/
protected $progressBar;
......
......@@ -269,7 +269,7 @@ class RecordProvider extends AbstractProvider
*/
protected function initPermissions()
{
$this->pageRecord = BackendUtility::getRecord('pages', $this->record['pid']);
$this->pageRecord = BackendUtility::getRecord('pages', $this->record['pid']) ?? [];
$this->pagePermissions = new Permission($this->backendUser->calcPerms($this->pageRecord));
}
......
......@@ -179,8 +179,8 @@ class ElementInformationController
// Check permissions and uid value:
if ($this->uid && $this->getBackendUser()->check('tables_select', $this->table)) {
if ((string)$this->table === 'pages') {
$this->pageInfo = BackendUtility::readPageAccess($this->uid, $this->permsClause);
$this->access = is_array($this->pageInfo);
$this->pageInfo = BackendUtility::readPageAccess($this->uid, $this->permsClause) ?: [];
$this->access = $this->pageInfo !== [];
$this->row = $this->pageInfo;
} else {
$this->row = BackendUtility::getRecordWSOL($this->table, $this->uid);
......@@ -189,8 +189,8 @@ class ElementInformationController
// Make $this->uid the uid of the versioned record, while $this->row['uid'] is live record uid
$this->uid = (int)$this->row['_ORIG_uid'];
}
$this->pageInfo = BackendUtility::readPageAccess((int)$this->row['pid'], $this->permsClause);
$this->access = is_array($this->pageInfo);
$this->pageInfo = BackendUtility::readPageAccess((int)$this->row['pid'], $this->permsClause) ?: [];
$this->access = $this->pageInfo !== [];
}
}
}
......
......@@ -152,7 +152,7 @@ class NewContentElementController
// Setting up the context sensitive menu:
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
// Getting the current page and receiving access information (used in main())
$this->pageInfo = BackendUtility::readPageAccess($this->id, $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW));
$this->pageInfo = BackendUtility::readPageAccess($this->id, $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)) ?: [];
}
/**
......@@ -214,7 +214,7 @@ class NewContentElementController
{
// Setting up the buttons for docheader
$this->getButtons();
$hasAccess = $this->id && is_array($this->pageInfo);
$hasAccess = $this->id && $this->pageInfo !== [];
if ($hasAccess) {
// If a column is pre-set
if (isset($this->colPos)) {
......
......@@ -459,7 +459,7 @@ class EditDocumentController
$this->fixWSversioningInEditConf();
// Prepare R_URL (request url)
$this->R_URL_parts = parse_url($request->getAttribute('normalizedParams')->getRequestUri());
$this->R_URL_parts = parse_url($request->getAttribute('normalizedParams')->getRequestUri()) ?: [];
$this->R_URL_getvars = $queryParams;
$this->R_URL_getvars['edit'] = $this->editconf;
......@@ -1015,8 +1015,8 @@ class EditDocumentController
}
// Access check...
// The page will show only if there is a valid page and if this page may be viewed by the user
$this->pageinfo = BackendUtility::readPageAccess($this->viewId, $this->perms_clause);
if ($this->pageinfo) {
$this->pageinfo = BackendUtility::readPageAccess($this->viewId, $this->perms_clause) ?: [];
if ($this->pageinfo !== []) {
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
}
// Setting up the buttons and markers for doc header
......
......@@ -240,7 +240,7 @@ class NewRecordController
. '</h1>';
// Id a positive id is supplied, ask for the page record with permission information contained:
if ($this->id > 0) {
$this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
$this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause) ?: [];
}
// If a page-record was returned, the user had read-access to the page.
if ($this->pageinfo['uid']) {
......@@ -280,12 +280,7 @@ class NewRecordController
{
// If there was a page - or if the user is admin (admins has access to the root) we proceed:
if (!empty($this->pageinfo['uid']) || $this->getBackendUserAuthentication()->isAdmin()) {
if (empty($this->pageinfo)) {
// Explicitly pass an empty array to the docHeader
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation([]);
} else {
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
}
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation($this->pageinfo);
// Acquiring TSconfig for this module/current page:
$this->web_list_modTSconfig = BackendUtility::getPagesTSconfig($this->pageinfo['uid'])['mod.']['web_list.'] ?? [];
$this->allowedNewTables = GeneralUtility::trimExplode(',', $this->web_list_modTSconfig['allowedNewTables'] ?? '', true);
......@@ -302,7 +297,7 @@ class NewRecordController
$this->newPagesAfter = 0;
}
// Set header-HTML and return_url
if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
if ($this->pageinfo['uid'] ?? false) {
$title = strip_tags($this->pageinfo[$GLOBALS['TCA']['pages']['ctrl']['label']]);
} else {
$title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
......
......@@ -565,22 +565,22 @@ class PageLayoutController
$this->colPosList = implode(',', $backendLayout->getColumnPositionNumbers());
}
// Removing duplicates, if any
$this->colPosList = array_unique(GeneralUtility::intExplode(',', $this->colPosList));
$colPosArray = array_unique(GeneralUtility::intExplode(',', $this->colPosList));
// Accessible columns
if (isset($this->modSharedTSconfig['properties']['colPos_list']) && trim($this->modSharedTSconfig['properties']['colPos_list']) !== '') {
$this->activeColPosList = array_unique(GeneralUtility::intExplode(',', trim($this->modSharedTSconfig['properties']['colPos_list'])));
$activeColPosArray = array_unique(GeneralUtility::intExplode(',', trim($this->modSharedTSconfig['properties']['colPos_list'])));
// Match with the list which is present in the colPosList for the current page
if (!empty($this->colPosList) && !empty($this->activeColPosList)) {
$this->activeColPosList = array_unique(array_intersect(
$this->activeColPosList,
$this->colPosList
if (!empty($colPosArray) && !empty($activeColPosArray)) {
$activeColPosArray = array_unique(array_intersect(
$activeColPosArray,
$colPosArray
));
}
} else {
$this->activeColPosList = $this->colPosList;
$activeColPosArray = $colPosArray;
}
$this->activeColPosList = implode(',', $this->activeColPosList);
$this->colPosList = implode(',', $this->colPosList);
$this->activeColPosList = implode(',', $activeColPosArray);
$this->colPosList = implode(',', $colPosArray);
}
$content .= $this->getHeaderFlashMessagesForCurrentPid();
......
......@@ -191,11 +191,11 @@ class SimpleDataHandlerController
$this->tce->copyTree = MathUtility::forceIntegerInRange($beUser->uc['copyLevels'], 0, 100);
}
if ($beUser->uc['neverHideAtCopy'] ?? false) {
$this->tce->neverHideAtCopy = 1;
$this->tce->neverHideAtCopy = true;
}
// Reverse order.
if ($this->flags['reverseOrder'] ?? false) {
$this->tce->reverseOrder = 1;
$this->tce->reverseOrder = true;
}
}
......
......@@ -93,7 +93,7 @@ class BackendModuleRepository implements SingletonInterface
* Finds a module menu entry by name
*
* @param string $name
* @return \TYPO3\CMS\Backend\Domain\Model\Module\BackendModule|bool
* @return \TYPO3\CMS\Backend\Domain\Model\Module\BackendModule|false
*/
public function findByModuleName($name)
{
......@@ -107,7 +107,7 @@ class BackendModuleRepository implements SingletonInterface
*
* @param string $name
* @param \SplObjectStorage $entries
* @return \TYPO3\CMS\Backend\Domain\Model\Module\BackendModule|bool
* @return \TYPO3\CMS\Backend\Domain\Model\Module\BackendModule|false
*/
public function findByModuleNameInGivenEntries($name, \SplObjectStorage $entries)
{
......
......@@ -41,7 +41,7 @@ final class AfterHistoryRollbackFinishedEvent
private $dataHandlerInput;
/**
* @var BackendUserAuthentication
* @var BackendUserAuthentication|null
*/
private $backendUserAuthentication;
......@@ -88,7 +88,7 @@ final class AfterHistoryRollbackFinishedEvent
return $this->dataHandlerInput;
}
public function getBackendUserAuthentication(): BackendUserAuthentication
public function getBackendUserAuthentication(): ?BackendUserAuthentication
{
return $this->backendUserAuthentication;
}
......
......@@ -36,7 +36,7 @@ final class BeforeHistoryRollbackStartEvent
private $diff;
/**
* @var BackendUserAuthentication
* @var BackendUserAuthentication|null
*/
private $backendUserAuthentication;
......@@ -76,7 +76,7 @@ final class BeforeHistoryRollbackStartEvent
return $this->diff;
}
public function getBackendUserAuthentication(): BackendUserAuthentication
public function getBackendUserAuthentication(): ?BackendUserAuthentication
{
return $this->backendUserAuthentication;
}
......
......@@ -102,7 +102,7 @@ class ModuleTemplate
/**
* Fluid Standalone View
*
* @var StandaloneView
* @var ViewInterface
*/
protected $view;
......
......@@ -33,14 +33,14 @@ class TreeNode implements ComparableNodeInterface, \Serializable
/**
* Parent Node
*
* @var \TYPO3\CMS\Backend\Tree\TreeNode
* @var \TYPO3\CMS\Backend\Tree\TreeNode|null
*/
protected $parentNode;
/**
* Child Nodes
*
* @var \TYPO3\CMS\Backend\Tree\TreeNodeCollection
* @var \TYPO3\CMS\Backend\Tree\TreeNodeCollection|null
*/
protected $childNodes;
......
......@@ -69,15 +69,15 @@ class PagePositionMap
// Element id.
/**
* @var string
* @var int
*/
public $elUid = '';
public $elUid;
// tt_content element uid to move.
/**
* @var string
* @var int
*/
public $moveUid = '';
public $moveUid;
/**
* @var array
......
......@@ -31,6 +31,7 @@ use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Site\Entity\NullSite;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Site\Entity\SiteInterface;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
......@@ -87,7 +88,7 @@ class PageLayoutContext
protected $siteLanguage;
/**
* @var Site
* @var SiteInterface
*/
protected $site;
......
......@@ -220,7 +220,7 @@ class PageLayoutView implements LoggerAwareInterface
/** @var PageLayoutView $pageLayoutView */
$pageLayoutView = GeneralUtility::makeInstance(self::class);
$pageLayoutView->id = $context->getPageId();
$pageLayoutView->pageinfo = BackendUtility::readPageAccess($pageLayoutView->id, '');
$pageLayoutView->pageinfo = BackendUtility::readPageAccess($pageLayoutView->id, '') ?: [];
$pageLayoutView->pageRecord = $context->getPageRecord();
$pageLayoutView->option_newWizard = $drawingConfiguration->getShowNewContentWizard();
$pageLayoutView->defLangBinding = $drawingConfiguration->getDefaultLanguageBinding();
......@@ -244,7 +244,7 @@ class PageLayoutView implements LoggerAwareInterface
$this->resolveSiteLanguages($this->id);
$this->pageRecord = BackendUtility::getRecordWSOL('pages', $this->id);
$this->initializeClipboard();
$this->pageinfo = BackendUtility::readPageAccess($this->id, '');
$this->pageinfo = BackendUtility::readPageAccess($this->id, '') ?: [];
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageActionsCallback = null;
if ($this->isPageEditable()) {
......
......@@ -132,7 +132,7 @@ class Constraint
/**
* Set workspace
*
* @param string $workspace
* @param int $workspace
*/
public function setWorkspaceUid($workspace)
{
......@@ -142,7 +142,7 @@ class Constraint
/**
* Get workspace
*
* @return string
* @return int
*/
public function getWorkspaceUid()
{
......
......@@ -105,7 +105,7 @@ class PermissionController extends ActionController
$this->returnUrl = GeneralUtility::_GP('returnUrl');
if ($this->request->hasArgument('returnUrl')) {
$this->returnUrl = $this->request->getArgument('returnUrl');
$this->returnUrl = (string)$this->request->getArgument('returnUrl');
}
$this->setPageInfo();
......@@ -389,7 +389,7 @@ class PermissionController extends ActionController
*/
protected function setPageInfo(): void
{
$this->pageInfo = BackendUtility::readPageAccess(BackendUtility::getRecord('pages', $this->id) ? $this->id : 0, ' 1=1');
$this->pageInfo = BackendUtility::readPageAccess(BackendUtility::getRecord('pages', $this->id) ? $this->id : 0, ' 1=1') ?: [];
}
/**
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Beuser\Domain\Model;
use TYPO3\CMS\Backend\Authentication\PasswordReset;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* Model for backend user
......@@ -48,7 +49,7 @@ class BackendUser extends \TYPO3\CMS\Extbase\Domain\Model\BackendUser
protected $fileMountPoints = '';
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup>
* @var ObjectStorage<BackendUserGroup>
*/
protected $backendUserGroups;
......@@ -115,7 +116,7 @@ class BackendUser extends \TYPO3\CMS\Extbase\Domain\Model\BackendUser
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $backendUserGroups
* @param ObjectStorage<BackendUserGroup> $backendUserGroups
*/
public function setBackendUserGroups($backendUserGroups)
{
......@@ -123,7 +124,7 @@ class BackendUser extends \TYPO3\CMS\Extbase\Domain\Model\BackendUser
}
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
* @return ObjectStorage<BackendUserGroup>
*/
public function getBackendUserGroups()
{
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Beuser\Domain\Model;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
/**
* Model for backend user group
......@@ -40,7 +41,7 @@ class BackendUserGroup extends AbstractEntity
protected $hidden;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup>
* @var ObjectStorage<BackendUserGroup>
* @Extbase\ORM\Lazy
*/
protected $subGroups;
......@@ -94,7 +95,7 @@ class BackendUserGroup extends AbstractEntity
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $subGroups
* @param ObjectStorage<BackendUserGroup> $subGroups
*/
public function setSubGroups($subGroups)
{
......@@ -102,7 +103,7 @@ class BackendUserGroup extends AbstractEntity
}
/**
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
* @return ObjectStorage<BackendUserGroup>
*/
public function getSubGroups()
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment