PHP code example of monque / php-migration

1. Go to this page and download the library: Download monque/php-migration library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

monque / php-migration example snippets


    wget https://github.com/monque/PHP-Migration/releases/download/v0.2.2/phpmig.phar
    

    php phpmig.phar sample.php
    
 php
    
    // Fatal error: Only variables can be passed by reference
    array_shift(array(1, 2));
    sort(array(1, 2, 3));

    // __DIR__ is pre-defined
    define('__DIR__', dirname(__FILE__));

    // Fatal error: Cannot redeclare class_alias()
    function class_alias() {}

    // This is fine
    if (!function_exists('class_alias')) {
        function class_alias() {}
    }

    // Fatal error: Call-time pass-by-reference has been removed
    array_map('trim', &$_SERVER);

    // Fatal error: 'break' operator with non-constant operand is no longer supported
    while (true) {
        break $a;
    }

    // Fatal error: Cannot re-assign auto-global variable _GET
    function ohno($_GET) {}

    // Array keys won't be overwritten when defining an array as a property of a class via an array literal
    class C {
        const ONE = 1;
        public $array = [
            self::ONE => 'foo',
            'bar',
            'quux',
        ];
    }

    // set_exception_handler() is no longer guaranteed to receive Exception objects
    set_exception_handler(function (Exception $e) { });

    // Changes to the handling of indirect variables, properties, and methods
    echo $$foo['bar']['baz'];

    // foreach no longer changes the internal array pointer
    foreach ($list as &$row) {
        current($list);
    }
    

php phpmig.phar -s classtree .

    git clone https://github.com/monque/PHP-Migration.git php-migration
    cd php-migration
    

    curl -sS https://getcomposer.org/installer | php
    php composer.phar install
    

    php bin/phpmig
    
 php

unpack($obj->getFormat(), $data); // OMG, What is $obj? How getFormat() works?
unpack('b3', $data); // Works in new version
unpack('a3', $data); // Affected