Can you hint return types in PHP 5.2.5?

狂风中的少年 提交于 2019-12-10 13:15:13

问题


I think my eclipse's ctrl+clicking links might benefit greatly...

Edit: I'm using eclipse PDT.

Edit 2: I'm very happy with the solution of putting docblocks before functions (and variables) with an @return or @var statement, I've just updated the documentation of my app and now eclipse is showing me what functions are available to what objects!

Awesome.


回答1:


// [...]
/**
 * Return the Request object
 *
 * @return Zend_Controller_Request_Abstract
 */
public function getRequest()
{
    return $this->_request;
}
// [...]

works perfectly with Eclipse PDT. Which plugin do you use?




回答2:


Short answer: no.

Long answer: consider adding docblocks with @return declarations.




回答3:


The only way to hint return type in PHP is to use a good IDE like Eclispe PDT or Zend Studio with standard comment block. PHP simply can n not predict return type because it is dynamically typed language so type checking is done in the run time unlike for the statically typed languages like C#, JAVA and C++.



来源:https://stackoverflow.com/questions/308027/can-you-hint-return-types-in-php-5-2-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!