msgraph-sdk-php
msgraph-sdk-php copied to clipboard
Wrong PHPDOC for Event `setAttendees()`
If it is added like this
Following exception will appear
Code below works but IDE and code quality checks are failing
Doc param should be changed from
@param Attendee[] $val The attendees
to
@param Attendee $val The attendees
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.
PHPDoc issues are now accurate in v2.0 - https://devblogs.microsoft.com/microsoft365dev/write-high-quality-code-with-the-microsoft-graph-php-sdk-v2/