Skip to content

Make XP compiler the Babel of PHP #299

@thekid

Description

@thekid

Scope of Change

This RFC suggests changing the PHP language support in the XP Compiler to support all future PHP features (at the time of writing, PHP 7). This would mean you could already start writing PHP 7 code, and could transpile it for running on older, PHP 5.5, environments.

Rationale

Ease adoption of new language features, decouple from slowly adopting production platforms and environments.

Functionality

Design principles

  • The future, now!
  • Valid PHP passes through the compiler untouched (except alternative syntax)
  • Output is as close as possible line/offset/whitespace wise

Compilation

Compilation can either be done explicitly by calling xcc or by using the JIT compiler.

$ xcc -E php5.5 -sp src/main/php -o target/ # Translates PHP 5.6, 7.0 
$ xcc -E php5.6 -sp src/main/php -o target/ # Translates PHP 7.0 features only
$ xcc -E php7.0 -sp src/main/php -o target/ # Copy-through, more or less
# ...

Features

The following are easy:

These need more investigation:

These might not work in a fast and reliable way:

Experimental support could be added for features currently under discussion:

We could also add Hack language features

We might want to include support for PHP 5.6:

Security considerations

Speed impact

Dependencies

Related documents

Inspired by http://channel9.msdn.com/Events/Build/2015/3-644

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions