Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
os: [ubuntu-latest, windows-latest]

steps:
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ XP Compiler
[![Build status on GitHub](https://github.com/xp-framework/compiler/workflows/Tests/badge.svg)](https://github.com/xp-framework/compiler/actions)
[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)
[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)
[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)
[![Requires PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)
[![Latest Stable Version](https://poser.pugx.org/xp-framework/compiler/version.svg)](https://packagist.org/packages/xp-framework/compiler)

Compiles future PHP to today's PHP.
Expand All @@ -16,7 +15,7 @@ After adding the compiler to your project via `composer require xp-framework/com

Example
-------
The following code uses Hack language, PHP 8.6, PHP 8.5, PHP 8.4, PHP 8.3, PHP 8.2, 8.1 and 8.0 features but runs on anything >= PHP 7.4. Builtin features from newer PHP versions are translated to work with the currently executing runtime if necessary.
The following code uses Hack language, PHP 8.6, PHP 8.5, PHP 8.4, PHP 8.3, PHP 8.2, 8.1 and 8.0 features but runs on anything >= PHP 8.0. Builtin features from newer PHP versions are translated to work with the currently executing runtime if necessary.

```php
<?php // In a file "HelloWorld.php"
Expand Down Expand Up @@ -62,11 +61,11 @@ $ xp compile -o dist.xar src/main/php/
# Compile src/main/php, do not write output
$ xp compile -n src/main/php/

# Target PHP 7.4 (default target is current PHP version)
$ xp compile -t php:7.4 HelloWorld.php HelloWorld.class.php
# Target PHP 8.0 (default target is current PHP version)
$ xp compile -t php:8.0 HelloWorld.php HelloWorld.class.php

# Emit XP meta information (includes lang.ast.emit.php.XpMeta):
$ xp compile -t php:7.4 -a php:xp-meta -o dist src/main/php
$ xp compile -t php:8.0 -a php:xp-meta -o dist src/main/php
```

The -o and -n options accept multiple input sources following them.
Expand All @@ -75,7 +74,7 @@ The -q option suppresses all diagnostic output except for errors.
Features supported
------------------

XP Compiler supports features such as annotations, arrow functions, enums, property type-hints, the null-safe instance operator as well as all PHP 7 and PHP 8 syntax additions. A complete list including examples can be found [in our Wiki](https://github.com/xp-framework/compiler/wiki).
XP Compiler supports features such as annotations, arrow functions, enums, property type-hints, the null-safe instance operator as well as all PHP 8 syntax additions. A complete list including examples can be found [in our Wiki](https://github.com/xp-framework/compiler/wiki).

### More features

Expand All @@ -89,7 +88,6 @@ $ xp compile
Usage: xp compile <in> [<out>]

@FileSystemCL<./vendor/xp-framework/compiler/src/main/php>
lang.ast.emit.PHP74
lang.ast.emit.PHP80
lang.ast.emit.PHP81
lang.ast.emit.PHP82
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"xp-framework/core": "^12.0 | ^11.6 | ^10.16",
"xp-framework/reflection": "^3.2 | ^2.15",
"xp-framework/ast": "^13.0 | ^12.2",
"php" : ">=7.4.0"
"php" : ">=8.0.0"
},
"require-dev" : {
"xp-framework/test": "^2.0 | ^1.5"
Expand Down
30 changes: 0 additions & 30 deletions src/main/php/lang/ast/emit/ArbitrayNewExpressions.class.php

This file was deleted.

67 changes: 0 additions & 67 deletions src/main/php/lang/ast/emit/AttributesAsComments.class.php

This file was deleted.

32 changes: 0 additions & 32 deletions src/main/php/lang/ast/emit/ChainScopeOperators.class.php

This file was deleted.

7 changes: 1 addition & 6 deletions src/main/php/lang/ast/emit/Declaration.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@
use lang\reflection\Modifiers;

class Declaration extends Type {
private $type, $codegen;

static function __static() { }

/** @param lang.ast.nodes.TypeDeclaration $type */
public function __construct($type, $codegen) {
$this->type= $type;
$this->codegen= $codegen;
}
public function __construct(private $type, private $codegen) { }

/** @return string */
public function name() { return ltrim($this->type->name, '\\'); }
Expand Down
6 changes: 1 addition & 5 deletions src/main/php/lang/ast/emit/Escaping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
use io\streams\OutputStream;

class Escaping implements OutputStream {
private $target, $replacements;

public function __construct(OutputStream $target, array $replacements) {
$this->target= $target;
$this->replacements= $replacements;
}
public function __construct(private OutputStream $target, private array $replacements) { }

public function write($bytes) {
$this->target->write(strtr($bytes, $this->replacements));
Expand Down
11 changes: 4 additions & 7 deletions src/main/php/lang/ast/emit/GeneratedCode.class.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<?php namespace lang\ast\emit;

class GeneratedCode extends Result {
private $prolog, $epilog;

/**
* Starts a result stream, including an optional prolog and epilog
*
* @param io.streams.OutputStream $out
* @param string $prolog
* @param string $epilog
* @param io.streams.OutputStream $out
* @param string $prolog
* @param string $epilog
*/
public function __construct($out, $prolog= '', $epilog= '') {
$this->prolog= $prolog;
$this->epilog= $epilog;
public function __construct($out, private $prolog= '', private $epilog= '') {
parent::__construct($out);
}

Expand Down
5 changes: 1 addition & 4 deletions src/main/php/lang/ast/emit/InType.class.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?php namespace lang\ast\emit;

class InType {
public $type;
public $meta= [];
public $init= [];
public $statics= [];
public $virtual= [];

public function __construct($type) {
$this->type= $type;
}
public function __construct(public $type) { }
}
5 changes: 2 additions & 3 deletions src/main/php/lang/ast/emit/Incomplete.class.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php namespace lang\ast\emit;

class Incomplete extends Type {
private $name;

/** @param string $name */
public function __construct($name) { $this->name= $name; }
/** Creates a new incomplete type */
public function __construct(private string $name) { }

/** @return string */
public function name() { return $this->name; }
Expand Down
44 changes: 0 additions & 44 deletions src/main/php/lang/ast/emit/MatchAsTernaries.class.php

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/php/lang/ast/emit/NonCapturingCatchVariables.class.php

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/php/lang/ast/emit/NullsafeAsTernaries.class.php

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/php/lang/ast/emit/OmitArgumentNames.class.php

This file was deleted.

Loading
Loading