Skip to content

Conversation

@Litarnus
Copy link
Contributor

@Litarnus Litarnus commented Oct 9, 2025

Needs #1936 merged first to fix compatibility for older PHP versions

@Litarnus Litarnus self-assigned this Oct 9, 2025
@Litarnus Litarnus marked this pull request as ready for review October 9, 2025 13:36
cursor[bot]

This comment was marked as outdated.

if (strpos($class, '\\Tests\\') > 0) {
$ns = str_replace('\\Tests\\', '\\', $class);
$mockedNs[] = substr($ns, 0, strrpos($ns, '\\'));
} elseif (str_starts_with($class, 'Tests\\')) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the str_starts_with() function, which is only available in PHP 8.0 and later. The project's composer.json file, however, specifies support for PHP versions ^7.2|^8.0. Because ClockMock::register() is called in tests/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 a Fatal 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.

@Litarnus Litarnus requested a review from cleptric October 9, 2025 13:58
@Litarnus Litarnus merged commit e3933fa into 5.x Oct 13, 2025
38 checks passed
@Litarnus Litarnus deleted the merge-master branch October 13, 2025 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants