Skip to content

Commit

Permalink
[BUGFIX] Resolve null coalesce order of operation issues
Browse files Browse the repository at this point in the history
The > operator binds higher than ??, meaning these are always comparing
null to 0.  That is clearly not the intent.

Used command:

> ./Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #97978
Releases: main, 11.5
Change-Id: I3410e087fe7fa214c4cb43312a551d8ca3047e70
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75248
Tested-by: core-ci <typo3@b13.com>
Tested-by: Simon Schaufelberger <simonschaufi+typo3@gmail.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Simon Schaufelberger <simonschaufi+typo3@gmail.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
Crell authored and sbuerk committed Jul 22, 2022
1 parent a799a4d commit c4db019
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
10 changes: 0 additions & 10 deletions Build/phpstan/phpstan-baseline.neon
Expand Up @@ -1130,16 +1130,6 @@ parameters:
count: 1
path: ../../typo3/sysext/core/Classes/Routing/Aspect/MappableProcessor.php

-
message: "#^Comparison operation \"\\>\" between null and 0 is always false\\.$#"
count: 1
path: ../../typo3/sysext/core/Classes/Routing/Aspect/PersistedAliasMapper.php

-
message: "#^Comparison operation \"\\>\" between null and 0 is always false\\.$#"
count: 1
path: ../../typo3/sysext/core/Classes/Routing/Aspect/PersistedPatternMapper.php

-
message: "#^Property TYPO3\\\\CMS\\\\Core\\\\Routing\\\\Enhancer\\\\AbstractEnhancer\\:\\:\\$aspects \\(array\\<TYPO3\\\\CMS\\\\Core\\\\Routing\\\\Aspect\\\\AspectInterface\\>\\) on left side of \\?\\? is not nullable\\.$#"
count: 1
Expand Down
Expand Up @@ -158,7 +158,7 @@ public function resolve(string $value): ?string
{
$value = $this->routeValuePrefix . $this->purgeRouteValuePrefix($value);
$result = $this->findByRouteFieldValue($value);
if ($result[$this->languageParentFieldName] ?? null > 0) {
if (($result[$this->languageParentFieldName] ?? null) > 0) {
return (string)$result[$this->languageParentFieldName];
}
if (isset($result['uid'])) {
Expand Down
Expand Up @@ -158,7 +158,7 @@ public function resolve(string $value): ?string
}
$values = $this->filterNamesKeys($matches);
$result = $this->findByRouteFieldValues($values);
if ($result[$this->languageParentFieldName] ?? null > 0) {
if (($result[$this->languageParentFieldName] ?? null) > 0) {
return (string)$result[$this->languageParentFieldName];
}
if (isset($result['uid'])) {
Expand Down

0 comments on commit c4db019

Please sign in to comment.