Skip to content

CASE conditions using class constants named NAMESPACE/INTERFACE/TRAIT etc are incorrectly tokenized #1218

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

Closed
felixfbecker opened this issue Nov 22, 2016 · 11 comments

Comments

@felixfbecker
Copy link

https://travis-ci.org/felixfbecker/php-language-server#L189

@gsherwood
Copy link
Member

I ran your phpcs.xml file over that file from the error message using 2.7.0, 3.0.0RC1 and both the master and 3.0 branches and I can't replicate any problems.

I've also cloned your repo and run PHPCS directly inside it to see if it is an integration issue, and I get no errors.

I've tried PHP 7 and PHP 5 version, with no difference either.

Is this an error you can actually reproduce?

@felixfbecker
Copy link
Author

Yes, it happens locally and in CI, on the completion branch.

@gsherwood
Copy link
Member

Thanks. I missed the branch name. Strangely, Travis shows master as the branch for that failed build, but that's obviously not the case.

@gsherwood
Copy link
Member

Smallest bit of code to replicate:

switch ($foo) {
    case Foo::NAMESPACE:
        return true;
}

@gsherwood gsherwood changed the title Undefined index: scope_opener in src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php CASE conditions using class constants named NAMESPACE/INTERFACE/TRAIT etc are incorrectly tokenized Nov 23, 2016
gsherwood added a commit that referenced this issue Nov 23, 2016
…CE/INTERFACE/TRAIT etc are incorrectly tokenized
@gsherwood
Copy link
Member

Thanks for the report. It has been fixed.

I've moved the code that determines that NAMEPSACE (etc) in Foo::NAMESPACE from the second pass to the first pass so that scope matching works correctly.

gsherwood added a commit that referenced this issue Nov 23, 2016
@felixfbecker
Copy link
Author

any ETA for a release containing the fix?

@gsherwood
Copy link
Member

any ETA for a release containing the fix?

Hopefully next week.

@felixfbecker
Copy link
Author

@gsherwood I need to merge that PR, but it breaks the build because of this bug. Tried updating to latest master, but apparently the Config class was removed?

@gsherwood
Copy link
Member

The Config class doesn't exist in the master branch. It's a new class in 3.x, so you'd want to pull from the 3.0 branch.

@felixfbecker
Copy link
Author

Thanks, it works now

@felixfbecker
Copy link
Author

felixfbecker commented Jan 25, 2017

@gsherwood I really need this fix and depending on the dev branch broke my builds multiple times now. Could you tag a new RC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants