diff --git a/examples/user-repositories-commits-async.php b/examples/user-repositories-commits-async.php index 27dd3e4f8f..0742bae9f0 100644 --- a/examples/user-repositories-commits-async.php +++ b/examples/user-repositories-commits-async.php @@ -2,6 +2,7 @@ use ApiClients\Client\Github\AsyncClient; use ApiClients\Client\Github\Resource\Async\Repository; use ApiClients\Client\Github\Resource\Async\User; +use ApiClients\Client\Github\Resource\Repository\Commit; use function ApiClients\Foundation\resource_pretty_print; use React\EventLoop\Factory; @@ -17,8 +18,10 @@ return $user->repository($argv[2] ?? 'github'); })->then(function (Repository $repository) { resource_pretty_print($repository, 1, true); - $repository->commits()->subscribe(function ($commit) { - resource_pretty_print($commit, 2, true); + $repository->commits()->take(1)->subscribe(function (Repository\Commit $commit) { + $commit->refresh()->then(function (Commit $commit) { + resource_pretty_print($commit, 2, true); + }); }, 'display_throwable'); })->done(null, 'display_throwable'); diff --git a/src/Resource/Async/Repository/Commit/EmptyFile.php b/src/Resource/Async/Repository/Commit/EmptyFile.php new file mode 100644 index 0000000000..90616b8418 --- /dev/null +++ b/src/Resource/Async/Repository/Commit/EmptyFile.php @@ -0,0 +1,9 @@ +parents; } + + /** + * @return Commit\File[] + */ + public function files(): array + { + return $this->files; + } } diff --git a/src/Resource/Repository/Commit/EmptyFile.php b/src/Resource/Repository/Commit/EmptyFile.php new file mode 100644 index 0000000000..3b82246bc1 --- /dev/null +++ b/src/Resource/Repository/Commit/EmptyFile.php @@ -0,0 +1,72 @@ +filename; + } + + /** + * @return int + */ + public function additions(): int + { + return $this->additions; + } + + /** + * @return int + */ + public function deletions(): int + { + return $this->deletions; + } + + /** + * @return int + */ + public function changes(): int + { + return $this->changes; + } + + /** + * @return string + */ + public function status(): string + { + return $this->status; + } + + /** + * @return string + */ + public function rawUrl(): string + { + return $this->raw_url; + } + + /** + * @return string + */ + public function blobUrl(): string + { + return $this->blob_url; + } + + /** + * @return string + */ + public function patch(): string + { + return $this->patch; + } +} diff --git a/src/Resource/Repository/Commit/FileInterface.php b/src/Resource/Repository/Commit/FileInterface.php new file mode 100644 index 0000000000..e22561f921 --- /dev/null +++ b/src/Resource/Repository/Commit/FileInterface.php @@ -0,0 +1,50 @@ +wait($this->handleCommand(new BuildAsyncFromSyncCommand(self::HYDRATE_CLASS, $this))->then(function (FileInterface $file) { + return $file->refresh(); + })); + } +} diff --git a/tests/Resource/Async/Repository/Commit/EmptyFileTest.php b/tests/Resource/Async/Repository/Commit/EmptyFileTest.php new file mode 100644 index 0000000000..f5cb496a58 --- /dev/null +++ b/tests/Resource/Async/Repository/Commit/EmptyFileTest.php @@ -0,0 +1,19 @@ +