xp-framework / compiler

Compiles future PHP to today's PHP.
19 stars 0 forks source link

Add support for compile-time checks #172

Closed thekid closed 1 year ago

thekid commented 1 year ago

This PR adds -c [check] to the command line to check for certain aspects at compile time.

Included checks

Example

Given the following code inside a file Overriding.php:

<?php

class Overriding {

  #[Override]
  public function fixture() { }
}

...the compilation yields:

$ xp compile -c method-overriding Overriding.php > /dev/null
! Overriding.php: Overriding::fixture() has #[\Override] attribute, but no matching parent method exists
[line 5 of Overriding.php]

× Compiled 1 file(s) to - using lang.ast.emit.PHP82, 1 error(s) occurred
Memory used: 2566.99 kB (2619.85 kB peak)
Time taken: 0.008 seconds
thekid commented 1 year ago

Closing in favor of #173