Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Duplicate type null is redundant #1204

Closed
thomasschiet opened this issue Jan 16, 2023 · 2 comments · Fixed by #1205
Closed

PHP Fatal error: Duplicate type null is redundant #1204

thomasschiet opened this issue Jan 16, 2023 · 2 comments · Fixed by #1205
Labels
Bug An error or unexpected behavior.
Milestone

Comments

@thomasschiet
Copy link
Contributor

thomasschiet commented Jan 16, 2023

Since upgrading to PHP 8.2, I cannot mock SplFileObject.

Mockery::mock(SplFileObject::class, ['php://memory']);

This yields the following error:

PHP Fatal error:  Duplicate type null is redundant in /app/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php(34) : eval()'d code on line 1174

In EvalLoader.php(34) : eval()'d code line 1174:
                                    
  Duplicate type null is redundant  
                                    

Happens on versions 1.5.1 and dev-master 3c3ca93.

@thomasschiet
Copy link
Contributor Author

thomasschiet commented Jan 16, 2023

The problem seems to be with the getChildren method on SplFileObject, which has the null standalone type since PHP 8.2.

The generated code is:

    public function getChildren(): null|null{
$argc = func_num_args();
$argv = func_get_args();
$ret = $this->_mockery_handleMethodCall(__FUNCTION__, $argv);
return $r

If others have the same issue, you can consider using a partial mock, this does not generate code for the affected method.

Mockery::mock(SplFileObject::class . '[isReadable,fgetcsv]', ['php://memory'])

@ghostwriter
Copy link
Member

Resolved via #1205

@ghostwriter ghostwriter added this to the 1.5.2 milestone Apr 20, 2023
@ghostwriter ghostwriter added the Bug An error or unexpected behavior. label Apr 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug An error or unexpected behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants