Skip to content

Instantly share code, notes, and snippets.

@shiwork
Last active September 10, 2015 18:09
Show Gist options
  • Save shiwork/38a8b4ddd92d4f1a80cc to your computer and use it in GitHub Desktop.
Save shiwork/38a8b4ddd92d4f1a80cc to your computer and use it in GitHub Desktop.
IntelliJのphp pluginの挙動
<?php
class A
{
/**
* @return $this
*/
public function foo()
{
return $this;
}
}
class B extends A
{
/**
* @return $this
*/
public static function bar()
{
return (new static())
->foo()
->foo() // 'Method '[name]' not found in class' when create instance by static().
->foo(); // this line is no suggest.
}
/**
* @return $this
*/
public static function foobar()
{
return (new self())
->foo()
->foo() // create instance by self()
->foo();
}
}
(new A)
->foo()
->foo()
->foo();
(new B)
->foo()
->foo()
->foo();
(new B)
->bar()
->foo() // no inspection when to write '@return $this' at phpdoc for B::bar() method.
->foo();
(new B)
->foobar()
->foo()
->foo();
@shiwork
Copy link
Author

shiwork commented Sep 10, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment