Skip to content

Commit

Permalink
Use global keyword
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Oct 8, 2020
1 parent 14a2b6f commit 496a33d
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions hooks/lib/github.php
Expand Up @@ -9,7 +9,7 @@

require_once './config.php';

$curl_base_opts = [
$curlBaseOpts = [
CURLOPT_USERAGENT => 'phpMyAdmin-bot',
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
Expand Down Expand Up @@ -108,6 +108,8 @@ function github_verify_post()
*/
function github_make_release($repo, $tag, $version, $description)
{
global $curlBaseOpts;

$ch = curl_init();

$result = [
Expand All @@ -120,7 +122,7 @@ function github_make_release($repo, $tag, $version, $description)
];

//set the url, number of POST vars, POST data
curl_setopt_array($ch, $GLOBALS['curl_base_opts']);
curl_setopt_array($ch, $curlBaseOpts);
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/' . $repo . '/releases');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['tag_name' => $tag, 'name' => $version, 'body' => $description]));
Expand All @@ -141,10 +143,12 @@ function github_make_release($repo, $tag, $version, $description)
*/
function github_comment_pull($repo, $pullid, $comment)
{
global $curlBaseOpts;

$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt_array($ch, $GLOBALS['curl_base_opts']);
curl_setopt_array($ch, $curlBaseOpts);
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/' . $repo . '/issues/' . $pullid . '/comments');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['body' => $comment]));
Expand All @@ -163,10 +167,12 @@ function github_comment_pull($repo, $pullid, $comment)
*/
function github_comment_commit($repo, $sha, $comment)
{
global $curlBaseOpts;

$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt_array($ch, $GLOBALS['curl_base_opts']);
curl_setopt_array($ch, $curlBaseOpts);
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/' . $repo . '/commits/' . $sha . '/comments');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['body' => $comment]));
Expand All @@ -185,8 +191,10 @@ function github_comment_commit($repo, $sha, $comment)
*/
function github_pull_commits($repo, $pullid)
{
global $curlBaseOpts;

$ch = curl_init();
curl_setopt_array($ch, $GLOBALS['curl_base_opts']);
curl_setopt_array($ch, $curlBaseOpts);
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/' . $repo . '/pulls/' . $pullid . '/commits');

//execute post
Expand All @@ -203,8 +211,10 @@ function github_pull_commits($repo, $pullid)
*/
function github_commit_detail($repo, $commit)
{
global $curlBaseOpts;

$ch = curl_init();
curl_setopt_array($ch, $GLOBALS['curl_base_opts']);
curl_setopt_array($ch, $curlBaseOpts);
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/' . $repo . '/commits/' . $commit);

//execute post
Expand All @@ -221,8 +231,10 @@ function github_commit_detail($repo, $commit)
*/
function github_commit_comments($repo, $sha)
{
global $curlBaseOpts;

$ch = curl_init();
curl_setopt_array($ch, $GLOBALS['curl_base_opts']);
curl_setopt_array($ch, $curlBaseOpts);
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/' . $repo . '/commits/' . $sha . '/comments');

//execute post
Expand All @@ -239,8 +251,10 @@ function github_commit_comments($repo, $sha)
*/
function github_pull_diff($repo, $pullid)
{
global $curlBaseOpts;

$ch = curl_init();
curl_setopt_array($ch, $GLOBALS['curl_base_opts']);
curl_setopt_array($ch, $curlBaseOpts);
curl_setopt($ch, CURLOPT_URL, 'https://github.com/' . $repo . '/pull/' . $pullid . '.patch');

//execute post
Expand Down

0 comments on commit 496a33d

Please sign in to comment.