Skip to content

Commit

Permalink
Fix getEventHandler when passing the class name of the main event han…
Browse files Browse the repository at this point in the history
…dler class
  • Loading branch information
danog committed Sep 13, 2024
1 parent e67ed5e commit ac8869d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs
Submodule docs updated 37 files
+1 −2 docs/API_docs/constructors/boost.md
+1 −2 docs/API_docs/constructors/broadcastRevenueBalances.md
+0 −28 docs/API_docs/constructors/channelAdminLogEventActionParticipantSubExtend.md
+1 −2 docs/API_docs/constructors/channelAdminLogEventsFilter.md
+10 −34 docs/API_docs/constructors/index.md
+1 −2 docs/API_docs/constructors/inputMediaPaidMedia.md
+0 −37 docs/API_docs/constructors/inputStorePaymentStarsGiveaway.md
+1 −6 docs/API_docs/constructors/messageActionGiveawayLaunch.md
+1 −2 docs/API_docs/constructors/messageActionGiveawayResults.md
+0 −31 docs/API_docs/constructors/messageActionPrizeStars.md
+2 −3 docs/API_docs/constructors/messageMediaGiveaway.md
+2 −3 docs/API_docs/constructors/messageMediaGiveawayResults.md
+2 −3 docs/API_docs/constructors/payments.giveawayInfoResults.md
+0 −31 docs/API_docs/constructors/prepaidStarsGiveaway.md
+0 −34 docs/API_docs/constructors/starsGiveawayOption.md
+0 −29 docs/API_docs/constructors/starsGiveawayWinnersOption.md
+1 −2 docs/API_docs/constructors/starsTransaction.md
+0 −29 docs/API_docs/constructors/updateBotPurchasedPaidMedia.md
+0 −27 docs/API_docs/constructors/updatePaidReactionPrivacy.md
+1 −1 docs/API_docs/index.md
+1 −9 docs/API_docs/methods/api_index.md
+0 −4 docs/API_docs/methods/index.md
+0 −35 docs/API_docs/methods/messages.getPaidReactionPrivacy.md
+2 −2 docs/API_docs/methods/messages.sendPaidReaction.md
+0 −35 docs/API_docs/methods/payments.getStarsGiveawayOptions.md
+0 −2 docs/API_docs/types/ChannelAdminLogEventAction.md
+0 −2 docs/API_docs/types/InputStorePaymentPurpose.md
+0 −2 docs/API_docs/types/MessageAction.md
+0 −2 docs/API_docs/types/PrepaidGiveaway.md
+0 −23 docs/API_docs/types/StarsGiveawayOption.md
+0 −21 docs/API_docs/types/StarsGiveawayWinnersOption.md
+0 −4 docs/API_docs/types/Update.md
+0 −2 docs/API_docs/types/Updates.md
+0 −4 docs/API_docs/types/index.md
+0 −2 docs/docs/FILTERS.md
+1 −1 docs/docs/USING_METHODS.md
+0 −2 docs/index.md
1 change: 1 addition & 0 deletions src/EventHandler/Message/Entities/MessageEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static function fromRawEntity(array|self $entity): self
'italic', 'messageEntityItalic' => new Italic($entity['offset'], $entity['length']),
'url', 'messageEntityUrl' => new Url($entity['offset'], $entity['length']),
'code', 'messageEntityCode' => new Code($entity['offset'], $entity['length']),
/** @psalm-suppress MixedArgument */
'pre', 'messageEntityPre' => new Pre($entity['offset'], $entity['length'], $entity['language'] ?? ''),
'text_link', 'messageEntityTextUrl' => new TextUrl($entity['offset'], $entity['length'], $entity['url']),
'text_mention', 'messageEntityMentionName' => new MentionName($entity['offset'], $entity['length'], $entity['user_id'] ?? $entity['user']['id']),
Expand Down
3 changes: 3 additions & 0 deletions src/Ipc/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ public function setEventHandler(mixed ...$params): void
public function getEventHandler(?string $class = null): ?EventHandlerProxy
{
if ($class !== null) {
if ($class === $this->getEventHandlerClass()) {
return new EventHandlerProxy(null, $this);
}
return $this->getPlugin($class);
}
return $this->hasEventHandler() ? new EventHandlerProxy(null, $this) : null;
Expand Down
7 changes: 7 additions & 0 deletions src/Wrappers/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ public function getEventHandler(?string $class = null): EventHandler|EventHandle
}
return $this->event_handler_instance;
}
/** @internal */
public function getEventHandlerClass(): ?string
{
return $this->event_handler_instance !== null
? $this->event_handler_instance::class
: null;
}
/**
* Check if an event handler instance is present.
*/
Expand Down

0 comments on commit ac8869d

Please sign in to comment.