From bf324b7f55152508dda925713a3eb08699b36a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech> Date: Wed, 20 Sep 2023 23:25:29 +0200 Subject: [PATCH] [TASK] Remove superflous fallback guard in ContentObjectRenderer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `ContentObjectRenderer->getImgResource()` null coalescing operator has been used to guard type errors. That has been guarded by a early array check and ensurance, therefore the guards are obselete. Remove them ! Used command(s): > Build/Scripts/runTests.sh -s phpstanGenerateBaseline Resolves: #101982 Releases: main, 12.4 Change-Id: Ic178e29a5d99ded62738707dc285f2c031330fb3 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81119 Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Oliver Bartsch <bo@cedev.de> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> --- Build/phpstan/phpstan-baseline.neon | 5 ---- .../ContentObject/ContentObjectRenderer.php | 23 +++++++++---------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Build/phpstan/phpstan-baseline.neon b/Build/phpstan/phpstan-baseline.neon index 76378bd0cba2..4c3ec8b310de 100644 --- a/Build/phpstan/phpstan-baseline.neon +++ b/Build/phpstan/phpstan-baseline.neon @@ -2040,11 +2040,6 @@ parameters: count: 1 path: ../../typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php - - - message: "#^Variable \\$fileArray on left side of \\?\\? always exists and is not nullable\\.$#" - count: 11 - path: ../../typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php - - message: "#^Variable \\$pidConf in isset\\(\\) always exists and is not nullable\\.$#" count: 1 diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php index 39174dcc4492..5db361ea5cf0 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php +++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php @@ -3678,7 +3678,7 @@ class ContentObjectRenderer implements LoggerAwareInterface } if (MathUtility::canBeInterpretedAsInteger($file)) { - $treatIdAsReference = $this->stdWrapValue('treatIdAsReference', $fileArray ?? []); + $treatIdAsReference = $this->stdWrapValue('treatIdAsReference', $fileArray); if (!empty($treatIdAsReference)) { $fileReference = $this->getResourceFactory()->getFileReferenceObject($file); $fileObject = $fileReference->getOriginalFile(); @@ -3702,18 +3702,17 @@ class ContentObjectRenderer implements LoggerAwareInterface } } if ($fileObject instanceof File) { - $processingConfiguration = []; - $processingConfiguration['width'] = $this->stdWrapValue('width', $fileArray ?? []); - $processingConfiguration['height'] = $this->stdWrapValue('height', $fileArray ?? []); - $processingConfiguration['fileExtension'] = $this->stdWrapValue('ext', $fileArray ?? []); - $processingConfiguration['maxWidth'] = (int)$this->stdWrapValue('maxW', $fileArray ?? []); - $processingConfiguration['maxHeight'] = (int)$this->stdWrapValue('maxH', $fileArray ?? []); - $processingConfiguration['minWidth'] = (int)$this->stdWrapValue('minW', $fileArray ?? []); - $processingConfiguration['minHeight'] = (int)$this->stdWrapValue('minH', $fileArray ?? []); - $processingConfiguration['noScale'] = $this->stdWrapValue('noScale', $fileArray ?? []); + $processingConfiguration['width'] = $this->stdWrapValue('width', $fileArray); + $processingConfiguration['height'] = $this->stdWrapValue('height', $fileArray); + $processingConfiguration['fileExtension'] = $this->stdWrapValue('ext', $fileArray); + $processingConfiguration['maxWidth'] = (int)$this->stdWrapValue('maxW', $fileArray); + $processingConfiguration['maxHeight'] = (int)$this->stdWrapValue('maxH', $fileArray); + $processingConfiguration['minWidth'] = (int)$this->stdWrapValue('minW', $fileArray); + $processingConfiguration['minHeight'] = (int)$this->stdWrapValue('minH', $fileArray); + $processingConfiguration['noScale'] = $this->stdWrapValue('noScale', $fileArray); $processingConfiguration['sample'] = (bool)$this->stdWrapValue('sample', $fileArray); - $processingConfiguration['additionalParameters'] = $this->stdWrapValue('params', $fileArray ?? []); - $processingConfiguration['frame'] = (int)$this->stdWrapValue('frame', $fileArray ?? []); + $processingConfiguration['additionalParameters'] = $this->stdWrapValue('params', $fileArray); + $processingConfiguration['frame'] = (int)$this->stdWrapValue('frame', $fileArray); if ($fileReference instanceof FileReference) { $processingConfiguration['crop'] = $this->getCropAreaFromFileReference($fileReference, $fileArray); } else { -- GitLab