2023-06-28 15:50:38 +02:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace danog\MadelineProto\EventHandler;
|
|
|
|
|
2023-07-04 19:48:23 +02:00
|
|
|
use danog\MadelineProto\Ipc\IpcCapable;
|
2023-07-10 10:12:46 +02:00
|
|
|
use JsonSerializable;
|
2023-07-27 13:20:30 +02:00
|
|
|
use ReflectionClass;
|
|
|
|
use ReflectionProperty;
|
2023-06-28 15:50:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a generic update.
|
|
|
|
*/
|
2023-07-10 10:12:46 +02:00
|
|
|
abstract class Update extends IpcCapable implements JsonSerializable
|
2023-06-28 15:50:38 +02:00
|
|
|
{
|
2023-07-14 20:15:04 +02:00
|
|
|
/** @internal */
|
2023-08-05 19:13:26 +02:00
|
|
|
public function jsonSerialize(): mixed
|
2023-07-10 10:12:46 +02:00
|
|
|
{
|
2023-07-27 13:20:30 +02:00
|
|
|
$res = ['_' => static::class];
|
|
|
|
$refl = new ReflectionClass($this);
|
|
|
|
foreach ($refl->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) {
|
|
|
|
$res[$prop->getName()] = $prop->getValue($this);
|
|
|
|
}
|
|
|
|
return $res;
|
2023-07-10 10:12:46 +02:00
|
|
|
}
|
2023-06-28 15:50:38 +02:00
|
|
|
}
|