2

Suppose I have a file called routes.php containing routes for my webapp:

use Symfony\Component\Routing;

$routes = new Routing\RouteCollection();
// Add routes here

return $routes;


This file is then included in my front controller as follows:

$routes = include 'routes.php';


Clearly this $routes object is of type RouteCollection. However, Eclipse doesn't seem to be aware of this, and as such I can't view the the object's methods when I start typing $routes-> which makes it difficult to know what methods and parameters are available to me.

Is there any way for me to hint at the return type of my routes.php file? I've tried adding an annotation @return \Symfony\Component\Routing\RouteCollection at the top of the routes file, but this doesn't seem to make any difference.

I'm using Eclipse 4.2 with the Aptana Studio 3 plugin. If this is a limitation specific to Aptana, would PDT handle this differently?

4

1 回答 1

2

PHPDoc 中没有指定文件的返回类型,因此您必须定义包含它的类型:

/* @var $routes \Symfony\Component\Routing\RouteCollection */
$routes = include 'routes.php';

取决于 IDE /** @var(即 Zend Studio、Eclipse PDT)或/* @var(即 Aptana、NetBeans)

于 2013-02-01T10:20:20.880 回答