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

Wrong constructor ownership when returning an anonymous class #682

Closed
DaGhostman opened this issue Apr 19, 2019 · 2 comments
Closed

Wrong constructor ownership when returning an anonymous class #682

DaGhostman opened this issue Apr 19, 2019 · 2 comments

Comments

@DaGhostman
Copy link

DaGhostman commented Apr 19, 2019

Question Answer
Infection version 0.12.2
Test Framework version PHPUnit 7.5.8
PHP version 7.2.15-0ubuntu0.18.10.2 (NTS)
Platform Ubuntu 18.10
Github Repo https://github.com/phOnion/framework/tree/feature/next

The issue I've encountered is when there is a class method, that returns an anonymous class, which has a constructor. The issue appears to be that it doesn't recognize which class owns the __construct method, this code example seems to reproduce the issue:

class Foo {
    public function bar(): object
    {
        return new class() {
            public function __construct() { /* irrelevant */ }
        };
     }
}

I was able to pinpoint the issue to src/Router/Strategy/Factory/RouteStrategyFactory. This temporary workaround seems to resolve the issue, however it feels nasty 😏

Output with issue
In CodeCoverageMethodIgnoreVisitor.php line 56:
                                    
 Method __construct does not exist
@BackEndTea
Copy link
Member

BackEndTea commented Apr 19, 2019

This looks like a duplicate of #616, which has been fixed with #630. So this should be released with 0.13.0. Could you check if dev-master works correctly for you?

I should've targeted the 0.12 branch with that fix, so it is my fault that its not in the 0.12 releases

@DaGhostman
Copy link
Author

DaGhostman commented Apr 19, 2019

Yep, can confirm it is a duplicate, sorry about that. Looking forward for the release

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

No branches or pull requests

2 participants