Issue Task Resolved

#110326Make tableDef split in CacheLifetimeCalculator explicit

Stefan Bürk 07/30/26, 04:35 updated 07/30/26, 05:30

Description

The nightly builds of main and 14.3 fail in the “phpstan … max” job since 2026-07-30 with a single error:

bc. typo3/sysext/frontend/Classes/Cache/CacheLifetimeCalculator.php
203 Variable $pid in isset() always exists and is not nullable.
isset.variable

Cause

phpstan/phpstan 2.2.7, released 2026-07-29 17:39 UTC – about seven hours before the main nightly started. That release reworks certainty handling for isset(), empty() and the null coalescing operators, in particular phpstan-src#6109 phpstan-src#6130 (“Do not let type narrowing define a certainly-undefined variable”).

The affected code is in typo3/sysext/frontend/Classes/Cache/CacheLifetimeCalculator.php, method getFirstTimeValueForRecord(). It destructures the “tablename:pid” argument with a list assignment:

bc. [$tableName, $pid] = GeneralUtility::trimExplode(‘:’, $tableDef);

and then guards the result with a condition combining an empty() check on the table name with a negated isset() check on the pid, throwing an InvalidArgumentException when either fails.

GeneralUtility::trimExplode() is annotated with a conditional return type resolving to a list of string. PHPStan 2.2.7 now treats $pid from that destructuring as a defined, non-nullable string, so it reports the isset() guard as redundant.

Worth noting: PHPStan is being optimistic here. A list type carries no length information, so at runtime $pid genuinely is undefined when the argument contains no colon – which is exactly the case the guard and the InvalidArgumentException exist for. The guard must stay; it only has to be written in a form the analyser can follow.

Impact

Analysis only, no runtime behaviour change. The same code exists unchanged in 13.4, which is not affected today only because the 13.4 nightly has no integrity stage.

Steps to reproduce

bc. Build/Scripts/runTests.sh -s composerInstallMax
Build/Scripts/runTests.sh -s phpstan — —no-progress

Proposed solution

Split explicitly instead of relying on list destructuring plus isset(), reading both parts with a null coalescing default and comparing them explicitly. Runtime semantics are preserved, including the empty() to identity comparison equivalence for an already trimmed string, and the guard stays effective for malformed input.

Additionally raise the minimum required version of phpstan/phpstan to 2.2.7 in the root manifest, so that locked pre-merge runs analyse with the same version that uncovered this. The component is declared only there, as a development requirement, and all three branches currently declare the same constraint, so no backport difference applies for that part.

Verification

Verified locally on main. With all dependencies at max, pinning phpstan/phpstan back to 2.2.6 while leaving everything else at max removes the error, which isolates the analyser release as the only trigger. With the proposed change applied, PHPStan reports no errors under both 2.2.6 and 2.2.7, so the code change itself is version neutral.

Also green with the change applied: cglGit, checkIntegrityPhp, and the CacheLifetimeCalculator functional test on both sqlite and mariadb.

Failing pipelines

Reviews 3

History 26

  1. Stefan Bürk commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-07-30T05:30:12+00:00" > 07/30/26, 05:30 </span>

    Applied in changeset commit:5fcdacd0e13c2d0ed6c87b3c475ccb56403959f8.