You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PHPStan fails on a clean master, so no PR can get a green Tests run #768
vendor/bin/phpstan analyse fails on a clean master (b713b22), so no pull request can get a green Tests run. The three lib/DateTime.php errors below appear at every supported phpVersion.
master currently shows green only because the Tests workflow last ran there on 24 October.
phpstan.neon sets no phpVersion, so PHPStan analyses as the running version and each matrix job (8.1 … 8.7) reports a slightly different set. Forcing it:
Three are @var tags that contradict the native return type, and they fail at 8.1, 8.3 and 8.6 alike:
lib/DateTime.php:43 — @var \DateInterval|false over parent::diff(), whose native return type is DateInterval. DateTime::diff() has not returned false since PHP 8.0, which is below this package's floor of ^8.1, so the |false and the if ($result === false) branch under it look unreachable on every supported version.
lib/DateTime.php:58 — @var DateTime|false over parent::modify(); native type is static(Safe\DateTime)|false at 8.1 and DateTime at 8.6.
lib/DateTime.php:75 — @var DateTime|false over parent::setDate(); native type is DateTime.
The other two are tentative return types, and they move with the version:
lib/DateTime.php:55 — Safe\DateTime::modify() is not covariant with the tentative static(DateTime)|false. Reported at 8.1 and 8.3, not at 8.6.
The @var tags cannot simply lose their |false: whether these methods can return false depends on the version, and phpstan.neon enables bleedingEdge, whose output asks that the cause be fixed rather than suppressed with @phpstan-ignore or a baseline. Dropping the === false branches removes an exception path on any version that can still return false, so the right shape depends on how far back you intend Safe\DateTime to keep throwing DatetimeException. Happy to send a patch once you say which way you would like it.
Note on runtime
These are static-analysis findings. Loading Safe\DateTime emits no deprecations on 8.2, 8.3 or 8.6. Safe\DateTimeImmutable emits 18 on 8.6.0-dev, which is what #767 addresses.
Activity