Problem/Motivation

Symfony 6 adds static return type hinting and Prophecy fails on it. The error message is:

PHP Fatal error:  '\static' is an invalid class name in /var/www/html/drupal/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code on line 8

See the testbot result from the patch from #3161889-198: [META] Symfony 6 compatibility.

Proposed resolution

We can wait for a new release of phpspec/prophecy with the fix for this problem. Only the bug is not yet fixed and we want to start with Symfony 6 on the D10.0.x ASAP. Instead of waiting for a fix and a new release, we can also change the testing for the code that gets static return type hinting from Prophecy to mocking. See: https://github.com/phpspec/prophecy/issues/527.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#2 3250442-2.patch2.03 KBdaffie

Comments

daffie created an issue. See original summary.

daffie’s picture

Status: Active » Needs review
Parent issue: » #3161889: [META] Symfony 6 compatibility
StatusFileSize
new2.03 KB

The fix.

andypost’s picture

does it mean that prophecy (mocking) may hit us other tests too?

The fix looks valid, please elaborate if it makes sense to stop using prophecy in contrib/custom tests

andypost’s picture

Or it's only specific to RequestContext?

daffie’s picture

Issue summary: View changes

Or it's only specific to RequestContext?

The problem is when you are using the return type hint "static" and use Prophecy in testing on that code. You will get the error message from the IS. There is an issue for getting this bug fixed. The problem is that the bug is not fixed at the moment and we cannot start with Symfony 6 in the 10.0.x branch. My idea was to change the use of prophecy to mocking. In that way we can start with Symfony 6 in D10. A kind of quick fix. You can do the same in contrib/custom when you have the same problem and cannot wait until the problem is fixed in Prophecy. See: https://github.com/phpspec/prophecy/issues/527.

Edit: With this change the testbot is green for 9.4.x with Symfony 5.4. No other changes are necessary for core on this problem. See: #3161889-204: [META] Symfony 6 compatibility.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Thank you, the patch makes sense ATM (while no fix for prophecy)

longwave’s picture

+1 to the fix, sometimes having two entirely separate object mocking frameworks available to us is a feature rather than a bug :)

  • catch committed bfd559a on 9.4.x
    Issue #3250442 by daffie, andypost, longwave: [Symfony 6] Symfony 6 adds...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.4.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.