Skip to content

Test Stub generated by return value generator for doubled method with static return type declaration is not properly initialized #5874

@frenchcomp

Description

@frenchcomp
Q A
PHPUnit version 11.2+
PHP version 8.2+
Installation Method Composer

Summary

Hi,
Since PHPUnit 11.2, I have issue when I want mock Symfony Process. I have no issue with PHPUnit 11.1 and priors versions.

Current behavior

When a mock the Symfony Process class, when I call a method on an instance of this mock, I have the error :
_Typed property MockObject_Process_XXXX::$_phpunit_state must not be accessed before initialization
I had test with define an expects() on the mock, but I had always the error.

There was 1 error:

  1. Test\IssueTest::testBug
    Error: Typed property MockObject_Process_62f16cad::$__phpunit_state must not be accessed before initialization

How to reproduce

I have reproducted the issue in this repository https://github.com/frenchcomp/test_phpunit_11_2_process
You can run the test case in the src folder : vendor/bin/phpunit src/IssueTest.php

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions