This repository installs a set of tools for upgrading PHP installation to PHP 7.
Clone the repository and run composer install
, this will setup all the tool and configure them. This installation only works on Linux.
This is a set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility. It will allow you to analyse your code for compatibility with higher and lower versions of PHP.
php7cc is a command line tool designed to make migration from PHP 5.3-5.6 to PHP 7 easier. It searches for potentially troublesome statements in existing code and generates reports containing file names, line numbers and short problem descriptions. It does not automatically fix code to work with the new PHP version.
In your console run ./vendor/bin/php7cc /path/to/your/code
to run PHP Compatibility checker.
For very old sites, where you want some quick fixes for old the mysql_*
and ereg_*
functions you can include the following shims.
This library attempts to create a drop-in replacement for ext/mysql on PHP 7 using mysqli.
dshafik/php7-mysql-shim bbrala/php7-ereg-shim
composer require dshafik/php7-mysql-shim --dev
Simple shim that can be included in old PHP 5 projects to provide ereg functionality through preg. Makes your life upgrading to PHP 7 a lot easier.
composer require bbrala/php7-ereg-shim --dev
Preg match with the eval flag (/e) has been removed.
<?php
$html = $_POST['html'];
// uppercase headings
$html = preg_replace(
'(<h([1-6])>(.*?)</h\1>)e',
'"<h$1>" . strtoupper("$2") . "</h$1>"',
$html
);
<?php
$html = $_POST['html'];
// uppercase headings
$html = preg_replace_callback(
'(<h([1-6])>(.*?)</h\1>)',
function ($m) {
return "<h$m[1]>" . strtoupper($m[2]) . "</h$m[1]>";
},
$html
);