kphp icon indicating copy to clipboard operation
kphp copied to clipboard

KPHP allows calling methods on null instances

Open quasilyte opened this issue 5 years ago • 0 comments

<?php

class Foo {
  public function f() {
    var_dump("OK");
  }
}

function test() {
  /** @var Foo */
  $foo = null;
  $foo->f();
}

test();

PHP:

Stack trace:
#0 example.php(15): test()
#1 {main}
  ...

KPHP:

string(2) "OK"

KPHP will produce a warning if we access an object via $this, but otherwise there will be no warnings or errors.

quasilyte avatar May 31 '21 16:05 quasilyte