From 41de551a96304fb63d78190a02a548b721639bea Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 6 Sep 2023 19:33:52 +0200 Subject: [PATCH] Rename some classes before release --- docs | 2 +- psalm-baseline.xml | 17 ++++++++----- src/API.php | 2 +- src/AnnotationsBuilder.php | 2 +- src/EventHandler/AbstractMessage.php | 2 +- .../{AbstractAction.php => Action.php} | 8 +++--- src/EventHandler/Action/Cancel.php | 4 +-- src/EventHandler/Action/ChooseContact.php | 4 +-- src/EventHandler/Action/ChooseSticker.php | 4 +-- src/EventHandler/Action/EmojiSeen.php | 4 +-- src/EventHandler/Action/EmojiTap.php | 4 +-- src/EventHandler/Action/GamePlay.php | 4 +-- src/EventHandler/Action/GeoLocation.php | 4 +-- src/EventHandler/Action/GroupCallSpeaking.php | 4 +-- src/EventHandler/Action/HistoryImport.php | 4 +-- src/EventHandler/Action/RecordAudio.php | 4 +-- src/EventHandler/Action/RecordRound.php | 4 +-- src/EventHandler/Action/RecordVideo.php | 4 +-- src/EventHandler/Action/Typing.php | 4 +-- src/EventHandler/Action/UploadAudio.php | 4 +-- src/EventHandler/Action/UploadDocument.php | 4 +-- src/EventHandler/Action/UploadPhoto.php | 4 +-- src/EventHandler/Action/UploadRound.php | 4 +-- src/EventHandler/Action/UploadVideo.php | 4 +-- ...ialogGroupCall.php => DialogGroupCall.php} | 2 +- .../Service/DialogGroupCall/GroupCall.php | 4 +-- .../DialogGroupCall/GroupCallInvited.php | 4 +-- .../DialogGroupCall/GroupCallScheduled.php | 4 +-- src/EventHandler/Privacy.php | 14 +++++------ .../Privacy/{Key.php => Rule.php} | 11 ++++---- .../{AbstractRule.php => RuleDestination.php} | 25 +++++++++++-------- .../{Rule => RuleDestination}/AllowAll.php | 6 ++--- .../AllowChatParticipants.php | 6 ++--- .../AllowCloseFriends.php | 6 ++--- .../AllowContacts.php | 6 ++--- .../{Rule => RuleDestination}/AllowUsers.php | 6 ++--- .../{Rule => RuleDestination}/DisallowAll.php | 6 ++--- .../DisallowChatParticipants.php | 6 ++--- .../DisallowContacts.php | 6 ++--- .../DisallowUsers.php | 6 ++--- src/EventHandler/Story/Story.php | 6 ++--- .../{AbstractTyping.php => Typing.php} | 8 +++--- .../Typing/SupergroupUserTyping.php | 4 +-- src/EventHandler/Typing/UserTyping.php | 4 +-- src/EventHandler/User/Status/Emoji.php | 2 +- src/InternalDoc.php | 1 - 46 files changed, 129 insertions(+), 119 deletions(-) rename src/EventHandler/{AbstractAction.php => Action.php} (96%) rename src/EventHandler/Message/Service/{AbstractDialogGroupCall.php => DialogGroupCall.php} (96%) rename src/EventHandler/Privacy/{Key.php => Rule.php} (91%) rename src/EventHandler/Privacy/{AbstractRule.php => RuleDestination.php} (71%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/AllowAll.php (85%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/AllowChatParticipants.php (86%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/AllowCloseFriends.php (84%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/AllowContacts.php (85%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/AllowUsers.php (87%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/DisallowAll.php (85%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/DisallowChatParticipants.php (86%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/DisallowContacts.php (85%) rename src/EventHandler/Privacy/{Rule => RuleDestination}/DisallowUsers.php (87%) rename src/EventHandler/{AbstractTyping.php => Typing.php} (84%) diff --git a/docs b/docs index 1af009547..355943bfe 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 1af0095472c40f98ae4bdd4af7d741ce36839eaf +Subproject commit 355943bfe72fac6b1e42301a5c1db6f5a1029841 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 82307cadc..fdd9746c0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -407,11 +407,6 @@ new $class - - - $type - - replyCache]]> @@ -438,6 +433,11 @@ wrapMessage($client->extractMessage($result))]]> + + + $type + + $peerResolved @@ -663,6 +663,11 @@ getIdInternal($rawParticipant['peer'])]]> + + + + + Message @@ -698,7 +703,7 @@ wrapMedia($rawStory['media'], $this->protected)]]> - + diff --git a/src/API.php b/src/API.php index b557641df..aa5890116 100644 --- a/src/API.php +++ b/src/API.php @@ -51,7 +51,7 @@ final class API extends AbstractAPI * * @var string */ - public const RELEASE = '8.0.0-beta144'; + public const RELEASE = '8.0.0-beta145'; /** * Secret chat was not found. * diff --git a/src/AnnotationsBuilder.php b/src/AnnotationsBuilder.php index 3196920b7..7b0e935c3 100644 --- a/src/AnnotationsBuilder.php +++ b/src/AnnotationsBuilder.php @@ -550,7 +550,7 @@ final class Blacklist { $had = []; foreach (ClassFinder::getClassesInNamespace(\danog\MadelineProto\EventHandler::class, ClassFinder::RECURSIVE_MODE) as $class) { $name = \basename(\str_replace('\\', '//', $class)); - if (isset($had[$name]) || $name === 'Status') { + if (isset($had[$name]) || $name === 'Status' || $name === 'Action') { continue; } $had[$name] = true; diff --git a/src/EventHandler/AbstractMessage.php b/src/EventHandler/AbstractMessage.php index 9160e3c5b..2c6c045f7 100644 --- a/src/EventHandler/AbstractMessage.php +++ b/src/EventHandler/AbstractMessage.php @@ -305,7 +305,7 @@ abstract class AbstractMessage extends Update implements SimpleFilters * * @return boolean */ - public function setAction(AbstractAction $action = new Typing): bool + public function setAction(Action $action = new Typing): bool { $action = $action->toRawAction() + [ 'msg_id' => $this->id ]; return $this->getClient()->methodCallAsyncRead( diff --git a/src/EventHandler/AbstractAction.php b/src/EventHandler/Action.php similarity index 96% rename from src/EventHandler/AbstractAction.php rename to src/EventHandler/Action.php index 43c1cf8bd..003d38a1f 100644 --- a/src/EventHandler/AbstractAction.php +++ b/src/EventHandler/Action.php @@ -38,11 +38,12 @@ use ReflectionClass; use ReflectionProperty; /** - * Typing events. + * In-progress actions. */ -abstract class AbstractAction implements JsonSerializable +abstract class Action implements JsonSerializable { - public static function fromRawAction(array $rawAction): AbstractAction + /** @internal */ + public static function fromRawAction(array $rawAction): Action { $type = $rawAction['_']; if ($type === 'sendMessageEmojiInteraction') { @@ -73,6 +74,7 @@ abstract class AbstractAction implements JsonSerializable }; } + /** @internal */ public function toRawAction(): array { return match (true) { diff --git a/src/EventHandler/Action/Cancel.php b/src/EventHandler/Action/Cancel.php index b8bd909fa..324a96655 100644 --- a/src/EventHandler/Action/Cancel.php +++ b/src/EventHandler/Action/Cancel.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * Invalidate all previous action updates. E.g. when user deletes entered text or aborts a video upload. */ -final class Cancel extends AbstractAction +final class Cancel extends Action { } diff --git a/src/EventHandler/Action/ChooseContact.php b/src/EventHandler/Action/ChooseContact.php index b8034a6d0..8fddc9ea5 100644 --- a/src/EventHandler/Action/ChooseContact.php +++ b/src/EventHandler/Action/ChooseContact.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is selecting a contact to share. */ -final class ChooseContact extends AbstractAction +final class ChooseContact extends Action { } diff --git a/src/EventHandler/Action/ChooseSticker.php b/src/EventHandler/Action/ChooseSticker.php index becc149a5..e7df01816 100644 --- a/src/EventHandler/Action/ChooseSticker.php +++ b/src/EventHandler/Action/ChooseSticker.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is choosing a sticker. */ -final class ChooseSticker extends AbstractAction +final class ChooseSticker extends Action { } diff --git a/src/EventHandler/Action/EmojiSeen.php b/src/EventHandler/Action/EmojiSeen.php index c620f875c..7ab36d994 100644 --- a/src/EventHandler/Action/EmojiSeen.php +++ b/src/EventHandler/Action/EmojiSeen.php @@ -16,12 +16,12 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is watching an animated emoji reaction triggered by another user, [click here for more info »](https://core.telegram.org/api/animated-emojis#emoji-reactions). */ -final class EmojiSeen extends AbstractAction +final class EmojiSeen extends Action { public function __construct( /** @var string Emoji */ diff --git a/src/EventHandler/Action/EmojiTap.php b/src/EventHandler/Action/EmojiTap.php index a86d0c929..c6165b1d2 100644 --- a/src/EventHandler/Action/EmojiTap.php +++ b/src/EventHandler/Action/EmojiTap.php @@ -16,12 +16,12 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User has clicked on an animated emoji triggering a [reaction, click here for more info »](https://core.telegram.org/api/animated-emojis#emoji-reactions). */ -final class EmojiTap extends AbstractAction +final class EmojiTap extends Action { public function __construct( /** @var string Emoji */ diff --git a/src/EventHandler/Action/GamePlay.php b/src/EventHandler/Action/GamePlay.php index 7da241504..a6cce73f7 100644 --- a/src/EventHandler/Action/GamePlay.php +++ b/src/EventHandler/Action/GamePlay.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is playing a game. */ -final class GamePlay extends AbstractAction +final class GamePlay extends Action { } diff --git a/src/EventHandler/Action/GeoLocation.php b/src/EventHandler/Action/GeoLocation.php index c3964a17f..371728f1b 100644 --- a/src/EventHandler/Action/GeoLocation.php +++ b/src/EventHandler/Action/GeoLocation.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is selecting a location to share. */ -final class GeoLocation extends AbstractAction +final class GeoLocation extends Action { } diff --git a/src/EventHandler/Action/GroupCallSpeaking.php b/src/EventHandler/Action/GroupCallSpeaking.php index e83a94a79..b28a2c708 100644 --- a/src/EventHandler/Action/GroupCallSpeaking.php +++ b/src/EventHandler/Action/GroupCallSpeaking.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is currently speaking in the group call. */ -final class GroupCallSpeaking extends AbstractAction +final class GroupCallSpeaking extends Action { } diff --git a/src/EventHandler/Action/HistoryImport.php b/src/EventHandler/Action/HistoryImport.php index 71338ee11..8fef80a67 100644 --- a/src/EventHandler/Action/HistoryImport.php +++ b/src/EventHandler/Action/HistoryImport.php @@ -16,12 +16,12 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * Chat history is being imported. */ -final class HistoryImport extends AbstractAction +final class HistoryImport extends Action { public function __construct( /** @var ?int Progress percentage */ diff --git a/src/EventHandler/Action/RecordAudio.php b/src/EventHandler/Action/RecordAudio.php index c1cdeb646..fc8d431c3 100644 --- a/src/EventHandler/Action/RecordAudio.php +++ b/src/EventHandler/Action/RecordAudio.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is recording a voice message. */ -final class RecordAudio extends AbstractAction +final class RecordAudio extends Action { } diff --git a/src/EventHandler/Action/RecordRound.php b/src/EventHandler/Action/RecordRound.php index 451e074f4..1fa9d2823 100644 --- a/src/EventHandler/Action/RecordRound.php +++ b/src/EventHandler/Action/RecordRound.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is recording a round video to share. */ -final class RecordRound extends AbstractAction +final class RecordRound extends Action { } diff --git a/src/EventHandler/Action/RecordVideo.php b/src/EventHandler/Action/RecordVideo.php index 2068f575d..0c5284b8a 100644 --- a/src/EventHandler/Action/RecordVideo.php +++ b/src/EventHandler/Action/RecordVideo.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is recording a video. */ -final class RecordVideo extends AbstractAction +final class RecordVideo extends Action { } diff --git a/src/EventHandler/Action/Typing.php b/src/EventHandler/Action/Typing.php index df7108d6b..f1a364e42 100644 --- a/src/EventHandler/Action/Typing.php +++ b/src/EventHandler/Action/Typing.php @@ -16,11 +16,11 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is typing. */ -final class Typing extends AbstractAction +final class Typing extends Action { } diff --git a/src/EventHandler/Action/UploadAudio.php b/src/EventHandler/Action/UploadAudio.php index 525a18553..0c9e970a7 100644 --- a/src/EventHandler/Action/UploadAudio.php +++ b/src/EventHandler/Action/UploadAudio.php @@ -16,12 +16,12 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is uploading a voice message. */ -final class UploadAudio extends AbstractAction +final class UploadAudio extends Action { public function __construct( /** @var ?int Progress percentage */ diff --git a/src/EventHandler/Action/UploadDocument.php b/src/EventHandler/Action/UploadDocument.php index 76f06cd6c..5c011fbb8 100644 --- a/src/EventHandler/Action/UploadDocument.php +++ b/src/EventHandler/Action/UploadDocument.php @@ -16,12 +16,12 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is uploading a file. */ -final class UploadDocument extends AbstractAction +final class UploadDocument extends Action { public function __construct( /** @var ?int Progress percentage */ diff --git a/src/EventHandler/Action/UploadPhoto.php b/src/EventHandler/Action/UploadPhoto.php index f13b9b752..c4f1399f1 100644 --- a/src/EventHandler/Action/UploadPhoto.php +++ b/src/EventHandler/Action/UploadPhoto.php @@ -16,12 +16,12 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is uploading a photo. */ -final class UploadPhoto extends AbstractAction +final class UploadPhoto extends Action { public function __construct( /** @var ?int Progress percentage */ diff --git a/src/EventHandler/Action/UploadRound.php b/src/EventHandler/Action/UploadRound.php index 277c0941c..60e5d652d 100644 --- a/src/EventHandler/Action/UploadRound.php +++ b/src/EventHandler/Action/UploadRound.php @@ -16,12 +16,12 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is uploading a round video. */ -final class UploadRound extends AbstractAction +final class UploadRound extends Action { public function __construct( /** @var ?int Progress percentage */ diff --git a/src/EventHandler/Action/UploadVideo.php b/src/EventHandler/Action/UploadVideo.php index 85d6c832e..d2fbbc2bb 100644 --- a/src/EventHandler/Action/UploadVideo.php +++ b/src/EventHandler/Action/UploadVideo.php @@ -16,12 +16,12 @@ namespace danog\MadelineProto\EventHandler\Action; -use danog\MadelineProto\EventHandler\AbstractAction; +use danog\MadelineProto\EventHandler\Action; /** * User is uploading a video. */ -final class UploadVideo extends AbstractAction +final class UploadVideo extends Action { public function __construct( /** @var ?int Progress percentage */ diff --git a/src/EventHandler/Message/Service/AbstractDialogGroupCall.php b/src/EventHandler/Message/Service/DialogGroupCall.php similarity index 96% rename from src/EventHandler/Message/Service/AbstractDialogGroupCall.php rename to src/EventHandler/Message/Service/DialogGroupCall.php index 413b07762..bd5a36a86 100644 --- a/src/EventHandler/Message/Service/AbstractDialogGroupCall.php +++ b/src/EventHandler/Message/Service/DialogGroupCall.php @@ -22,7 +22,7 @@ use danog\MadelineProto\MTProto; /** * Represents a service message about a group call. */ -abstract class AbstractDialogGroupCall extends ServiceMessage +abstract class DialogGroupCall extends ServiceMessage { /** Group call ID */ public readonly int $callId; diff --git a/src/EventHandler/Message/Service/DialogGroupCall/GroupCall.php b/src/EventHandler/Message/Service/DialogGroupCall/GroupCall.php index 25001f302..3dd52575f 100644 --- a/src/EventHandler/Message/Service/DialogGroupCall/GroupCall.php +++ b/src/EventHandler/Message/Service/DialogGroupCall/GroupCall.php @@ -16,13 +16,13 @@ namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; -use danog\MadelineProto\EventHandler\Message\Service\AbstractDialogGroupCall; +use danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; use danog\MadelineProto\MTProto; /** * The group call has started or ended. */ -final class GroupCall extends AbstractDialogGroupCall +final class GroupCall extends DialogGroupCall { /** @var bool Whether that group call ended or not. */ public readonly bool $ended; diff --git a/src/EventHandler/Message/Service/DialogGroupCall/GroupCallInvited.php b/src/EventHandler/Message/Service/DialogGroupCall/GroupCallInvited.php index 379526456..76f852cd2 100644 --- a/src/EventHandler/Message/Service/DialogGroupCall/GroupCallInvited.php +++ b/src/EventHandler/Message/Service/DialogGroupCall/GroupCallInvited.php @@ -16,13 +16,13 @@ namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; -use danog\MadelineProto\EventHandler\Message\Service\AbstractDialogGroupCall; +use danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; use danog\MadelineProto\MTProto; /** * A set of users was invited to the group call. */ -final class GroupCallInvited extends AbstractDialogGroupCall +final class GroupCallInvited extends DialogGroupCall { public function __construct( MTProto $API, diff --git a/src/EventHandler/Message/Service/DialogGroupCall/GroupCallScheduled.php b/src/EventHandler/Message/Service/DialogGroupCall/GroupCallScheduled.php index ad7042ed3..6b7ca804b 100644 --- a/src/EventHandler/Message/Service/DialogGroupCall/GroupCallScheduled.php +++ b/src/EventHandler/Message/Service/DialogGroupCall/GroupCallScheduled.php @@ -16,13 +16,13 @@ namespace danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; -use danog\MadelineProto\EventHandler\Message\Service\AbstractDialogGroupCall; +use danog\MadelineProto\EventHandler\Message\Service\DialogGroupCall; use danog\MadelineProto\MTProto; /** * A group call was scheduled. */ -final class GroupCallScheduled extends AbstractDialogGroupCall +final class GroupCallScheduled extends DialogGroupCall { public function __construct( MTProto $API, diff --git a/src/EventHandler/Privacy.php b/src/EventHandler/Privacy.php index 429920311..efe96e844 100644 --- a/src/EventHandler/Privacy.php +++ b/src/EventHandler/Privacy.php @@ -16,8 +16,8 @@ namespace danog\MadelineProto\EventHandler; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; -use danog\MadelineProto\EventHandler\Privacy\Key; +use danog\MadelineProto\EventHandler\Privacy\Rule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; use danog\MadelineProto\MTProto; /** @@ -26,16 +26,16 @@ use danog\MadelineProto\MTProto; final class Privacy extends Update { /** New privacy rule. */ - public readonly Key $key; + public readonly Rule $rule; - /** Peers to which the privacy rules apply */ - public readonly array $rules; + /** @var list Peers to which the privacy rules apply */ + public readonly array $appliesTo; /** @internal */ public function __construct(MTProto $API, array $rawPrivacy) { parent::__construct($API); - $this->key = Key::fromRawKey($rawPrivacy['key']['_']); - $this->rules = \array_map(AbstractRule::fromRawRule(...), $rawPrivacy['rules']); + $this->rule = Rule::fromRawKey($rawPrivacy['key']['_']); + $this->appliesTo = \array_map(RuleDestination::fromRawRule(...), $rawPrivacy['rules']); } } diff --git a/src/EventHandler/Privacy/Key.php b/src/EventHandler/Privacy/Rule.php similarity index 91% rename from src/EventHandler/Privacy/Key.php rename to src/EventHandler/Privacy/Rule.php index 87e4576e8..95609ef59 100644 --- a/src/EventHandler/Privacy/Key.php +++ b/src/EventHandler/Privacy/Rule.php @@ -19,7 +19,8 @@ namespace danog\MadelineProto\EventHandler\Privacy; use AssertionError; use JsonSerializable; -enum Key: string implements JsonSerializable +/** Represents a privacy rule. */ +enum Rule: string implements JsonSerializable { /** Whether we can see the last online timestamp of this user */ case STATUS_TIMESTAMP = 'privacyKeyStatusTimestamp'; @@ -39,17 +40,17 @@ enum Key: string implements JsonSerializable case ADDED_BY_PHONE = 'privacyKeyAddedByPhone'; /** Whether the user accepts voice messages */ case VOICE_MESSAGES = 'privacyKeyVoiceMessages'; - + /** Whether the user can see our bio. */ case ABOUT = 'privacyKeyAbout'; /** - * + * @internal * * @throws AssertionError */ - public static function fromRawKey(string $key): Key + public static function fromRawKey(string $key): Rule { - foreach (Key::cases() as $case) { + foreach (Rule::cases() as $case) { if ($case->value === $key) { return $case; } diff --git a/src/EventHandler/Privacy/AbstractRule.php b/src/EventHandler/Privacy/RuleDestination.php similarity index 71% rename from src/EventHandler/Privacy/AbstractRule.php rename to src/EventHandler/Privacy/RuleDestination.php index 68a542b3b..ad6f9649c 100644 --- a/src/EventHandler/Privacy/AbstractRule.php +++ b/src/EventHandler/Privacy/RuleDestination.php @@ -16,22 +16,25 @@ namespace danog\MadelineProto\EventHandler\Privacy; -use danog\MadelineProto\EventHandler\Privacy\Rule\AllowAll; -use danog\MadelineProto\EventHandler\Privacy\Rule\AllowChatParticipants; -use danog\MadelineProto\EventHandler\Privacy\Rule\AllowCloseFriends; -use danog\MadelineProto\EventHandler\Privacy\Rule\AllowContacts; -use danog\MadelineProto\EventHandler\Privacy\Rule\AllowUsers; -use danog\MadelineProto\EventHandler\Privacy\Rule\DisallowAll; -use danog\MadelineProto\EventHandler\Privacy\Rule\DisallowChatParticipants; -use danog\MadelineProto\EventHandler\Privacy\Rule\DisallowContacts; -use danog\MadelineProto\EventHandler\Privacy\Rule\DisallowUsers; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowAll; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowChatParticipants; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowCloseFriends; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowContacts; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\AllowUsers; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\DisallowAll; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\DisallowChatParticipants; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\DisallowContacts; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination\DisallowUsers; use JsonSerializable; use ReflectionClass; use ReflectionProperty; -abstract class AbstractRule implements JsonSerializable +/** + * To whom does a privacy rule apply? + */ +abstract class RuleDestination implements JsonSerializable { - public static function fromRawRule(array $rawRule): AbstractRule + public static function fromRawRule(array $rawRule): RuleDestination { return match ($rawRule['_']) { 'privacyValueAllowAll' => new AllowAll, diff --git a/src/EventHandler/Privacy/Rule/AllowAll.php b/src/EventHandler/Privacy/RuleDestination/AllowAll.php similarity index 85% rename from src/EventHandler/Privacy/Rule/AllowAll.php rename to src/EventHandler/Privacy/RuleDestination/AllowAll.php index 86c5e1b44..bdbe43f55 100644 --- a/src/EventHandler/Privacy/Rule/AllowAll.php +++ b/src/EventHandler/Privacy/RuleDestination/AllowAll.php @@ -14,13 +14,13 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; /** * Allow all users. */ -final class AllowAll extends AbstractRule +final class AllowAll extends RuleDestination { } diff --git a/src/EventHandler/Privacy/Rule/AllowChatParticipants.php b/src/EventHandler/Privacy/RuleDestination/AllowChatParticipants.php similarity index 86% rename from src/EventHandler/Privacy/Rule/AllowChatParticipants.php rename to src/EventHandler/Privacy/RuleDestination/AllowChatParticipants.php index 8eb810f09..007471292 100644 --- a/src/EventHandler/Privacy/Rule/AllowChatParticipants.php +++ b/src/EventHandler/Privacy/RuleDestination/AllowChatParticipants.php @@ -14,14 +14,14 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; /** * Allow all participants of certain chats. */ -final class AllowChatParticipants extends AbstractRule +final class AllowChatParticipants extends RuleDestination { /** Allowed chats */ public readonly array $chats; diff --git a/src/EventHandler/Privacy/Rule/AllowCloseFriends.php b/src/EventHandler/Privacy/RuleDestination/AllowCloseFriends.php similarity index 84% rename from src/EventHandler/Privacy/Rule/AllowCloseFriends.php rename to src/EventHandler/Privacy/RuleDestination/AllowCloseFriends.php index c6dc40581..615723548 100644 --- a/src/EventHandler/Privacy/Rule/AllowCloseFriends.php +++ b/src/EventHandler/Privacy/RuleDestination/AllowCloseFriends.php @@ -14,10 +14,10 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; -final class AllowCloseFriends extends AbstractRule +final class AllowCloseFriends extends RuleDestination { } diff --git a/src/EventHandler/Privacy/Rule/AllowContacts.php b/src/EventHandler/Privacy/RuleDestination/AllowContacts.php similarity index 85% rename from src/EventHandler/Privacy/Rule/AllowContacts.php rename to src/EventHandler/Privacy/RuleDestination/AllowContacts.php index 902287ded..0994a8c44 100644 --- a/src/EventHandler/Privacy/Rule/AllowContacts.php +++ b/src/EventHandler/Privacy/RuleDestination/AllowContacts.php @@ -14,13 +14,13 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; /** * Allow all contacts. */ -final class AllowContacts extends AbstractRule +final class AllowContacts extends RuleDestination { } diff --git a/src/EventHandler/Privacy/Rule/AllowUsers.php b/src/EventHandler/Privacy/RuleDestination/AllowUsers.php similarity index 87% rename from src/EventHandler/Privacy/Rule/AllowUsers.php rename to src/EventHandler/Privacy/RuleDestination/AllowUsers.php index c1a7a45f2..aba80346d 100644 --- a/src/EventHandler/Privacy/Rule/AllowUsers.php +++ b/src/EventHandler/Privacy/RuleDestination/AllowUsers.php @@ -14,14 +14,14 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; /** * Allow only certain user. */ -final class AllowUsers extends AbstractRule +final class AllowUsers extends RuleDestination { /** Allowed users */ public readonly array $users; diff --git a/src/EventHandler/Privacy/Rule/DisallowAll.php b/src/EventHandler/Privacy/RuleDestination/DisallowAll.php similarity index 85% rename from src/EventHandler/Privacy/Rule/DisallowAll.php rename to src/EventHandler/Privacy/RuleDestination/DisallowAll.php index 38773c98b..0d2a76b88 100644 --- a/src/EventHandler/Privacy/Rule/DisallowAll.php +++ b/src/EventHandler/Privacy/RuleDestination/DisallowAll.php @@ -14,13 +14,13 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; /** * Disallow all users. */ -final class DisallowAll extends AbstractRule +final class DisallowAll extends RuleDestination { } diff --git a/src/EventHandler/Privacy/Rule/DisallowChatParticipants.php b/src/EventHandler/Privacy/RuleDestination/DisallowChatParticipants.php similarity index 86% rename from src/EventHandler/Privacy/Rule/DisallowChatParticipants.php rename to src/EventHandler/Privacy/RuleDestination/DisallowChatParticipants.php index b70ae88a2..349ddc5d2 100644 --- a/src/EventHandler/Privacy/Rule/DisallowChatParticipants.php +++ b/src/EventHandler/Privacy/RuleDestination/DisallowChatParticipants.php @@ -14,14 +14,14 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; /** * Disallow only participants of certain chats. */ -final class DisallowChatParticipants extends AbstractRule +final class DisallowChatParticipants extends RuleDestination { /** Allowed chats */ public readonly array $chats; diff --git a/src/EventHandler/Privacy/Rule/DisallowContacts.php b/src/EventHandler/Privacy/RuleDestination/DisallowContacts.php similarity index 85% rename from src/EventHandler/Privacy/Rule/DisallowContacts.php rename to src/EventHandler/Privacy/RuleDestination/DisallowContacts.php index a459a141c..b177ac14a 100644 --- a/src/EventHandler/Privacy/Rule/DisallowContacts.php +++ b/src/EventHandler/Privacy/RuleDestination/DisallowContacts.php @@ -14,13 +14,13 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; /** * Disallow only contacts. */ -final class DisallowContacts extends AbstractRule +final class DisallowContacts extends RuleDestination { } diff --git a/src/EventHandler/Privacy/Rule/DisallowUsers.php b/src/EventHandler/Privacy/RuleDestination/DisallowUsers.php similarity index 87% rename from src/EventHandler/Privacy/Rule/DisallowUsers.php rename to src/EventHandler/Privacy/RuleDestination/DisallowUsers.php index 04f3e8067..005055a19 100644 --- a/src/EventHandler/Privacy/Rule/DisallowUsers.php +++ b/src/EventHandler/Privacy/RuleDestination/DisallowUsers.php @@ -14,14 +14,14 @@ * @link https://docs.madelineproto.xyz MadelineProto documentation */ -namespace danog\MadelineProto\EventHandler\Privacy\Rule; +namespace danog\MadelineProto\EventHandler\Privacy\RuleDestination; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; /** * Disallow only certain users. */ -final class DisallowUsers extends AbstractRule +final class DisallowUsers extends RuleDestination { /** Allowed users */ public readonly array $users; diff --git a/src/EventHandler/Story/Story.php b/src/EventHandler/Story/Story.php index 16d1a0ec5..fb48346da 100644 --- a/src/EventHandler/Story/Story.php +++ b/src/EventHandler/Story/Story.php @@ -24,7 +24,7 @@ use danog\MadelineProto\EventHandler\Media\Video; use danog\MadelineProto\EventHandler\Message; use danog\MadelineProto\EventHandler\Message\Entities\MessageEntity; use danog\MadelineProto\EventHandler\Message\ReportReason; -use danog\MadelineProto\EventHandler\Privacy\AbstractRule; +use danog\MadelineProto\EventHandler\Privacy\RuleDestination; use danog\MadelineProto\Ipc\Client; use danog\MadelineProto\MTProto; use danog\MadelineProto\ParseMode; @@ -74,7 +74,7 @@ final class Story extends AbstractStory /** A set of physical coordinates associated to this story */ //public readonly ?array $mediaAreas; //! - /** @var list */ + /** @var list */ public readonly array $privacy; /** Our reaction to the story */ @@ -113,7 +113,7 @@ final class Story extends AbstractStory $this->media = $API->wrapMedia($rawStory['media'], $this->protected); $this->entities = MessageEntity::fromRawEntities($rawStory['entities'] ?? []); - $this->privacy = \array_map(AbstractRule::fromRawRule(...), $rawStory['privacy'] ?? []); + $this->privacy = \array_map(RuleDestination::fromRawRule(...), $rawStory['privacy'] ?? []); $this->recentViewers = $rawStory['views']['recent_viewers'] ?? []; $this->views = $rawStory['views']['views_count'] ?? null; diff --git a/src/EventHandler/AbstractTyping.php b/src/EventHandler/Typing.php similarity index 84% rename from src/EventHandler/AbstractTyping.php rename to src/EventHandler/Typing.php index 6cf1365a5..0a57f1b9d 100644 --- a/src/EventHandler/AbstractTyping.php +++ b/src/EventHandler/Typing.php @@ -21,19 +21,19 @@ use danog\MadelineProto\MTProto; /** * A user is typing. */ -abstract class AbstractTyping extends Update +abstract class Typing extends Update { /** @var int The user id that is typing. */ public readonly int $userId; - /** @var AbstractAction Whether the user is typing, sending a media or doing something else. */ - public readonly AbstractAction $action; + /** @var Action Whether the user is typing, sending a media or doing something else. */ + public readonly Action $action; /** @internal */ public function __construct(MTProto $API, array $rawTyping) { parent::__construct($API); $this->userId = $rawTyping['user_id'] ?? $API->getIdInternal($rawTyping['from_id']); - $this->action = AbstractAction::fromRawAction($rawTyping['action']); + $this->action = Action::fromRawAction($rawTyping['action']); } } diff --git a/src/EventHandler/Typing/SupergroupUserTyping.php b/src/EventHandler/Typing/SupergroupUserTyping.php index 5a4d23fe3..84043ded1 100644 --- a/src/EventHandler/Typing/SupergroupUserTyping.php +++ b/src/EventHandler/Typing/SupergroupUserTyping.php @@ -16,14 +16,14 @@ namespace danog\MadelineProto\EventHandler\Typing; -use danog\MadelineProto\EventHandler\AbstractTyping; +use danog\MadelineProto\EventHandler\Typing; use danog\MadelineProto\MTProto; use danog\MadelineProto\MTProtoTools\DialogId; /** * A user is typing in a [supergroup](https://core.telegram.org/api/channel). */ -final class SupergroupUserTyping extends AbstractTyping +final class SupergroupUserTyping extends Typing { /** @var int Channel ID. */ public readonly int $chatId; diff --git a/src/EventHandler/Typing/UserTyping.php b/src/EventHandler/Typing/UserTyping.php index b2d297550..6ecd7b0f0 100644 --- a/src/EventHandler/Typing/UserTyping.php +++ b/src/EventHandler/Typing/UserTyping.php @@ -16,13 +16,13 @@ namespace danog\MadelineProto\EventHandler\Typing; -use danog\MadelineProto\EventHandler\AbstractTyping; +use danog\MadelineProto\EventHandler\Typing; use danog\MadelineProto\MTProto; /** * The user is preparing a message; typing, recording, uploading, etc. This update is valid for 6 seconds. If no further updates of this kind are received after 6 seconds, it should be considered that the user stopped doing whatever they were doing. */ -final class UserTyping extends AbstractTyping +final class UserTyping extends Typing { /** @internal */ public function __construct(MTProto $API, array $rawTyping) diff --git a/src/EventHandler/User/Status/Emoji.php b/src/EventHandler/User/Status/Emoji.php index e4fa3552b..24fda5304 100644 --- a/src/EventHandler/User/Status/Emoji.php +++ b/src/EventHandler/User/Status/Emoji.php @@ -20,7 +20,7 @@ use danog\MadelineProto\EventHandler\User\Status; use danog\MadelineProto\MTProto; /** - * The [emoji status](https://core.telegram.org/api/emoji-status) of a certain user has changed or removed. + * The [emoji status](https://core.telegram.org/api/emoji-status) of a certain user has changed or was removed. */ final class Emoji extends Status { diff --git a/src/InternalDoc.php b/src/InternalDoc.php index 1d1a29027..d05ef3870 100644 --- a/src/InternalDoc.php +++ b/src/InternalDoc.php @@ -37,7 +37,6 @@ use danog\MadelineProto\EventHandler\Message\Entities\Spoiler; use danog\MadelineProto\EventHandler\Message\Entities\Url; use danog\MadelineProto\EventHandler\Participant\Admin; use danog\MadelineProto\EventHandler\Participant\Member; -use danog\MadelineProto\EventHandler\Privacy\Key; use danog\MadelineProto\EventHandler\Update; use danog\MadelineProto\EventHandler\User\Status\Emoji; use danog\MadelineProto\EventHandler\User\Username;