wapmorgan / PhpDeprecationDetector

Analyzer of PHP code to search issues with deprecated functionality in newer interpreter versions.
http://wapmorgan.github.io/PhpDeprecationDetector/
BSD 3-Clause "New" or "Revised" License
364 stars 37 forks source link

PHP Errors and Notices at various sample files #36

Closed danielmarschall closed 5 years ago

danielmarschall commented 5 years ago

Hello,

I was using PHP codefixer to scan all PHP files on my server. I found a few files which caused PHP notices and PHP errors.

Here you can find all samples and their respective error messages: https://misc.daniel-marschall.de/bugreports/php_codefixer/

Sample 1: A file from the nextgen-gallery plugin of Wordpress. Bug 1.1: Notice: Undefined offset: 0 in phar:///.../phpcf.phar/data/define_case_insensitive.php on line 13 Bug 1.2: Fatal error: Uncaught TypeError: Argument 1 passed to wapmorgan\PhpCodeFixer\PhpCodeFixer::divideByComma() must be of the type array, null given, called in phar:///.../phpcf.phar/data/define_case_insensitive.php on line 13 and defined in phar:///.../phpcf.phar/src/PhpCodeFixer.php:462

Sample 2: dotclear.php file of an old Wordpress admin area. Bug 2.1: Notice: Undefined offset: 0 in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 11 Bug 2.2: Fatal error: Uncaught TypeError: Argument 1 passed to wapmorgan\PhpCodeFixer\PhpCodeFixer::divideByComma() must be of the type array, null given, called in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 11 and defined in phar:///.../phpcf.phar/src/PhpCodeFixer.php:462

Sample 3: A stringparser class, version A Bug 3.1: Notice: Undefined offset: 0 in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 12 Bug 3.2: Fatal error: Uncaught TypeError: Argument 1 passed to wapmorgan\PhpCodeFixer\PhpCodeFixer::trimSpaces() must be of the type array, null given, called in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 12 and defined in phar:///.../phpcf.phar/src/PhpCodeFixer.php:477

Sample 4: A bbcode class, version A Bug 4.1: Notice: Undefined offset: 0 in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 12 Bug 4.2: Fatal error: Uncaught TypeError: Argument 1 passed to wapmorgan\PhpCodeFixer\PhpCodeFixer::trimSpaces() must be of the type array, null given, called in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 12 and defined in phar:///.../phpcf.phar/src/PhpCodeFixer.php:477

Sample 5: A stringparser class, version B Bug 5.1: Notice: Undefined offset: 0 in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 12 Bug 5.2: Fatal error: Uncaught TypeError: Argument 1 passed to wapmorgan\PhpCodeFixer\PhpCodeFixer::trimSpaces() must be of the type array, null given, called in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 12 and defined in phar:///.../phpcf.phar/src/PhpCodeFixer.php:477

Sample 6: A bbcode class, version B Bug 6.1: Notice: Undefined offset: 0 in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 12 Bug 6.2: Fatal error: Uncaught TypeError: Argument 1 passed to wapmorgan\PhpCodeFixer\PhpCodeFixer::trimSpaces() must be of the type array, null given, called in phar:///.../phpcf.phar/data/preg_replace_e_modifier.php on line 12 and defined in phar:///.../phpcf.phar/src/PhpCodeFixer.php:477

Version used: 2.0.17

wapmorgan commented 5 years ago

Check out dev-master version.

danielmarschall commented 5 years ago

How do I build the PHAR file to test it?

wapmorgan commented 5 years ago

Unzip and try this package phpcf-dev.zip

danielmarschall commented 5 years ago

Thank you very much for sending the new build.  I have run the script against all the files on my server again, and I found another small problem which I didn't find earlier because I grep'ed for "Stack " (which is now all empty). Now I also grep'ed for "on line".

Here is the output:

File /.../owncloud/public_html/lib/composer/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php  5.3 | /daten/homes/owncloud/public_html/lib/composer/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php:33      | ini              | Ini safe_mode is deprecated.

Total problems: 1

PHP Notice:  Uninitialized string offset: 1 in phar:///..../phpcf.phar/src/PhpCodeFixer.php on line 362

Here is the source file:  https://misc.daniel-marschall.de/bugreports/php_codefixer/sample_7.phps

wapmorgan commented 5 years ago

Hm... This problem was fixed too, now the output is

D:\Загрузки>php phpcf-dev.phar sample_7.phps
Max file size set to: 1.000 MiB

File sample_7.phps
 PHP | File:Line                           |             Type | Issue
 5.3 | \sample_7.phps:33                   | ini              | Ini safe_mode is deprecated.

Total problems: 1
Peak memory usage: 2.807 MB
danielmarschall commented 5 years ago

I'm sorry, I was providing the wrong sample file. Here is the correct sample 7 which shows the PHP notice in your current developer build: https://misc.daniel-marschall.de/bugreports/php_codefixer/sample_7.phps

wapmorgan commented 5 years ago

Fixed phpcf-dev.zip. Check out

danielmarschall commented 5 years ago

Why did you open this ticket again? (did you want to re-open #39?)

PS: I have tested your new developer build, and now all PHP warnings/notices are resolved.

wapmorgan commented 5 years ago

Ok, this one is resolved.