Merge master#1935
Conversation
# Conflicts: # psalm.xml.dist # tests/Metrics/MetricsTest.php
| if (strpos($class, '\\Tests\\') > 0) { | ||
| $ns = str_replace('\\Tests\\', '\\', $class); | ||
| $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); | ||
| } elseif (str_starts_with($class, 'Tests\\')) { |
There was a problem hiding this comment.
Potential bug: The code uses str_starts_with(), which is incompatible with the project's supported PHP 7.x versions, causing a fatal error when tests are run on those versions.
-
Description: The
ClockMock::register()method uses thestr_starts_with()function, which is only available in PHP 8.0 and later. The project'scomposer.jsonfile, however, specifies support for PHP versions^7.2|^8.0. BecauseClockMock::register()is called intests/bootstrap.php, this code is executed whenever the test suite runs. On environments using PHP 7.2, 7.3, or 7.4, this will cause aFatal error: Uncaught Error: Call to undefined function str_starts_with(), which will prevent the test suite from running. -
Suggested fix: To ensure compatibility with PHP 7.2+, replace the call to
str_starts_with($class, 'Tests\\')with its equivalent,strpos($class, 'Tests\\') === 0. This pattern is already used in other parts of the codebase.
severity: 0.85, confidence: 0.98
Did we get this right? 👍 / 👎 to inform future reviews.
Needs #1936 merged first to fix compatibility for older PHP versions