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

Fatal error: Cannot use 'true' as class name as it is reserved #1269

Closed
aj-norman opened this issue Jun 6, 2023 · 2 comments
Closed

Fatal error: Cannot use 'true' as class name as it is reserved #1269

aj-norman opened this issue Jun 6, 2023 · 2 comments
Assignees
Labels
Bug An error or unexpected behavior. Fixed for bug fixes or error corrections
Milestone

Comments

@aj-norman
Copy link

aj-norman commented Jun 6, 2023

Hi,

I'm getting an issue similar to #1149 when using the true return type in PHP 8.2. the error produced the following in terminal:

PHP Fatal error:  Cannot use 'true' as class name as it is reserved in /private/var/folders/s6/mt33vjsn36q1jkdprflfh5cr0000gn/T/MockeryKoER9D on line 1

Env details:

  • PHP 8.2
  • Laravel 10.x
  • PHPUnit 10
  • Mockery 1.6.1

Steps to reproduce:

I have a method similar to the following:

<?php

class Example
{
    public function testMethod(): true
    {
        // ...
    }
}

And in test I am doing the following:

<?php
// ...

$mock = Mockery::mock(Example::class);
$mock->shouldHaveReceived("testMethod")->once();

// ...

Removing the true return type allows the test to pass with the same test code

@ghostwriter ghostwriter added the Bug An error or unexpected behavior. label Jun 6, 2023
@ghostwriter ghostwriter self-assigned this Jun 6, 2023
@ghostwriter ghostwriter added this to the 1.6.2 milestone Jun 6, 2023
@ghostwriter ghostwriter added the Fixed for bug fixes or error corrections label Jun 6, 2023
@ghostwriter
Copy link
Member

Hey @aj-norman,

This issue has been resolved via #1271

Thank you for your contribution.

@aj-norman
Copy link
Author

Thanks for fixing this

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. Fixed for bug fixes or error corrections
Projects
None yet
Development

No branches or pull requests

2 participants