Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle null values #904

Merged
merged 16 commits into from
Dec 19, 2023
6 changes: 4 additions & 2 deletions src/XeroPHP/Remote/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __construct(Application $application = null)
$this->_data = [];
$this->_associated_objects = [];
}

public static function make(Application $application = null)
{
return new static($application);
Expand Down Expand Up @@ -520,7 +520,9 @@ public function __set($property, $value)

protected function propertyUpdated($property, $value)
{
if (! isset($this->_data[$property]) || $this->_data[$property] !== $value) {
$currentValue = isset($this->_data[$property]) ? $this->_data[$property] : null;

if ($currentValue !== $value) {
//If this object can update itself, set its own dirty flag, otherwise, set its parent's.
if (count(array_intersect($this::getSupportedMethods(), [Request::METHOD_PUT, Request::METHOD_POST])) > 0) {
//Object can update itself
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests\Application;
namespace XeroPHP\Tests\Application;

use XeroPHP\Application;

Expand Down
2 changes: 1 addition & 1 deletion tests/HelpersTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests;
namespace XeroPHP\Tests;

use XeroPHP\Helpers;

Expand Down
6 changes: 6 additions & 0 deletions tests/Remote/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public function testPracticeManagerClientListIsReturned()
<Position />
</Contact>
</Contacts>
<Groups>
<Group>
<ID>783949</ID>
<Name>1 Geotechnical Limited</Name>
</Group>
</Groups>
</Client>
<Client>
<ID>697</ID>
Expand Down
2 changes: 1 addition & 1 deletion tests/Webhook/EventTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests;
namespace XeroPHP\Tests\Webhook;

use XeroPHP\Webhook;
use XeroPHP\Application;
Expand Down
2 changes: 1 addition & 1 deletion tests/WebhookTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace XeroPHP\tests;
namespace XeroPHP\Tests;

use XeroPHP\Application;
use XeroPHP\Application\PrivateApplication;
Expand Down