NOTE
NOTE
NOTE: There is not much point in using this repository. Please see Rector PHP rectorphp/rector for a better solution.
NOTE
NOTE
Convert PHP5 code to PHP7 (scalar type hinted parameters, return types) by reading the PHPdoc blocks of your source file. For example, in PHP5 code if you had @param int $index
, the function signature will be modified as public function myFunc(int $index) {
(Not in packagist yet) Clone/download this repository and install the dependencies using composer.
composer install
Usage:
php php5to7.php [OPTIONS] <file/directory>
--overwrite Instead of outputting the changed source, writes
the php7 changes into the file.
--backup For every file it modifies, copies the original
to filename.php.bak.
-h --help This help message.
<file/directory> The path to the individual file, or a directory
to process every php file recursively.
This should not be used for large projects, mission critical code, etc. This is currently an on-going experiment.
- No typehinting will be done on:
- Parameters that are not documented with PHPdoc blocks
- Parameters that are more than one type, e.g.
string|array
- Parameters other than the basic scalars:
int
,float
,string
, andbool
- Code with scalar typehints may operate slower than code without them (might be negligible)
- Pull requests welcome
- Please use the PSR2 standard with CodeSniffer