sstalle / php7cc Goto Github PK
View Code? Open in Web Editor NEWPHP 7 Compatibility Checker
License: MIT License
PHP 7 Compatibility Checker
License: MIT License
Composer put its config directory at $HOME/.config/composer
instead of $HOME/.composer
. Consequently the export statement in the install instructions failed for me. It should be export PATH="$PATH:$HOME/.config/composer/vendor/bin"
.
While I was working on packaging of php7cc to introduce it to Debian it came to my attention that php-pimple (direct dependency of php7cc) is not compatible with PHP-7.
Debian is dropping PHP-5 so I wonder if php7cc could switch to PHP-7 compatible alternative of Pimple? The latter FTBFS with PHP-7...
Currently php7cc returns 0 regardless of number of errors detected which makes it hard to integrate into build processes. Preferably php7cc should return something else when warnings and errors occur :)
this will fail when I run code on a server with php 7, but will not display this as a problem when I run php7cc. I had this in several files and it gave me greens across the board.
function randomName($this) {
$do = $this;
return $do;
}
HI,
I was curious what exactly "Nested by-reference foreach loop, make sure there is no iteration over the same array" warning mean?
I am trying to check some websites on a CentOS 5.11 server to get a preliminary idea as to how the php code would fare in an upgrade. I've tried running against various directory paths and get the following back:
PHP Fatal error: Cannot access private property Sstalle\php7cc\Infrastructure\ContainerBuilder::$outputFormat in /root/.composer/vendor/sstalle/php7cc/src/Infrastructure/ContainerBuilder.php on line 210
This is what I'm working with:
# php7cc -V
PHP 7 Compatibility Checker version 1.2.0
# php --version
PHP 5.3.3 (cli) (built: Oct 23 2014 07:48:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
I'm not familiar enough with php to figure out the issue. Let me know if I need to provide any more information. Thanks.
Hello,
Let me start by saying this looks like a very nice tool.
It would be nice to have an 'except' option, to ignore certain folders (ie vendor).
Hi,
Awesome tool, using it right now to have a look at about 200 sites and their possible issues
Just a little question. Any idea what kind of errors this tool would miss? I would assume wrong Exception handling since errors now also throw their an Error, but do you know of any other specifics that you know it will miss?
Regards,
Bjorn.
Hello,
I would like to install this using composer global require sstalle/php7cc
, instead of having to create a project for it.
This would allow me to run php7cc
from anywhere.
Only problem is that it requires an old version of Symfony (2.5.x
) which causes conflicts with other global packages that are requiring 2.7.x
.
Could the dependency be updated safely here ? Or is there any specific reason 2.5.x
is uses ?
Thanks
When i run Php 7 comparability test on my wordpress plugin im getting this error.
PHP Fatal error: Maximum function nesting level of '100' reached, aborting! in /var/www/html/test/vendor/sstalle/php7cc/src/NodeAnalyzer/FunctionAnalyzer.php on line 15 PHP Stack trace: PHP 1. {main}() /var/www/html/test/vendor/sstalle/php7cc/bin/php7cc:0 PHP 2. require() /var/www/html/test/vendor/sstalle/php7cc/bin/php7cc:4 PHP 3. Symfony\Component\Console\Application->run() /var/www/html/test/vendor/sstalle/php7cc/bin/php7cc.php:21 PHP 4. Symfony\Component\Console\Application->doRun() /var/www/html/test/vendor/symfony/console/Application.php:117 PHP 5. Symfony\Component\Console\Application->doRunCommand() /var/www/html/test/vendor/symfony/console/Application.php:186 PHP 6. Symfony\Component\Console\Command\Command->run() /var/www/html/test/vendor/symfony/console/Application.php:818 PHP 7. Sstalle\php7cc\Infrastructure\PHP7CCCommand->execute() /var/www/html/test/vendor/symfony/console/Command/Command.php:256 PHP 8. Sstalle\php7cc\PathCheckExecutor->check() /var/www/html/test/vendor/sstalle/php7cc/src/Infrastructure/PHP7CCCommand.php:128 PHP 9. Sstalle\php7cc\PathChecker->check() /var/www/html/test/vendor/sstalle/php7cc/src/PathCheckExecutor.php:65 PHP 10. Sstalle\php7cc\PathChecker->checkFile() /var/www/html/test/vendor/sstalle/php7cc/src/PathChecker.php:41 PHP 11. Sstalle\php7cc\ContextChecker->checkContext() /var/www/html/test/vendor/sstalle/php7cc/src/PathChecker.php:57 PHP 12. Sstalle\php7cc\NodeTraverser\Traverser->traverse() /var/www/html/test/vendor/sstalle/php7cc/src/ContextChecker.php:50 PHP 13. PhpParser\NodeTraverser->traverse() /var/www/html/test/vendor/sstalle/php7cc/src/NodeTraverser/Traverser.php:28 PHP 14. PhpParser\NodeTraverser->traverseArray() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:64 PHP 15. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:129 PHP 16. PhpParser\NodeTraverser->traverseArray() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84 PHP 17. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:129 PHP 18. PhpParser\NodeTraverser->traverseArray() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84 PHP 19. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:129 PHP 20. PhpParser\NodeTraverser->traverseArray() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:84 PHP 21. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:129 PHP 22. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 23. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 24. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 25. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 26. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 27. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 28. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 29. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 30. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 31. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 32. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 33. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 34. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 35. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 36. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 37. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 38. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 39. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 40. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 41. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 42. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 43. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 44. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 45. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 46. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 47. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 48. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 49. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 50. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 51. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 52. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 53. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 54. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 55. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 56. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 57. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 58. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 59. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 60. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 61. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 62. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 63. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 64. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 65. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 66. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 67. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 68. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 69. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 70. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 71. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 72. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 73. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 74. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 75. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 76. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 77. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 78. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 79. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 80. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 81. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 82. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 83. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 84. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 85. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 86. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 87. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 88. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 89. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 90. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 91. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 92. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 93. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 94. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 95. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 96. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 97. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 98. PhpParser\NodeTraverser->traverseNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:97 PHP 99. Sstalle\php7cc\NodeVisitor\RemovedFunctionCallVisitor->enterNode() /var/www/html/test/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php:88
I am trying to check my project folder and got an error:
I run: php bin/php7cc.php /var/www/example.com/ php
PHP Catchable fatal error: Argument 1 passed to Sstalle\php7cc\Iterator\ExtensionFilteringRecursiveIterator::__construct() must be an instance of RecursiveDirectoryIterator, string given in /home/vagrant/php7cc/src/Iterator/ExtensionFilteringRecursiveIterator.php on line 17
PHP Stack trace:
PHP 1. {main}() /home/vagrant/php7cc/bin/php7cc.php:0
PHP 2. Symfony\Component\Console\Application->run() /home/vagrant/php7cc/bin/php7cc.php:7
PHP 3. Symfony\Component\Console\Application->doRun() /home/vagrant/php7cc/vendor/symfony/console/Symfony/Component/Console/Application.php:124
PHP 4. Symfony\Component\Console\Application->doRunCommand() /home/vagrant/php7cc/vendor/symfony/console/Symfony/Component/Console/Application.php:193
PHP 5. Symfony\Component\Console\Command\Command->run() /home/vagrant/php7cc/vendor/symfony/console/Symfony/Component/Console/Application.php:889
PHP 6. Sstalle\php7cc\Infrastructure\PHP7CCCommand->execute() /home/vagrant/php7cc/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:253
PHP 7. Sstalle\php7cc\PathChecker->check() /home/vagrant/php7cc/src/Infrastructure/PHP7CCCommand.php:71
PHP 8. Sstalle\php7cc\Iterator\ExtensionFilteringRecursiveIterator->getChildren() /home/vagrant/php7cc/src/Infrastructure/PHP7CCCommand.php:78
PHP 9. RecursiveFilterIterator->getChildren() /home/vagrant/php7cc/src/Iterator/ExtensionFilteringRecursiveIterator.php:39
PHP 10. Sstalle\php7cc\Iterator\ExtensionFilteringRecursiveIterator->__construct() /home/vagrant/php7cc/src/Iterator/ExtensionFilteringRecursiveIterator.php:39
PHP Version => 5.3.10-1ubuntu3.14
System => Linux utrip 3.2.0-69-generic-pae #103-Ubuntu SMP Tue Sep 2 05:15:53 UTC 2014 i686
Build Date => Sep 4 2014 07:13:00
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
Additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini,
/etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/mcrypt.ini,
/etc/php5/cli/conf.d/mongodb.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini,
/etc/php5/cli/conf.d/xdebug.ini,
/etc/php5/cli/conf.d/zz-blackfire.ini
PHP API => 20090626
PHP Extension => 20090626
Zend Extension => 220090626
Zend Extension Build => API220090626,NTS
PHP Extension Build => API20090626,NTS
Debug Build => no
Thread Safety => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, zip, phar
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls
Registered Stream Filters => zlib., bzip2., convert.iconv., string.rot13, string.toupper, string.tolower, string.strip_tags, convert., consume
d, dechunk, mcrypt., mdecrypt.
It wasn't immediately obvious for users unfamilar with GitHub.
This is a stub. I'll submit a pull later!
Hi :)
You did an amazing work with this project! I also developed a similar tool (php7-checker). When I started it, the goal was mainly to give a try to the PhpParser project and it was some fun to do it.
Sadly, I didn't find your library before I started mine. But as your library is far more advanced, I propose to deprecate my project in favor of yours. Would you accept some help on php7cc? I can already see some improvements that could be done like:
When run, php7cc outputs error text using only color to indicate the severity. This is an accessibility issue for those with color blindness.
It also means that severity information is lost when the output is piped to a file. For instance, in the following output, the first is a yellow severity and the second is a red severity but when piped there's no indication of that.
File: /Users/.../docroot/modules/field_ui/field_ui.module
Line 278: Function argument(s) returned by "func_get_args" might have been modified
func_get_args();File: /Users/.../docroot/modules/filter/filter.api.php
Line 205: Removed regular expression modifier "e" used
preg_replace('|(.+?)
|se', '[codefilter_code]$1[/codefilter_code]', $text);
I followed the instructions as listed and added the $PATH information into my .bash-profile ... however, it doesn't run. I keep getting this error:
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "php7cc" is not defined.
if I echo $PATH, this is what I get (assuming it's right)
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin:/Users/bmyers/.config/composer/vendor/bin
not sure what I'm doing wrong.
I'm on macOS Sierra running PHP 5.6. I even tried running it locally in my project (installing it there as well per the instructions) and I get the same error.
php7cc -o json /path/to/my/directory/ | json_pp
-o does not work for me
I cannot see the errors. I just take the output of how many files where checked in how much time. Could you please help?
In my PHP7Checker, I also added a checker that looks for redeclaration of functions whose was added in PHP7:
I'm not sure whether it's really pertinent but if you think so, I could port the visitor to php7cc
php7cc
print full file names in File:
field even if I invoke checker from current directory like php7cc .
.
It would be great if php7cc could report file names with relative paths from current directory instead of full paths from root. This would be helpful to report PHP-7 incompatibilities upstream without cluttering php7cc output with meaningless local paths to current working directory.
Thanks.
Is this for php version 7.0 and 7.1?
I stumbled on the following message:
Line 48. Reserved word "resource" used as a class, interface or trait name:
vagrant@php7dev:~$ php -v
PHP 7.0.0-dev (cli) (built: Jul 30 2015 08:09:27)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
vagrant@php7dev:~$ php -r "class Numeric {}; var_dump(new Numeric());"
object(Numeric)#1 (0) {
}
vagrant@php7dev:~$ php -r "class Resource {}; var_dump(new Resource());"
object(Resource)#1 (0) {
}
vagrant@php7dev:~$ php -r "class Mixed {}; var_dump(new Mixed());"
object(Mixed)#1 (0) {
}
Opposed to Bool
that is a reserved word:
vagrant@php7dev:~$ php -r "class Bool {}; var_dump(new Bool());"
Fatal error: Cannot use 'Bool' as class name as it is reserved in Command line code on line 1
It would be really handy, to be able to do something with the returned output, in its current form while not impossible to awk and manipulate it. Would be ideal to have the output as a JSON optionally to be able to parse into other applications.
PHP 7.1 is stable since December 1st, and gives a lot of enhancements. I.e., it allows to add a ?
on method return type to allow null or type (?string
).
php7cc ran on a PHP7.1 project throw following errors:
> Syntax error, unexpected '?' on line 22. Processing aborted.
"You may also need composer to install php7cc."
I don't know, what composer is. I don't want to clutter my server by installing utilities only used for a single program to be used for a limited time and wasting time on learning about them and their possible side effects.
That is why I do not use php7cc, but use e.g. php7mar instead.
With PHP-7.0.5 and PHPUnit-5.3.0 I'm getting the following test failures on Debian:
There were 4 failures:
1) ContextCheckerTest::testMessages with data set #97 ('Escaped unicode codepoints in....test)', '<?php $str = "\u{xyz}";\n', array('Invalid UTF-8 codepoint escap...quence'))
Escaped unicode codepoints in double quoted string (/build/php7cc-1.0.2/test/resource/escapedUnicodeCodepoint/php7/escapedUnicodeCodepointInString.test)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Invalid UTF-8 codepoint escape sequence'
+'Unicode codepoint escaping "\u{xyz}" in a string'
/build/php7cc-1.0.2/test/code/ContextCheckerTest.php:27
2) ContextCheckerTest::testMessages with data set #103 ('Escaped unicode codepoints in....test)', '<?php\n$str = <<<EOD\n \u{xyz}\nEOD;\n\n', array('Invalid UTF-8 codepoint escap...quence'))
Escaped unicode codepoints in heredoc (/build/php7cc-1.0.2/test/resource/escapedUnicodeCodepoint/php7/escapedUnicodeCodepointInHeredoc.test)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Invalid UTF-8 codepoint escape sequence'
+'Unicode codepoint escaping "\u{xyz}" in a string'
/build/php7cc-1.0.2/test/code/ContextCheckerTest.php:27
3) ContextCheckerTest::testMessages with data set #148 ('Invalid octal literal (/build....test)', '<?php\n$i = 0781;\n', array('Invalid numeric literal'))
Invalid octal literal (/build/php7cc-1.0.2/test/resource/invalidOctalLiteral/php7/invalidOctalLiteral.test)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Invalid numeric literal'
+'Invalid octal literal 0781'
/build/php7cc-1.0.2/test/code/ContextCheckerTest.php:27
4) ContextCheckerTest::testMessages with data set #149 ('Invalid octal literal (/build....test)', '<?php\n$i = 011119;\n', array('Invalid numeric literal'))
Invalid octal literal (/build/php7cc-1.0.2/test/resource/invalidOctalLiteral/php7/invalidOctalLiteral.test)
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Invalid numeric literal'
+'Invalid octal literal 011119'
/build/php7cc-1.0.2/test/code/ContextCheckerTest.php:27
Please advise.
Add warnings for the following:
Other tasks:
#!/usr/bin/env php ...
)Lexer\Emulative
?.phar
packages to Github releases pageSetting the --level=error
displays warnings, assuming deprecated messages are classed as warnings (or notices?).
$ php7cc --version
PHP 7 Compatibility Checker version 1.1.0
$ php7cc --level=error .
File: /Volumes/Dev/Test/Foo.php
> Line 5: PHP 4 constructors are now deprecated
function Foo()
{
}
Checked 1 file in 0.005 second
Would you consider porting to the NPM way of doing things?
Test code :
var_dump("\DateTime"::createFromFormat('d', '01'));
with 7.0 :
`object(DateTime)#1 (3) { ["date"]=> string(26) "2017-07-01 05:33:28.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "America/New_York" }`
With php7cc :
Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or ')' on line 4. Processing aborted.
This seems to be rather a lot of false positives returned by this...
File: /home/reedy/mediawiki/img_auth.php
> Line 192: [Warning] Function argument(s) returned by "func_get_args" might have been modified
func_get_args();
The only statements before this is global $wgImgAuthDetails;
-- this isn't any modification
We've seen a lot of these false positives in many functions when scanning MediaWiki and extensions deployed on Wikimedia sites
I can give you some more examples if you want to see if it's possible to improve the detection
Since #9, the minimum requirement for php7cc seems to be PHP 5.5.9 due to the dependency to symfony/expression-language, which requires PHP >= 5.5.9
PHP 7 uses stable sorting algorithm in some cases, which makes sorted order for equal values inconsistent with previous versions.
Links:
I ran on a few files, and i got this error:
Fatal error: Allowed memory size of 36700160 bytes exhausted (tried to allocate 72 bytes) in /root/.composer/vendor/sstalle/php7cc/src/Token/TokenCollection.php on line 18
Call Stack:
0.0001 221280 1. {main}() /root/.composer/vendor/sstalle/php7cc/bin/php7cc:0
0.0003 227112 2. require('/root/.composer/vendor/sstalle/php7cc/bin/php7cc.php') /root/.composer/vendor/sstalle/php7cc/bin/php7cc:4
0.0112 1670272 3. Symfony\Component\Console\Application->run() /root/.composer/vendor/sstalle/php7cc/bin/php7cc.php:21
0.0135 2026696 4. Symfony\Component\Console\Application->doRun() /root/.composer/vendor/symfony/console/Application.php:123
0.0136 2027488 5. Symfony\Component\Console\Application->doRunCommand() /root/.composer/vendor/symfony/console/Application.php:192
0.0136 2028088 6. Symfony\Component\Console\Command\Command->run() /root/.composer/vendor/symfony/console/Application.php:844
0.0140 2032432 7. Sstalle\php7cc\Infrastructure\PHP7CCCommand->execute() /root/.composer/vendor/symfony/console/Command/Command.php:259
0.0333 5421656 8. Sstalle\php7cc\PathCheckExecutor->check() /root/.composer/vendor/sstalle/php7cc/src/Infrastructure/PHP7CCCommand.php:76
0.0338 5469104 9. Sstalle\php7cc\PathChecker->check() /root/.composer/vendor/sstalle/php7cc/src/PathCheckExecutor.php:35
11.0865 30588584 10. Sstalle\php7cc\PathChecker->checkFile() /root/.composer/vendor/sstalle/php7cc/src/PathChecker.php:48
11.0866 30593168 11. Sstalle\php7cc\ContextChecker->checkContext() /root/.composer/vendor/sstalle/php7cc/src/PathChecker.php:63
11.2009 32747280 12. Sstalle\php7cc\NodeTraverser\Traverser->traverse() /root/.composer/vendor/sstalle/php7cc/src/ContextChecker.php:50
11.4681 35558448 13. Sstalle\php7cc\Token\TokenCollection->__construct() /root/.composer/vendor/sstalle/php7cc/src/NodeTraverser/Traverser.php:21
Example:
Indirect variable, property or method access: $this->db->{$this->config[$name]};
Indirect variable, property or method access: $this->{$params['name']};
Indirect variable, property or method access: $schema->{$field['name']};
Indirect variable, property or method access: self::$_request->record->{$detail->to['name']};
Indirect variable, property or method access: self::$_request->record->sku->getFirst()->{$detail->to['name']};
Indirect variable, property or method access: self::$_request->record->{$detail->to['name']};
Indirect variable, property or method access: $record_node->{$schema['node_name']};
...
I know about uniform variable syntax and changed behavior in PHP 7, but there is no problem actually in above code, right?
HI guys,
I'm getting many times this kind of error:
Class/trait/interface "{ClassName}" was added in the global namespace.
I don't undestand why this situation should throws an error in PHP7; at lease, I would expect a warning!
Thanks
wrong place
I think the cost to add support for extensions .inc, .php5, .php4
Pretty sure this is a false positive:
if(!function_exists('intdiv')) {
/**
* Integer division
*
* @param int $dividend Number to be divided.
* @param int $divisor Number which divides the dividend.
* @return int The integer quotient of the division of dividend by divisor.
* @throws ArithmeticError
* @throws DivisionByZeroError
* @see https://wiki.php.net/rfc/intdiv
* @see http://php.net/intdiv
*/
function intdiv($dividend, $divisor) {
$dividend = (int)$dividend;
$divisor = (int)$divisor;
if($divisor === 0) {
throw new DivisionByZeroError("Division by zero");
}
if($dividend === PHP_INT_MIN && $divisor === -1) {
throw new ArithmeticError("Division of PHP_INT_MIN by -1 is not an integer");
}
return (int)($dividend/$divisor);
}
}
Cannot redeclare global function "intdiv"
i.e., the function is wrapped in !function_exists
. That shouldn't error.
Is this correct? If I look here
http://php.net/manual/en/migration70.removed-exts-sapis.php
I can see that mysql is a removed extension, but not mysqli...
As of PHP 7 the keywords listed on this page https://secure.php.net/manual/en/reserved.keywords.php
are allowed as property, constant, and method names of classes, interfaces and traits, except that class may not be used as constant name.
So php7cc shouldn't complain when it encounters a class with a method named switch
f.e.
#!/usr/bin/env php
<?php namespace Scripts;
echo "hello\n";
Namespace declaration statement has to be the very first statement in the script on line 2. Processing aborted.
Shouldn't error. Shebangs are allowed in PHP. Tested in PHP 5.6 and 7.1. No errors.
PHP 7 compatibility checks are not working well, see https://www.drupal.org/node/2760025
[Sun Jul 03 22:59:57.311158 2016] [:error] [pid 3168:tid 1844] [client ::1:54149] PHP Fatal error: 'continue' not in the 'loop' or 'switch' context in httprl\httprl.module on line 1418
Drupal 7 code can be found at https://www.drupal.org/project/httprl.
For this code:
$requests = function () use ($client, $urls, &$tempFiles) {
// ...
foreach ($urls as $url) {
// ...
yield $url => function ($poolOptions) use ($client, $url, $tmpFileName) {
// ...
return $client->getAsync($url, $requestOptions);
};
}
};
php7cc returns:
> Line 87: "yield" usage in expression context
function () use($client, $urls, &$tempFiles) {
};
Seems like there is no possible different behavior error in this code. Am I wrong?
Hi!
I have an error while installing php7cc:
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Dependency resolution completed in 0.044 seconds
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for sstalle/php7cc ^1.1 -> satisfiable by sstalle/php7cc[1.1.0].
- Conclusion: remove nikic/php-parser v2.1.0
- Conclusion: don't install nikic/php-parser v2.1.0
- sstalle/php7cc 1.1.0 requires nikic/php-parser ~1.4 -> satisfiable by nikic/php-parser[v1.4.0, v1.4.1].
- Can only install one of: nikic/php-parser[v1.4.0, v2.1.0].
- Can only install one of: nikic/php-parser[v1.4.1, v2.1.0].
- Installation request for nikic/php-parser (locked at v2.1.0) -> satisfiable by nikic/php-parser[v2.1.0].
Installation failed, reverting ./composer.json to its original content.
It is cos I already have installed php-parser 2.1.0 required by drush.
What the best way to resolve the problem? Is it really needed to require php-parser v1.4 for php7cc or v2.x is ok too?
Thank you!
It seem the "Bitwise shift" test for 32bits system only.
use "PHP_INT_SIZE * 8" to get the real value for the system. or ask for system architecture to be tested in commandline parameters.
I don't want to do a recursive check, but if I do php ../php7cc/bin/php7cc.php *php
in a big project, my shell expands the argument list as expected (matching 88 files), but php7cc dies with [RuntimeException] Too many arguments.
.
Hi,
I like your tool and it works fine so far. But it seems that it is not able to detect removed functions written in uppercase letters (I don't know why someone would do this, but the developer did this in the project I have to upgrade).
For example: mysql_connect() is recognized, MYSQL_CONNECT() is not.
Is there any workaround I could try? Thanks for any suggestions.
Hi !
I didn't really know where to give you this information....
But I created a docker image to run php7cc.
You can find it there https://github.com/ypereirareis/docker-php7cc OR there https://hub.docker.com/r/ypereirareis/php7cc/ and maybe share the information in your documentation ๐
(The travis build is currently running for the first time in case you see the badge before the end of the build ๐ธ )
Thx for your work !
Just wondering if you planned to setup a CI service (like travis, circle or scrutinizer fe) to run tests for PR / commits?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.