rileydutton / Exchange-Web-Services-for-PHP

A basic library for interacting with Exchange Web Services using PHP 5.
MIT License
91 stars 42 forks source link

Warning: Creating default object from empty value in ExchangeClient.php on line 94 #18

Open IntellectProductions opened 9 years ago

IntellectProductions commented 9 years ago

This only makes sense.. here is the code in the object:

public function get_events($start, $end) {
    $this->setup();

    $FindItem->Traversal = "Shallow";
    $FindItem->ItemShape->BaseShape = "IdOnly";
    $FindItem->ParentFolderIds->DistinguishedFolderId->Id = "calendar";

    if($this->delegate != NULL) {
        $FindItem->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = $this->delegate;
    }

    $FindItem->CalendarView->StartDate = $start;
    $FindItem->CalendarView->EndDate = $end;

    $response = $this->client->FindItem($FindItem);
..................................

$FindItem isn't even defined or anything... so it's throwing the error about creating a default object from an empty value. Is there a better way to go about this? Instead of just doing:

$FindItem = new StdClass;

Because then it throws an error on line 95 ($FindItem->ItemShape->BaseShape) because then it becomes a multi-dimensional object... which would be tedious to make every single level an StdClass..

Thanks for any help.

seanBlommaert commented 8 years ago

This happens in /lib/ExchangeClient.php on line 195 as well. The fix for me was to instantiate the Mailbox property as stdClass: $FindItem->ParentFolderIds->DistinguishedFolderId->Mailbox = new stdClass();

igittigitt commented 5 years ago

This also happens on serveral other locations, like ExchangeClient.php in create_event() function. Everytime an object is referenced which is not instantiated before. I could fix it with the same as seanBlommaert said, create an object and assign it.