PHP Casting Variable as Object type in foreach Loop

前端 未结 5 560

Within the following code, $quiz_object->personalities contains an array of Personality objects.

// Loop through each personality th         


        
5条回答
  •  再見小時候
    2021-02-01 15:54

    I know this post is old but I think this may help someone:

    In PhpStorm works this way, maybe in others too.

    /**
     * @param ClassName[] $variables
     */
    public function loopFunction($variables){
        foreach ($variables as $variable) {
            echo $variable->functionName();
        }
    }
    

提交回复
热议问题