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

Uninitialized string offset in PHP Tokenizer on PHP 5.2 #1237

Closed
jrfnl opened this issue Dec 13, 2016 · 4 comments
Closed

Uninitialized string offset in PHP Tokenizer on PHP 5.2 #1237

jrfnl opened this issue Dec 13, 2016 · 4 comments

Comments

@jrfnl
Copy link
Contributor

jrfnl commented Dec 13, 2016

I'm receiving a PHP notice on PHP5.2 with PHPCS 2.7.1/master since commit 531a731 which is breaking our builds on PHP5.2

Notice: Uninitialized string offset: 0 in /tmp/phpcs/CodeSniffer/Tokenizers/PHP.php on line 688

@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 13, 2016

More detailed information:

Test code:

<?php
// Comment:
$a ?: $c;

will eventually tokenize as:

0 :: T_OPEN_TAG :: <?php
1 :: T_COMMENT :: // Comment:
2 :: T_NONE ::
3 :: T_VARIABLE :: $a
4 :: T_WHITESPACE ::
6 :: T_INLINE_ELSE :: :
7 :: T_WHITESPACE ::
8 :: T_VARIABLE :: $c
9 :: T_SEMICOLON :: ;

And gives the unitialized string offset issue when dealing with the $a T_VARIABLE token, so it looks like the issue is related to the T_NONE (which I would have expected to be a T_WHITESPACE anyhow).

@gsherwood gsherwood changed the title Uninitialized string offset in PHP Tokenizer Uninitialized string offset in PHP Tokenizer on PHP5.2 Dec 13, 2016
@gsherwood gsherwood changed the title Uninitialized string offset in PHP Tokenizer on PHP5.2 Uninitialized string offset in PHP Tokenizer on PHP 5.2 Dec 13, 2016
@gsherwood
Copy link
Member

I can't get a 5.2 install to check the fix on, so it would be great if you could see if this change fixes the issue. I think it will given the issue itself looks pretty obvious in the code.

@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 13, 2016

All ok now.
Example of build which was failing & now passing: https://travis-ci.org/jrfnl/PHPCompatibility/builds/183551067 (second build in the list - PHP 5.2 with PHPCS master)

@gsherwood
Copy link
Member

Good news. Thanks a lot for testing that for me.

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

Successfully merging a pull request may close this issue.

2 participants