Add PHPDoc to (generated?) models to increase usability
Currently the PHP Documentation of the model classes is lacking, which makes it harder to use them / understand them. Since the model classes are probably generated, a change to the generator should be able to facilitate this. Not sure where to post this issue though, is the generator also on GitHub?
For example Google_Service_Calendar_Event::setStart() has a type-hint that a Google_Service_Calendar_EventDateTime object should be used, but getStart() does not have a PHPDoc @return hint:
class Google_Service_Calendar_Event
{
public function setStart(Google_Service_Calendar_EventDateTime $start)
{
$this->start = $start;
}
//Current approach, no PHPDoc
public function getStart()
{
return $this->start;
}
/**
* Preferred approach
* @return Google_Service_Calendar_EventDateTime
*/
public function getStart()
{
return $this->start;
}
/**
* as of PHP7
* @return Google_Service_Calendar_EventDateTime
*/
public function getStart() : Google_Service_Calendar_EventDateTime
{
return $this->start;
}
}
Currently using the API Client and specific services is quite an 'adventure' / puzzle of finding out how everything works and by trial and error find out the proper way. Does Google use the PHP API Services themselves as well? I would say out of frustration one would add such type hints quite quickly ;)
+1 to this, without the phpdoc is really hard to know what are the classes of the objects of all the classes.
+1 IDEs can't auto complete without docblocks! What is the status of this?
@asimlqt thanks for the +1, not sure somebody is monitoring this repository though. It seems @bshaffer is the lead developer. @bshaffer, should we report such requests elsewhere?
@holtkamp believe it or not, we'll actually be adding this soon :)
Unfortunately we need to preserve BC for now, so the second option is what we are implementing.
Unfortunately we need to preserve BC for now, so the second option is what we are implementing.
Aah, that is already great! Thanks for the heads-up!
This has been added! Check out v0.13!
Nice! @bshaffer
Some feedback, look at this line: https://github.com/google/google-api-php-client-services/blob/b8c3ee8adab9eaffc3825cabc12740ad6e2ed76f/src/Google/Service/Calendar/Events.php#L80-L86
The proper return type would probably suggest an array / collection, so @return Google_Service_Calendar_Event[] would be better: suggest it is iterable.
Currently my IDE (PHPStorm) still needs an explicit typehint:
/* @var GoogleCalendarEvent $calendarEvent */
foreach ($calendarEvents->getItems() as $calendarEvent) {
echo $calendarEvent->getStart()->getDateTime();
}
@bshaffer minor bump on this?
@bshaffer can this issue be re-opened?
@bshaffer tiresless bump on this? Minimal effort, maximum awesome this seems to me! 🚀
@mattwhisenhunt @bshaffer can this issue be re-opened? See my comment https://github.com/google/google-api-php-client-services/issues/28#issuecomment-314583187
@mattwhisenhunt @bshaffer happy birthday to this issue
https://github.com/googleapis/google-api-php-client-services/blob/d41fea99f90d7935bd57cf654bf271072fe584f1/src/Google/Service/Calendar/Events.php#L81
Anyone monitoring this issue?
@holtkamp that's definitely something we need to address. Would you mind opening a fresh issue for us?
@dwsupplee sure! See https://github.com/googleapis/google-api-php-client-services/issues/172