For example, consider the following code:
/** * @param array $array * @param string $key * @return mixed * @throws \InvalidArgumentException */ private function getArrayEntry(& $array, $key) { if (!array_key_exists($key, $array)) { throw new \InvalidArgumentException( 'Invalid array of values for location. Missing '.$key.'.' ); } return $array[$key]; } /** * @param array $data * @return Location */ public function createFromArray(array $data) { $this->getArrayEntry($data, 'name'); }
Should the second method have @throws in the doc block?
How is it used compared to Java, where there is the keyword 'throw'?
php phpdoc
Filip gรณrny
source share