Skip to content

Instantly share code, notes, and snippets.

@alcaeus
Created May 12, 2016 05:30
Show Gist options
  • Save alcaeus/16d869adf686032b2b5f85719e6c50d4 to your computer and use it in GitHub Desktop.
Save alcaeus/16d869adf686032b2b5f85719e6c50d4 to your computer and use it in GitHub Desktop.
<?php
class Foo
{
/**
* @return self
*/
public function foo()
{
return $this;
}
/**
* @return $this
*/
public function fooThis()
{
return $this;
}
}
class Bar extends Foo
{
public function bar()
{
echo "Yes!";
}
}
// PhpStorm does not offer bar() as method here due to @return self
(new Bar())->foo()->bar();
// PhpStorm correctly handles code completion
(new Bar())->fooThis()->bar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment