php – 自动完成foreach中的变量

前端之家收集整理的这篇文章主要介绍了php – 自动完成foreach中的变量前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下代码
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.

@H_403_11@
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.
        }
    }
}
原文链接:https://www.f2er.com/php/138774.html

猜你在找的PHP相关文章