Community
Participate
Working Groups
With PHP 7, return types can be defined in the code itself to enforce it. However the PHPDoc return type should still supersede the return type enforced by the function or method itself, and that's not the behavior Eclipse is displaying at the moment. For example, let the classes, Foo and Bar, be defined as the following: <?php class Foo { /** * @return static */ public static function getNew() : Foo { $class = static::class; return new $class; } } class Bar extends Foo { /** * @return void */ public function doStuff() : void { ... } } ?> When using: <?php $bar = Bar::getNew(); $bar->| The expected code completion suggestions here should be every public constant, property and method available on class Bar, thus in this case it should display both the getNew and doStuff methods to auto-complete. However it only shows up the Foo ones, in other words, just the getNew method. By dropping the ": Foo" return type from the method itself, as so: /** * @return static */ public static function getNew() { ... } Then it starts showing the correct code suggestions from class Bar. This was reproduced in: Version: Neon.2 Release (4.6.2) Build id: 20161208-0600