From c7bff70a660cecd3d439f42cf627bd33980f7d43 Mon Sep 17 00:00:00 2001 From: Jeroeny Date: Sat, 2 Nov 2019 12:32:59 +0100 Subject: [PATCH] remove deprecations --- src/Api/MergeRequests.php | 23 ------------ src/Api/Repositories.php | 75 -------------------------------------- src/Model/Branch.php | 37 ++++++++++++++++--- src/Model/Issue.php | 6 +-- src/Model/MergeRequest.php | 10 ++--- src/Model/Noteable.php | 4 +- src/Model/Project.php | 4 +- 7 files changed, 43 insertions(+), 116 deletions(-) diff --git a/src/Api/MergeRequests.php b/src/Api/MergeRequests.php index 1144e593f..7b047875a 100644 --- a/src/Api/MergeRequests.php +++ b/src/Api/MergeRequests.php @@ -8,12 +8,9 @@ use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; use Symfony\Component\OptionsResolver\Options; -use const E_USER_DEPRECATED; use function array_filter; use function count; use function is_array; -use function sprintf; -use function trigger_error; final class MergeRequests extends ApiBase { @@ -167,26 +164,6 @@ public function removeNote(int $projectId, int $mrId, int $noteId) return $this->delete($this->getProjectPath($projectId, 'merge_requests/' . $this->encodePath((string)$mrId) . '/notes/' . $this->encodePath((string)$noteId))); } - /** - * @return mixed - */ - public function showComments(int $project_id, int $mr_id) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the showNotes() method instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->showNotes($project_id, $mr_id); - } - - /** - * @return mixed - */ - public function addComment(int $project_id, int $mr_id, string $note) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.1 and will be removed in 10.0. Use the addNote() method instead.', __METHOD__), E_USER_DEPRECATED); - - return $this->addNote($project_id, $mr_id, $note); - } - /** * @return mixed */ diff --git a/src/Api/Repositories.php b/src/Api/Repositories.php index 5317c8b1e..7522f4dff 100644 --- a/src/Api/Repositories.php +++ b/src/Api/Repositories.php @@ -7,10 +7,7 @@ use DateTimeInterface; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; -use const E_USER_DEPRECATED; use function array_map; -use function sprintf; -use function trigger_error; final class Repositories extends ApiBase { @@ -326,78 +323,6 @@ public function tree(int $project_id, array $params = []) return $this->get($this->getProjectPath($project_id, 'repository/tree'), $params); } - /** - * @return mixed - */ - public function blob(int $project_id, string $sha, string $filepath) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::getRawFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->getRawFile($project_id, $filepath, $sha); - } - - /** - * @return mixed - */ - public function getFile(int $project_id, string $file_path, string $ref) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::getFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->getFile($project_id, $file_path, $ref); - } - - /** - * @return mixed - */ - public function createFile(int $project_id, string $file_path, string $content, string $branch, string $commit_message, ?string $encoding = null, ?string $author_email = null, ?string $author_name = null) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::createFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->createFile($project_id, [ - 'file_path' => $file_path, - 'branch' => $branch, - 'content' => $content, - 'commit_message' => $commit_message, - 'encoding' => $encoding, - 'author_email' => $author_email, - 'author_name' => $author_name, - ]); - } - - /** - * @return mixed - */ - public function updateFile(int $project_id, string $file_path, string $content, string $branch, string $commit_message, ?string $encoding = null, ?string $author_email = null, ?string $author_name = null) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::updateFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->updateFile($project_id, [ - 'file_path' => $file_path, - 'branch' => $branch, - 'content' => $content, - 'commit_message' => $commit_message, - 'encoding' => $encoding, - 'author_email' => $author_email, - 'author_name' => $author_name, - ]); - } - - /** - * @return mixed - */ - public function deleteFile(int $project_id, string $file_path, string $branch, string $commit_message, ?string $author_email = null, ?string $author_name = null) - { - @trigger_error(sprintf('The %s() method is deprecated since version 9.2 and will be removed in 10.0. Use the %s::deleteFile() method instead.', __METHOD__, RepositoryFiles::class), E_USER_DEPRECATED); - - return $this->client->repositoryFiles()->deleteFile($project_id, [ - 'file_path' => $file_path, - 'branch' => $branch, - 'commit_message' => $commit_message, - 'author_email' => $author_email, - 'author_name' => $author_name, - ]); - } - /** * @return mixed */ diff --git a/src/Model/Branch.php b/src/Model/Branch.php index 651b3ccd2..658afacff 100644 --- a/src/Model/Branch.php +++ b/src/Model/Branch.php @@ -8,9 +8,9 @@ use Gitlab\Client; /** - * @property-read string $name - * @property-read bool $protected - * @property-read Commit $commit + * @property-read string $name + * @property-read bool $protected + * @property-read Commit $commit * @property-read Project $project */ final class Branch extends Model @@ -86,21 +86,46 @@ public function commits(array $parameters = []): array public function createFile(string $file_path, string $content, string $commit_message): File { - $data = $this->client->repositories()->createFile($this->project->id, $file_path, $content, $this->name, $commit_message); + $data = $this->client->repositoryFiles()->createFile( + $this->project->id, + [ + 'branch' => $this->name, + 'file_path' => $file_path, + 'content' => $content, + 'commit_message' => $commit_message, + ] + ); return File::fromArray($this->getClient(), $this->project, $data); } public function updateFile(string $file_path, string $content, string $commit_message): File { - $data = $this->client->repositories()->updateFile($this->project->id, $file_path, $content, $this->name, $commit_message); + $data = $this->client->repositoryFiles()->updateFile( + $this->project->id, + [ + + 'branch' => $this->name, + 'file_path' => $file_path, + 'content' => $content, + 'commit_message' => $commit_message, + ] + ); return File::fromArray($this->getClient(), $this->project, $data); } public function deleteFile(string $file_path, string $commit_message): bool { - $this->client->repositories()->deleteFile($this->project->id, $file_path, $this->name, $commit_message); + $this->client->repositoryFiles()->deleteFile( + $this->project->id, + [ + + 'branch' => $this->name, + 'file_path' => $file_path, + 'commit_message' => $commit_message, + ] + ); return true; } diff --git a/src/Model/Issue.php b/src/Model/Issue.php index 0bb29bd54..5915e34f4 100644 --- a/src/Model/Issue.php +++ b/src/Model/Issue.php @@ -97,7 +97,7 @@ public function move(Project $toProject): Issue public function close(?string $comment = null): Issue { if ($comment) { - $this->addComment($comment); + $this->addNote($comment); } return $this->update(['state_event' => 'close']); @@ -113,7 +113,7 @@ public function reopen(): Issue return $this->open(); } - public function addComment(string $comment): Note + public function addNote(string $comment): Note { $data = $this->client->issues()->addComment($this->project->id, $this->iid, ['body' => $comment]); @@ -123,7 +123,7 @@ public function addComment(string $comment): Note /** * @return Note[] */ - public function showComments(): array + public function showNotes(): array { $notes = []; $data = $this->client->issues()->showComments($this->project->id, $this->iid); diff --git a/src/Model/MergeRequest.php b/src/Model/MergeRequest.php index aee26af6a..241d6d3fc 100644 --- a/src/Model/MergeRequest.php +++ b/src/Model/MergeRequest.php @@ -113,7 +113,7 @@ public function update(array $params): MergeRequest public function close(?string $comment = null): MergeRequest { if ($comment) { - $this->addComment($comment); + $this->addNote($comment); } return $this->update(['state_event' => 'close']); @@ -141,9 +141,9 @@ public function merged(): MergeRequest return $this->update(['state_event' => 'merge']); } - public function addComment(string $comment): Note + public function addNote(string $note): Note { - $data = $this->client->mergeRequests()->addComment($this->project->id, $this->iid, $comment); + $data = $this->client->mergeRequests()->addNote($this->project->id, $this->iid, $note); return Note::fromArray($this->getClient(), $this, $data); } @@ -151,10 +151,10 @@ public function addComment(string $comment): Note /** * @return Note[] */ - public function showComments(): array + public function showNotes(): array { $notes = []; - $data = $this->client->mergeRequests()->showComments($this->project->id, $this->iid); + $data = $this->client->mergeRequests()->showNotes($this->project->id, $this->iid); foreach ($data as $note) { $notes[] = Note::fromArray($this->getClient(), $this, $note); diff --git a/src/Model/Noteable.php b/src/Model/Noteable.php index 3df95fe35..7d6dc0be9 100644 --- a/src/Model/Noteable.php +++ b/src/Model/Noteable.php @@ -6,12 +6,12 @@ interface Noteable { - public function addComment(string $comment): Note; + public function addNote(string $comment): Note; /** * @return Note[] */ - public function showComments(): array; + public function showNotes(): array; /** * @return static diff --git a/src/Model/Project.php b/src/Model/Project.php index af3cf6cbb..a1f1e2bc0 100644 --- a/src/Model/Project.php +++ b/src/Model/Project.php @@ -486,7 +486,7 @@ public function tree(array $params = []): array public function blob(string $sha, string $filepath): string { - return $this->client->repositories()->blob($this->id, $sha, $filepath); + return $this->client->repositoryFiles()->getRawFile($this->id, $filepath, $sha); } /** @@ -494,7 +494,7 @@ public function blob(string $sha, string $filepath): string */ public function getFile(string $sha, string $filepath): array { - return $this->client->repositories()->getFile($this->id, $filepath, $sha); + return $this->client->repositoryFiles()->getFile($this->id, $filepath, $sha); } public function createFile(