| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/projects/nextcloud/3rdparty/php-opencloud/openstack/src/Images/v2/ |
Upload File : |
<?php
declare(strict_types=1);
namespace OpenStack\Images\v2;
class JsonPatch extends \OpenStack\Common\JsonSchema\JsonPatch
{
public function disableRestrictedPropRemovals(array $diff, array $restrictedProps): array
{
foreach ($diff as $i => $changeSet) {
if ('remove' == $changeSet['op'] && in_array($changeSet['path'], $restrictedProps)) {
unset($diff[$i]);
}
}
return $diff;
}
/**
* {@inheritdoc}
*
* We need to override the proper way to handle objects because Glance v2 does not
* support whole document replacement with empty JSON pointers.
*/
protected function handleObject(\stdClass $srcStruct, \stdClass $desStruct, string $path): array
{
$changes = [];
foreach ($desStruct as $key => $val) {
if (!property_exists($srcStruct, $key)) {
$changes[] = $this->makePatch(self::OP_ADD, $this->path($path, $key), $val);
} elseif ($srcStruct->$key != $val) {
$changes = array_merge($changes, $this->makeDiff($srcStruct->$key, $val, $this->path($path, $key)));
}
}
if ($this->shouldPartiallyReplace($desStruct, $srcStruct)) {
foreach ($srcStruct as $key => $val) {
if (!property_exists($desStruct, $key)) {
$changes[] = $this->makePatch(self::OP_REMOVE, $this->path($path, $key));
}
}
}
return $changes;
}
protected function handleArray(array $srcStruct, array $desStruct, string $path): array
{
$changes = [];
if ($srcStruct != $desStruct) {
if ($diff = $this->arrayDiff($desStruct, $srcStruct)) {
$changes[] = $this->makePatch(self::OP_REPLACE, $path, $desStruct);
}
foreach ($srcStruct as $key => $val) {
if (!in_array($val, $desStruct, true)) {
$changes[] = $this->makePatch(self::OP_REMOVE, $this->path($path, $key));
}
}
}
return $changes;
}
}