VKCOM/kphp

You can access properties via `$` and its name

Danil42Russia opened this issue · 1 comments

<?php

main();

function main() {
  $cls = new TestClass();
  $cls->getName("test");

  var_dump(instance_to_array($cls));
}

class TestClass {
  private string $name;

  function getName(string $name): void {
    $this->$name = $name;
//         ^ <- error is here
  }
}

Output to KPHP:

array(1) {
  ["name"]=>
  string(4) "test"
}

Output to PHP:

array(1) {
  'test' =>
  string(4) "test"
}