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

Analyze error for class definition inside of if(class_exists(... #5801

Closed
aguenther opened this issue Mar 8, 2021 · 3 comments
Closed

Analyze error for class definition inside of if(class_exists(... #5801

aguenther opened this issue Mar 8, 2021 · 3 comments
Labels

Comments

@aguenther
Copy link

Bug Report

Subject Details
Rector version Rector 0.9.31
Installed as composer dependency

If a PHP file checks for the existence of a class before defining it, Rector throws an Analyze Error: "Class X was not found while trying to analyse it", and skips the entire file.

Minimal PHP Code Causing Issue

<?php
if (!class_exists('Foobaer')) {
    class Foobaer {

    }
}

Expected Behaviour

Rector should be able to analyse a file with such a construct in it, without throwing errors

@aguenther aguenther added the bug label Mar 8, 2021
@TomasVotruba
Copy link
Member

This should be solved by static reflection merged a week ago: #5665

It's still not released, because it needs in-depth testing.
Could you verify this works with dev-master?

@aguenther
Copy link
Author

I can verify that this indeed does work with dev-master 👍

@samsonasik
Copy link
Member

Closing as works in dev-master then. @aguenther thank you for verify.

TomasVotruba added a commit that referenced this issue Apr 3, 2024
rectorphp/rector-src@a43f371 [CodeQuality] Handle Switch maybe return on ExplicitReturnNullRector (#5801)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants