From e15ee949f315900fa50c6044281685aaafa4dee9 Mon Sep 17 00:00:00 2001 From: Cameron Eagans Date: Mon, 1 Aug 2022 12:57:07 -0600 Subject: [PATCH] feature #1066 Fix typehint for repository dispatch method (cweagans) This PR was squashed before being merged into the 3.4.x-dev branch. Discussion ---------- Closes https://github.com/KnpLabs/php-github-api/issues/1065 Commits ------- 714798ce7bde498dafae276ac54194cbd1e05144 Fix typehint for repository dispatch method 5005773664c5f0be14c6d6b7d6c2a5bce90e7671 styleci fixes --- lib/Github/Api/Repo.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index 5760a587bed..f5762279e7a 100644 --- a/lib/Github/Api/Repo.php +++ b/lib/Github/Api/Repo.php @@ -286,14 +286,19 @@ public function readme($username, $repository, $format = 'raw', $dir = null, $pa * * @link https://developer.github.com/v3/repos/#create-a-repository-dispatch-event * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $eventType A custom webhook event name + * @param string $username the user who owns the repository + * @param string $repository the name of the repository + * @param string $eventType A custom webhook event name + * @param array|object $clientPayload The payload to pass to Github. * * @return mixed null on success, array on error with 'message' */ - public function dispatch($username, $repository, $eventType, array $clientPayload) + public function dispatch($username, $repository, $eventType, $clientPayload) { + if (is_array($clientPayload)) { + $clientPayload = (object) $clientPayload; + } + return $this->post(\sprintf('/repos/%s/%s/dispatches', rawurlencode($username), rawurlencode($repository)), [ 'event_type' => $eventType, 'client_payload' => $clientPayload,