I am currently using something like
class User{
/* @var Contacts*/
public $contacts = array();
}
$userObj = new User();
$userObj->contacts[] = new Contact(...);
$userObj->contacts[] = new Contact(...);
Tough we can document the type of variable using phpDocumentor, is it also possible to restrict other types of objects to be assigned to the contacts array
$userObj->contacts[] = 2.3 //should be considered as invalid
Not how it works in php
Here is what you can do instead
No you can use it like so
And the following will cause an error