Back to development after spending some years in a management position, I am dealing with a PHP code, which has some definitions that I cannot understand (looks like I am far beyond of PHP progress on these years). Can someone let me know what campaignDTO and ParamDTO do in this definition?
What will be returned from this method?
/**
* Creates a campaign
* @param campaignDTO $campaign
* @param ParamDTO $param
* @throws \Exception
* @return campaignDTO
*/
public function createCampaign(campaignDTO $campaign, ParamDTO $param)
{
}
Type declarations as per docs:
Type declarations allow functions to require that parameters are of a certain type at call time. If the given value is of the incorrect type, then an error is generated: in PHP 5, this will be a recoverable fatal error, while PHP 7 will throw a TypeError exception.
These are type-hints
for run-time validation. It tells the code to expect objects of class type campaignDTO
and ParamDTO
, or a class that extends from these.
If you pass in an array, or a string, or something that is not a class that is or extends capaignDTO
then the code will throw an error.
The function, as it is, returns nothing.
According to the code-comment, it will return an object of type campaignDTO
, which looks like the first parameter.