xp-framework / compiler

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

Ensure filenames in errors reflect source files #54

Closed thekid closed 6 years ago

thekid commented 6 years ago

So e.g. "src/main/php/com/example/Service.php" instead of "CompilingClassLoader, eval()`ed code"

$ cat Test.php
<?php

use lang\Error;

class Test {

  public static function main() {
    trigger_error('Error');
    throw new Error('Test');
  }
}

# Current behavior
$ xp Test
Uncaught exception: Exception lang.Error (Test)
  at <main>::trigger_error() [line 8 of CompilingClassloader.class.php(162) : eval()`d code] Error
  at Test::main(array[0]) [line 374 of class-main.php]

# New behavior
$ xp Test
Uncaught exception: Exception lang.Error (Test)
  at <main>::trigger_error() [line 8 of Test.php] Error
  at Test::main(array[0]) [line 374 of class-main.php]
thekid commented 6 years ago

Fails with HHVM

F unittest.TestWarning(test= lang.ast.unittest.loader.CompilingClassLoaderTest::load_class, time= 0.152 seconds) {
  unittest.Warnings(1)@{
    "include(src://ns5b6eef267af9a/Tests.php): File not found" in lang\ast\CompilingClassLoader::loadClass0() (CompilingClassloader.class.php, line 167, occured once)
  }
}

See https://travis-ci.org/xp-framework/compiler/jobs/414875435


Reason is a different implementation of stream wrappers there - url_stat() needs to be implemented, too.

thekid commented 6 years ago

No measurable performance or memory usage impact, good to merge 👍