在这个例子中:
/**
*
* @param <type> $foo
* @return <type>
*/
function do_something($foo) {
return $foo->really_do_something();
}
如何表明 $foo 必须属于 Foo 类?
/**
*
* @param Foo $foo
* @return <type>
*/
function do_something(Foo $foo) {
return $foo->really_do_something();
}
较新版本的 PHP(我认为是 PHP 5 以上)具有参数类型:
function do_something(Foo $foo) {
return $foo->really_do_something();
}
如果 $foo 不是 Foo 的类型,则会抛出异常。
我假设 phpDoc 选择了这个