PHP Function Arguments: Array of Objects of a Specific Class

后端 未结 4 1764
走了就别回头了
走了就别回头了 2020-12-17 14:49

I have a function that takes a member of a particular class:

public function addPage(My_Page $page)
{
  // ...
}

I\'d like to make another

4条回答
  •  半阙折子戏
    2020-12-17 15:20

    You can also add PhpDoc comment to get autocomplete in IDE

        /**
         * @param My_Page[] $pages
         */
        public function addPages(array $pages)
        {
          // ...
        }
    

提交回复
热议问题