Convert variable names to camel case

[MAILPOET-1796]
This commit is contained in:
Jan Jakeš
2020-01-09 15:02:58 +01:00
committed by Jan Jakeš
parent f5da704106
commit 54549ff037
687 changed files with 15890 additions and 15887 deletions

View File

@ -23,9 +23,9 @@ class GitHubController {
private $http_client;
public function __construct($username, $token, $project) {
$this->zip_filename = $project === self::PROJECT_MAILPOET ? self::FREE_ZIP_FILENAME : self::PREMIUM_ZIP_FILENAME;
$github_path = $project === self::PROJECT_MAILPOET ? 'mailpoet' : 'mailpoet-premium';
$this->http_client = new Client([
$this->zipFilename = $project === self::PROJECT_MAILPOET ? self::FREE_ZIP_FILENAME : self::PREMIUM_ZIP_FILENAME;
$githubPath = $project === self::PROJECT_MAILPOET ? 'mailpoet' : 'mailpoet-premium';
$this->httpClient = new Client([
'auth' => [$username, $token],
'headers' => [
'Accept' => 'application/vnd.github.v3+json',
@ -35,7 +35,7 @@ class GitHubController {
}
public function createReleasePullRequest($version) {
$response = $this->http_client->post('pulls', [
$response = $this->httpClient->post('pulls', [
'json' => [
'title' => 'Release ' . $version,
'head' => self::RELEASE_SOURCE_BRANCH,
@ -43,24 +43,24 @@ class GitHubController {
],
]);
$response = json_decode($response->getBody()->getContents(), true);
$pull_request_number = $response['number'];
if (!$pull_request_number) {
$pullRequestNumber = $response['number'];
if (!$pullRequestNumber) {
throw new \Exception('Failed to create a new release pull request');
}
$this->assignPullRequest($pull_request_number);
$this->assignPullRequest($pullRequestNumber);
}
private function assignPullRequest($pull_request_number) {
$this->http_client->post("pulls/$pull_request_number/requested_reviewers", [
private function assignPullRequest($pullRequestNumber) {
$this->httpClient->post("pulls/$pull_request_number/requested_reviewers", [
'json' => ['reviewers' => [self::QA_GITHUB_LOGIN]],
]);
$this->http_client->post("issues/$pull_request_number/assignees", [
$this->httpClient->post("issues/$pull_request_number/assignees", [
'json' => ['assignees' => [self::QA_GITHUB_LOGIN]],
]);
}
public function checkReleasePullRequestPassed($version) {
$response = $this->http_client->get('pulls', [
$response = $this->httpClient->get('pulls', [
'query' => [
'state' => 'all',
'head' => self::RELEASE_SOURCE_BRANCH,
@ -72,32 +72,32 @@ class GitHubController {
if (sizeof($response) === 0) {
throw new \Exception('Failed to load release pull requests');
}
$response = array_filter($response, function ($pull_request) use ($version) {
return strpos($pull_request['title'], 'Release ' . $version) !== false;
$response = array_filter($response, function ($pullRequest) use ($version) {
return strpos($pullRequest['title'], 'Release ' . $version) !== false;
});
if (sizeof($response) === 0) {
throw new \Exception('Release pull request not found');
}
$release_pull_request = reset($response);
$this->checkPullRequestChecks($release_pull_request['statuses_url']);
$pull_request_number = $release_pull_request['number'];
$this->checkPullRequestReviews($pull_request_number);
$releasePullRequest = reset($response);
$this->checkPullRequestChecks($releasePullRequest['statuses_url']);
$pullRequestNumber = $releasePullRequest['number'];
$this->checkPullRequestReviews($pullRequestNumber);
}
private function checkPullRequestChecks($statuses_url) {
$response = $this->http_client->get($statuses_url);
private function checkPullRequestChecks($statusesUrl) {
$response = $this->httpClient->get($statusesUrl);
$response = json_decode($response->getBody()->getContents(), true);
// Find checks. Statuses are returned in reverse chronological order. We need to get the first of each type
$latest_statuses = [];
$latestStatuses = [];
foreach ($response as $status) {
if (!isset($latest_statuses[$status['context']])) {
$latest_statuses[$status['context']] = $status;
if (!isset($latestStatuses[$status['context']])) {
$latestStatuses[$status['context']] = $status;
}
}
$failed = [];
foreach ($latest_statuses as $status) {
foreach ($latestStatuses as $status) {
if ($status['state'] !== 'success') {
$failed[] = $status['context'];
}
@ -107,8 +107,8 @@ class GitHubController {
}
}
private function checkPullRequestReviews($pull_request_number) {
$response = $this->http_client->get("pulls/$pull_request_number/reviews");
private function checkPullRequestReviews($pullRequestNumber) {
$response = $this->httpClient->get("pulls/$pull_request_number/reviews");
$response = json_decode($response->getBody()->getContents(), true);
$approved = 0;
foreach ($response as $review) {
@ -121,20 +121,20 @@ class GitHubController {
}
}
public function publishRelease($version, $changelog, $release_zip_path) {
public function publishRelease($version, $changelog, $releaseZipPath) {
$this->ensureNoDraftReleaseExists();
$this->ensureReleaseDoesNotExistYet($version);
$release_info = $this->createReleaseDraft($version, $changelog);
$releaseInfo = $this->createReleaseDraft($version, $changelog);
// remove {?name,label} from the end of 'upload_url'
$upload_url = preg_replace('/\{[^{}]+\}$/ui', '', $release_info['upload_url']);
$this->uploadReleaseZip($upload_url, $release_zip_path);
$this->publishDraftAsRelease($release_info['id']);
$uploadUrl = preg_replace('/\{[^{}]+\}$/ui', '', $releaseInfo['upload_url']);
$this->uploadReleaseZip($uploadUrl, $releaseZipPath);
$this->publishDraftAsRelease($releaseInfo['id']);
}
public function getLatestCommitRevisionOnBranch($branch) {
try {
$response = $this->http_client->get('commits/' . urlencode($branch));
$response = $this->httpClient->get('commits/' . urlencode($branch));
$data = json_decode($response->getBody()->getContents(), true);
} catch (ClientException $e) {
if ($e->getCode() === 404) {
@ -146,7 +146,7 @@ class GitHubController {
}
private function ensureNoDraftReleaseExists() {
$response = $this->http_client->get('releases');
$response = $this->httpClient->get('releases');
$data = json_decode($response->getBody()->getContents(), true);
if (is_array($data) && count($data) > 0 && $data[0]['draft']) {
throw new \Exception('There are unpublished draft releases');
@ -155,7 +155,7 @@ class GitHubController {
private function ensureReleaseDoesNotExistYet($version) {
try {
$this->http_client->get('releases/tags/' . urlencode($version));
$this->httpClient->get('releases/tags/' . urlencode($version));
$existing = true;
} catch (ClientException $e) {
if ($e->getCode() !== 404) {
@ -170,7 +170,7 @@ class GitHubController {
}
private function createReleaseDraft($version, $changelog) {
$response = $this->http_client->post('releases', [
$response = $this->httpClient->post('releases', [
'json' => [
'draft' => true,
'name' => $version,
@ -182,20 +182,20 @@ class GitHubController {
return json_decode($response->getBody()->getContents(), true);
}
private function uploadReleaseZip($upload_url, $release_zip_path) {
$this->http_client->post($upload_url, [
private function uploadReleaseZip($uploadUrl, $releaseZipPath) {
$this->httpClient->post($uploadUrl, [
'headers' => [
'Content-Type' => 'application/zip',
],
'query' => [
'name' => $this->zip_filename,
'name' => $this->zipFilename,
],
'body' => fopen($release_zip_path, 'rb'),
'body' => fopen($releaseZipPath, 'rb'),
]);
}
private function publishDraftAsRelease($release_id) {
$this->http_client->patch('releases/' . urlencode($release_id), [
private function publishDraftAsRelease($releaseId) {
$this->httpClient->patch('releases/' . urlencode($releaseId), [
'json' => [
'draft' => false,
],