Skip to content

Commit 8bd53a9

Browse files
committed
Handle deprecation of dynamic properties in PHP8.2+
1 parent 1f424c0 commit 8bd53a9

File tree

4 files changed

+3642
-3618
lines changed

4 files changed

+3642
-3618
lines changed

library/Vmwarephp/ManagedObject.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
class ManagedObject {
55
private $reference;
66
protected $vmwareService;
7+
private array $aProperties = [];
78

89
function __construct(Service $vmwareService, \ManagedObjectReference $managedObjectReference) {
910
$this->vmwareService = $vmwareService;
@@ -14,17 +15,17 @@ function getParentHost() {
1415
return $this->vmwareService->getVhostHost();
1516
}
1617

17-
function __get($propertyName) {
18-
if (!isset($this->$propertyName)) {
19-
$queryForProperty = 'get' . ucfirst($propertyName);
20-
return $this->$queryForProperty();
21-
}
22-
return $this->$propertyName;
23-
}
18+
function __get($propertyName) {
19+
if (!array_key_exists($propertyName, $this->aProperties)) {
20+
$queryForProperty = 'get' . ucfirst($propertyName);
21+
return $this->$queryForProperty();
22+
}
23+
return $this->aProperties[$propertyName];
24+
}
2425

25-
function __set($propertyName, $propertyValue) {
26-
$this->$propertyName = $propertyValue;
27-
}
26+
function __set($propertyName, $propertyValue) {
27+
$this->aProperties[$propertyName] = $propertyValue;
28+
}
2829

2930
function getReferenceType() {
3031
return $this->reference->type;

library/Vmwarephp/SoapClient.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
namespace Vmwarephp;
33

44
class SoapClient extends \SoapClient {
5+
private array $aProperties = [];
6+
7+
public function __set(string $name, mixed $value): void {
8+
$this->aProperties[$name] = $value;
9+
}
10+
11+
public function __get(string $name): mixed {
12+
return (array_key_exists($name, $this->aProperties) ? $this->aProperties[$name]: null);
13+
}
514

615
function __doRequest($request, $location, $action, $version, $one_way = 0) {
716
$request = $this->appendXsiTypeForExtendedDatastructures($request);

0 commit comments

Comments
 (0)