加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 自动完成foreach中的变量

发布时间:2020-12-13 13:48:34 所属栏目:PHP教程 来源:网络整理
导读:我有以下代码: class Orders{ /** * * @var Supplier */ private $suppliers; //Array of Supplier function loopAllSuppliers(){ foreach($this-suppliers as $supplier){ $supplier-/*no suggestion*/ //Can't get the method's to show here $this-suppl
我有以下代码:
class Orders{
    /**
     *
     * @var Supplier
     */
    private $suppliers; //Array of Supplier

    function loopAllSuppliers(){
        foreach($this->suppliers as $supplier){
            $supplier->/*no suggestion*/ //Can't get the method's to show here

            $this->suppliers->getSupplierName(); //methods in class Supplier show normally here
        }
    }
}

问题很简单.我只是想能够为我的变量$供应商声明一个类型,就像我用$供应商做的那样.

笔记:

> Supplier是一个具有公共方法getSupplierName()的类.
>我正在使用Netbeans IDE.

class Orders{
    /**
     *
     * @var Supplier
     */
    private $suppliers;

    function loopAllSuppliers(){
        foreach($this->suppliers as $supplier){ /* @var $supplier Supplier */
      //Must declare the type again inside the foreach as Netbeans doesn't support
      // defining variable as arrays in doc blocks,yet.
        }
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读