msgraph-sdk-php icon indicating copy to clipboard operation
msgraph-sdk-php copied to clipboard

Wrong PHPDOC for Event `setAttendees()`

Open N-M opened this issue 2 years ago • 1 comments

If it is added like this image Following exception will appear

image

Code below works but IDE and code quality checks are failing

image

Doc param should be changed from

@param Attendee[] $val The attendees

to

@param Attendee $val The attendees

N-M avatar Dec 01 '21 22:12 N-M

Thanks for raising this @N-M

My apologies, we did not anticipate breaking code quality checks like PHPStan when we fixed the bug in the PHPDoc type, changing from Attendee to Attendee[].

Ideally, to create an event, we should be passing a Attendee[] from the docs but unfortunately we previously set the wrong PHPDoc type. Looks like you found a workaround by initialising an Attendee object with a list of Attendees which serializes to the expected collection of attendees hence $event->setAttendees($outlookAttendees) works.

The change to the PHPDoc types was made to cater for new developers starting on the SDK who would pass a single Attendee object to setAttendees() and end up getting a 400 since the API expects a collection.

The solution here seems to be to revert the PHPDoc change and mark this as a known issue on our v1 SDK with a workaround for developers new to this SDK. I shall discuss this with the rest of the team and share the final conclusion.

Ndiritu avatar Dec 02 '21 09:12 Ndiritu

PHPDoc issues are now accurate in v2.0 - https://devblogs.microsoft.com/microsoft365dev/write-high-quality-code-with-the-microsoft-graph-php-sdk-v2/

Ndiritu avatar Nov 20 '23 13:11 Ndiritu