Skip to content

Improve PHPDoc to (generated?) models to increase usability #172

Closed

Description

@holtkamp

As requested, this is a new issue for #28 (comment)

Is your feature request related to a problem? Please describe.
The generated PHPDoc can be improved, for example this line:

* @return Google_Service_Calendar_Event

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();
}

Describe the solution you'd like
Indicate cardinality in PHPDoc return types

Describe alternatives you've considered
Using typehints in userland code can used as workaround, but this is quite error-prone and not very "intelligent"...

Activity

  1. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Jun 30, 2019
  2. NicoHaase commented on Jul 2, 2019

    @NicoHaase

    Same here, PHPStan complains that \Google_Service_Calendar_Event::getAttendees returns an array of attendees instead of a single instance of Google_Service_Calendar_EventAttendee as given in the docblock

  3. holtkamp commented on Sep 9, 2019

    @holtkamp
    Author

    @dwsupplee and @jdpedrie is this somewhere on a roadmap / your radar? Seems "low hanging fruit" to me (of course, no idea whether that is the case, might be way more complex than I think...)

  4. dwsupplee commented on Sep 9, 2019

    @dwsupplee
    Contributor

    @holtkamp thanks for the ping. It is indeed! We've got a handful of changes we are working on batching up together in our code generator.

  5. dwsupplee commented on Jan 17, 2020

    @dwsupplee
    Contributor

    I just wanted to raise awareness this is still on our radar, and thank everyone for their patience.

  6. Kocal commented on Feb 21, 2020

    @Kocal

    Typings of \Google_Service_Analytics_Webproperties::getItems and \Google_Service_Analytics_Webproperties::setItems are incorrect too, they should use Google_Service_Analytics_Webproperty[], not Google_Service_Analytics_Webproperty.

  7. holtkamp commented on Mar 30, 2020

    @holtkamp
    Author

    @dwsupplee thanks for #172 (comment) and letting us know this is still on the radar

    Just wanted to point out that the original issue was submitted in August 2016...

    Maybe it might be a nice challenge to wrap up before / around August 2020? 😇

  8. holtkamp commented on Jun 20, 2021

    @holtkamp
    Author

    I suppose with https://github.com/googleapis/google-api-php-client-services/releases/tag/v0.200.0 this issue has been resolved => close issue 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions