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

Error when file ends with "function" #974

Closed
UziTech opened this issue Apr 25, 2016 · 8 comments
Closed

Error when file ends with "function" #974

UziTech opened this issue Apr 25, 2016 · 8 comments

Comments

@UziTech
Copy link

UziTech commented Apr 25, 2016

<?php

function

causes a bunch of undefined index errors

@aik099
Copy link
Contributor

aik099 commented Apr 25, 2016

Can you please write exactly what error text is and with a stack trace?

@aik099
Copy link
Contributor

aik099 commented Apr 25, 2016

Does these notices fail corresponding unit tests?

@UziTech
Copy link
Author

UziTech commented Apr 25, 2016

Notice:  Undefined offset: 4 in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Tokenizers\PHP.php on line 1009
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. PHP_CodeSniffer_File->_parse() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:474
  9. PHP_CodeSniffer_File::tokenizeString() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:695
 10. PHP_CodeSniffer_Tokenizers_PHP->processAdditional() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:1455
Notice:  Undefined offset: 4 in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Tokenizers\PHP.php on line 1015
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. PHP_CodeSniffer_File->_parse() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:474
  9. PHP_CodeSniffer_File::tokenizeString() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:695
 10. PHP_CodeSniffer_Tokenizers_PHP->processAdditional() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:1455
Notice:  Undefined index: content in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Fixer.php on line 139
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. PHP_CodeSniffer_Fixer->startFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:475
Notice:  Undefined index: column in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\WhiteSpace\ScopeIndentSniff.php on line 219
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. Generic_Sniffs_WhiteSpace_ScopeIndentSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573
Notice:  Undefined index: column in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php on line 77
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. Generic_Sniffs_Files_LineLengthSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573
Notice:  Undefined index: column in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php on line 104
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. Generic_Sniffs_Files_LineLengthSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573
  9. Generic_Sniffs_Files_LineLengthSniff->checkLineLength() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php:82
Notice:  Undefined index: column in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php on line 111
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. Generic_Sniffs_Files_LineLengthSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573
  9. Generic_Sniffs_Files_LineLengthSniff->checkLineLength() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php:82
Notice:  Undefined index: content in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php on line 112
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. Generic_Sniffs_Files_LineLengthSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573
  9. Generic_Sniffs_Files_LineLengthSniff->checkLineLength() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php:82
Notice:  Undefined index: column in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php on line 117
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. Generic_Sniffs_Files_LineLengthSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573
  9. Generic_Sniffs_Files_LineLengthSniff->checkLineLength() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php:82
Notice:  Undefined index: length in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php on line 117
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. Generic_Sniffs_Files_LineLengthSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573
  9. Generic_Sniffs_Files_LineLengthSniff->checkLineLength() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff.php:82
Notice:  Undefined index: content in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php on line 2679
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. PHP_CodeSniffer_Standards_AbstractScopeSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573
  9. PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff->processTokenOutsideScope() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\AbstractScopeSniff.php:155
 10. PHP_CodeSniffer_File->getDeclarationName() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\PEAR\Sniffs\NamingConventions\ValidFunctionNameSniff.php:194
Notice:  Undefined index: content in C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\Standards\Generic\Sniffs\NamingConventions\UpperCaseConstantNameSniff.php on line 58
Stack trace:
  1. {main}() C:\Program Files (x86)\PHP\v5.6.18\phpcs:0
  2. PHP_CodeSniffer_CLI->runphpcs() C:\Program Files (x86)\PHP\v5.6.18\phpcs:25
  3. PHP_CodeSniffer_CLI->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:104
  4. PHP_CodeSniffer->processFiles() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\CLI.php:912
  5. PHP_CodeSniffer->processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:629
  6. PHP_CodeSniffer->_processFile() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1732
  7. PHP_CodeSniffer_File->start() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer.php:1854
  8. Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff->process() C:\Program Files (x86)\PHP\v5.6.18\pear\PHP\CodeSniffer\File.php:573

@UziTech
Copy link
Author

UziTech commented Apr 25, 2016

I don't believe there is a unit test for this error

@aik099
Copy link
Contributor

aik099 commented Apr 25, 2016

In PHPUnit if a notice/warning happens during test run it automatically fails the test.

@UziTech
Copy link
Author

UziTech commented Apr 25, 2016

Are you referring to a unit test on the file?

The file is not a valid PHP file.

@gsherwood
Copy link
Member

Issue was in the core tokenizer and has now been fixed. Thanks for reporting it.

@aik099
Copy link
Contributor

aik099 commented Apr 26, 2016

Are you referring to a unit test on the file?

@UziTech , I was talking about unit test for sniff that used tokenizer, that in turn triggered that error.

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.

3 participants