I\'m writing a little homebrew ORM (academic interest). I\'m trying to adhere to the TDD concept as a training exercise, and as part of that exercise I\'m writing documentat
You could achieve something like method overloading by checking the type of the passed parameter at runtime (PHP does not support this concept known from other languages like ADA, Java, C# or C++ e.g.):
[...]
/**
* @param User|array|integer $user
* @return array
*/
public function getCollection($user) {
// perhaps a switch-case would be better here
if ($user instanceof User) {
// do what has to be done if you passed in a User object
} else if (is_int($user) {
// do what has to be done if you passed in a user id
} else if (is_array($user)) {
// do what has to be done if you passed in an array of user ids
}
}
[...]