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

Undefined offset when explaining standard with custom sniffs #1334

Closed
dereuromark opened this issue Feb 3, 2017 · 6 comments
Closed

Undefined offset when explaining standard with custom sniffs #1334

dereuromark opened this issue Feb 3, 2017 · 6 comments

Comments

@dereuromark
Copy link
Contributor

dereuromark commented Feb 3, 2017

When running

vendor/bin/phpcs --standard=PSR2R/ruleset.xml -e

I get

The PSR2R standard contains 103 sniffs

...
Notice: Undefined offset: 4 in ...\squizlabs\php_codesniffer\src\Ruleset.php on line 263
Notice: Undefined offset: 5 in ...

for current develop branch.

Using 3.0RC3

@gsherwood
Copy link
Member

This doesn't happen for the included sniffs. Can you please post your custom ruleset?

@dereuromark
Copy link
Contributor Author

It is linked in the above Development branch: https://github.com/php-fig-rectified/psr2r-sniffer/blob/master/PSR2R/ruleset.xml

@gsherwood
Copy link
Member

I don't get any notices when running outside your repository, but I can replicate after cloning your repo and running it from there. I'll take a look and see if I can figure out what is going on.

@dereuromark
Copy link
Contributor Author

Thx!
PS: your tokenizer requires a constant somewhere inside which makes it quite the overhead to get it up and running (seee here) without overhead. Ideally this should only be new File() with empty config and ruleset and then be able to tokenize a file IMO.

@gsherwood
Copy link
Member

If you want to tokenize a file or string with reports etc, this is the code: https://gist.github.com/gsherwood/aafd2c16631a8a872f0c4a23916962ac

Or just to get tokens (this is a JS example, but would work for PHP too): https://gist.github.com/gsherwood/f17cfc90f14a9b29eeb6b2e99e6e7f66

I don't think it's that bad.

@gsherwood gsherwood changed the title Undefined offset for -e Undefined offset when explaining standard with custom sniffs Feb 5, 2017
@gsherwood
Copy link
Member

There was an easier way to do the explain in 3.0 because all the codes are recorded elsewhere, so I've changed the method to use the information the Ruleset already had, which fixes this issue.

Thanks for reporting it.

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