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

Function exists checks are not passing the checker #65

Open
hkdobrev opened this issue Apr 3, 2018 · 4 comments
Open

Function exists checks are not passing the checker #65

hkdobrev opened this issue Apr 3, 2018 · 4 comments

Comments

@hkdobrev
Copy link

hkdobrev commented Apr 3, 2018

I have code similar to:

if (function_exists('xdebug_get_function_stack')) {
	$trace = array_slice(array_reverse(xdebug_get_function_stack()), 4);
}

So running this with XDebug extension would get the trace differently, but it could work without XDebug. There could be other conditional uses of a function or a class, especially for backwards-compatibility.

However, the checker complains about these function uses as the parses doesn't detect the function_exists condition.

@hkdobrev
Copy link
Author

hkdobrev commented Apr 3, 2018

class_exists checks are also quite common and would probably also suffer from the same issue.

@Ocramius
Copy link
Collaborator

Ocramius commented Apr 3, 2018 via email

MidnightDesign pushed a commit to MidnightDesign/ComposerRequireChecker that referenced this issue Sep 17, 2020
@VincentLanglet
Copy link
Contributor

class_exists checks are also quite common and would probably also suffer from the same issue.

I just encounter the issue with code like

        if (class_exists(CacheTokenParser::class)) {
            $this->addTokenParser(new CacheTokenParser());
        }

It's the only use of CacheTokenParser and it's reported as an error by composer-require-checker.

But not sure it can be solved.

@Ocramius
Copy link
Collaborator

Ocramius commented Dec 7, 2022

@VincentLanglet that's something you'd exclude manually via config.

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

3 participants