HaxeFoundation / HaxeFoundation/haxe
[PHP] Possible runtime metadata field name bug
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Hej,
I don't know if it's a documentation problem https://haxe.org/manual/lf-metadata.html#since-haxe-4.0.0 and it only applies to compile-time meta or if it's a bug, but you can't use a runtime metadata name (using field access like @foo.bar) on PHP target while it works fine on JS for example : https://try.haxe.org/#31AD2A9F
I have a minimal example :
```haxe
@:rtti
class A {
@foo.bar
public var foo : Bool;
public function new(){}
}
```
Generates something like that on PHP :
```php
\x0A\x09\x0A\x09\x09\x0A\x09\x09\x0A\x09\x0A\x09\x0A\x09\x0A\x09\x09\x0A\x09\x09\x0A\x09\x09\x0A\x09\x0A";
/**
* @var bool
*/
public $foo;
/**
* @return void
*/
public function __construct () {
}
/**
* @internal
* @access private
*/
static public function __hx__init ()
{
static $called = false;
if ($called) return;
$called = true;
}
}
class _HxAnon_A2 extends HxAnon {
function __construct($foo.bar) {
$this->foo.bar = $foo.bar; // "Parse error: syntax error, unexpected '.', expecting ')'"
}
}
class _HxAnon_A1 extends HxAnon {
function __construct($foo) {
$this->foo = $foo;
}
}
class _HxAnon_A0 extends HxAnon {
function __construct($fields) {
$this->fields = $fields;
}
}
Boot::registerClass(A::class, 'A');
Boot::registerMeta(A::class, new _HxAnon_A0(new _HxAnon_A1(new _HxAnon_A2(null))));
A::__hx__init();
```
Contributor guide
Assessment
This issue has not been assessed yet.