Composer autoload_static.php error under PHP 5.5

Summary (tl;dr)

Composer v1.1 generates a static autoloader for PHP v5.6+ which fails PHP 5.5 syntax checks.

Using an earlier version of Composer or omitting autoload_static.php is an effective workaround until WP Engine’s servers are updated to PHP 5.6 or 7.

Problem

On May 10th, Composer’s v1.1.0 release introduced a faster static autoloader for PHP 5.6 and above. The new code exists in a separate composer/autoload_static.php file which loads conditionally based on PHP version.

In most cases this should be fine, but on Git push, WP Engine syntax-checks every PHP file against PHP 5.5. The autoload_static.php defines object properties with concatenated strings, something that wasn’t possible until PHP 5.6 and so the push fails with this error:

PHP Parse error: syntax error, unexpected '.', expecting ')' in - on line 19

Below are lines 16-20 from autoload_static.php, the concatenated strings in the array values are invalid in PHP 5.5. IOP\ is our project’s namespace.

public static $prefixDirsPsr4 = array (
    'IOP\' => 
    array (
        0 => __DIR__ . '/../../../../..' . '/wp-content/themes/iop',
        1 => __DIR__ . '/../../../../..' . '/wp-content/themes/iop/inc',

Solutions & Workarounds

This problem only exists under PHP 5.5, whose end-of-life date is July 10th, 2016. Once WP Engine updates their servers to PHP 5.6 or 7, the updated autoloaders will validate correctly.

In the meantime, either the autoload_static.php file can be blocked in .gitignore, or a version of Composer prior to 1.1.0 can be used. Composer’s Downloads page documents its --version flag for installing previous versions.

Note that the PHP version used to generate the autoload files does not appear to matter, Composer generated identical files running under PHP 5.5.30 and PHP 7.0.6.

References

Em-based relative breakpoints

Designing with relative breakpoints (no pixels widths!) Crazy, but the thinking is sound: 7 Habits of Highly Effective Media Queries

The next version of Bootstrap is switching to Em-defined breakpoint widths. http://v4-alpha.getbootstrap.com/layout/overview/#responsive-breakpoints

Update: The Bootstrap team reversed course, v4 will use px breakpoints. Discussions on GitHub: #17366#17403 (and way back in 2012: #1943)

While I suspect pixels will win out, the debate goes on. PX, EM or REM Media Queries?

eslint-config-airbnb

Will certainly be switching between “extends”: “airbnb” and “extends”: “airbnb-base/legacy” depending on whether a project’s main developer is writing classic JavaScript or ES6. Seems easily forgettable hope this helps me find the setting when I need it. update: Deprecated! post updated with the newer airbnb-base syntax. eslint-config-airbnb