Passed
Pull Request — master (#1)
by Michael
02:10
created
syntax.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
      * @throws Exception
63 63
      */
64 64
     public function handle($match, $state, $pos, Doku_Handler $handler) {
65
-        list($pmServiceKey,$issueSyntax) = explode('>', trim($match,'[]'));
65
+        list($pmServiceKey, $issueSyntax) = explode('>', trim($match, '[]'));
66 66
 
67 67
         /** @var ServiceInterface $serviceClass */
68 68
         $serviceClass = $this->syntaxPatterns[$pmServiceKey]::getInstance();
69 69
 
70 70
         $issue = $serviceClass->parseIssueSyntax($issueSyntax);
71 71
 
72
-        if(null === $issue) {
72
+        if (null === $issue) {
73 73
             return [$pmServiceKey, $issueSyntax];
74 74
         }
75 75
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @return bool If rendering was successful.
97 97
      */
98 98
     public function render($mode, Doku_Renderer $renderer, $data) {
99
-        if($mode !== 'xhtml' || count($data) === 2) {
99
+        if ($mode !== 'xhtml' || count($data) === 2) {
100 100
             $renderer->interwikilink(null, null, 'google.com', implode(' ', $data));
101 101
             return true;
102 102
         }
Please login to merge, or discard this patch.
action/ajax.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $html = '<div class="org_repos">';
133 133
         $html .= '<p>Below are the repositories of the organisation to which the authorized user has access to. Click on the icon to create/delete the webhook.</p>';
134 134
         $html .= '<div><ul>';
135
-        usort($repos, function ($repo1, $repo2) {return $repo1->displayName < $repo2->displayName ? -1 : 1;});
135
+        usort($repos, function($repo1, $repo2) {return $repo1->displayName < $repo2->displayName ? -1 : 1; });
136 136
         foreach ($repos as $repo) {
137 137
             $stateIssue = empty($repo->hookID) ? 'inactive' : 'active';
138 138
             if ($repo->error === 403) {
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 
177 177
 
178 178
         ignore_user_abort(true);
179
-        set_time_limit(60*20);
179
+        set_time_limit(60 * 20);
180 180
         ob_start();
181 181
         $this->util->sendResponse(202, 'Importing  issues...');
182 182
         header('Connection: close');
183
-        header('Content-Length: '.ob_get_length());
183
+        header('Content-Length: ' . ob_get_length());
184 184
         ob_end_flush();
185 185
         ob_end_flush();
186 186
         flush();
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         $lockID = $data->getImportLockID($serviceName, $projectKey);
280 280
         $lockData = $data->getLockContent($lockID);
281 281
         if ($lockData === false) {
282
-            msg('Import not locked ' . $lockID,2);
282
+            msg('Import not locked ' . $lockID, 2);
283 283
             return [200, ['status' => 'done']];
284 284
         }
285 285
         if (!empty($lockData['status']) && $lockData['status'] === 'done') {
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
     protected function abortIssueImport() {
293 293
         if (!auth_ismanager()) {
294
-            return array(403,'');
294
+            return array(403, '');
295 295
         }
296 296
         /** @var helper_plugin_magicmatcher_data $data */
297 297
         $data = plugin_load('helper', 'magicmatcher_data');
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 
308 308
     protected function abortCommitImport() {
309 309
         if (!auth_ismanager()) {
310
-            return array(403,'');
310
+            return array(403, '');
311 311
         }
312 312
         /** @var helper_plugin_magicmatcher_data $data */
313 313
         $data = plugin_load('helper', 'magicmatcher_data');
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
             $option .= '>';
361 361
             $option .= $issue_option['label'];
362 362
             $option .= '</option>';
363
-            $options.= $option;
363
+            $options .= $option;
364 364
         }
365 365
         return array(200, array('issue_options' => $options));
366 366
     }
Please login to merge, or discard this patch.
helper/db.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 // must be run within Dokuwiki
10 10
 use dokuwiki\plugin\issuelinks\classes\Issue;
11 11
 
12
-if(!defined('DOKU_INC')) die();
12
+if (!defined('DOKU_INC')) die();
13 13
 
14 14
 class helper_plugin_issuelinks_db extends DokuWiki_Plugin
15 15
 {
@@ -24,22 +24,22 @@  discard block
 block discarded – undo
24 24
      * @throws Exception Only thrown in unittests
25 25
      */
26 26
     public function getDB() {
27
-        if(null === $this->db) {
27
+        if (null === $this->db) {
28 28
             /** @var helper_plugin_sqlite $sqlite */
29 29
             $sqlite = plugin_load('helper', 'sqlite');
30
-            if(!$sqlite) {
30
+            if (!$sqlite) {
31 31
                 msg('This plugin requires the sqlite plugin. Please install it', -1);
32 32
                 return null;
33 33
             }
34 34
 
35
-            if($sqlite->getAdapter()->getName() !== DOKU_EXT_PDO) {
36
-                if(defined('DOKU_UNITTEST')) throw new \Exception('Couldn\'t load PDO sqlite.');
35
+            if ($sqlite->getAdapter()->getName() !== DOKU_EXT_PDO) {
36
+                if (defined('DOKU_UNITTEST')) throw new \Exception('Couldn\'t load PDO sqlite.');
37 37
                 return null;
38 38
             }
39 39
             $sqlite->getAdapter()->setUseNativeAlter(true);
40 40
 
41 41
             // initialize the database connection
42
-            if(!$sqlite->init('issuelinks', DOKU_PLUGIN . 'issuelinks/db/')) {
42
+            if (!$sqlite->init('issuelinks', DOKU_PLUGIN . 'issuelinks/db/')) {
43 43
                 return null;
44 44
             }
45 45
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function saveKeyValuePair($key, $value) {
61 61
         $db = $this->getDB();
62
-        if(!$db) return false;
62
+        if (!$db) return false;
63 63
         $sql = 'REPLACE INTO opts VALUES (?, ?)';
64 64
         $db->query($sql, array($key, $value));
65 65
     }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function getKeyValue($key) {
74 74
         $db = $this->getDB();
75
-        if(!$db) return false;
75
+        if (!$db) return false;
76 76
         $sql = 'SELECT val FROM opts WHERE opt = ?';
77 77
         $res = $db->query($sql, array($key));
78 78
         $value = $db->res2single($res);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      * @return bool
133 133
      */
134 134
     public function saveIssue(Issue $issue) {
135
-        $ok = $this->saveEntity('issues', array (
135
+        $ok = $this->saveEntity('issues', array(
136 136
             'service' => $issue->getServiceName(),
137 137
             'project' => $issue->getProject(),
138 138
             'id' => $issue->getKey(),
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
             'type' => $issue->getType(),
143 143
             'status' => $issue->getStatus(),
144 144
             'parent' => $issue->getParent(),
145
-            'components' => implode(',',$issue->getComponents()),
145
+            'components' => implode(',', $issue->getComponents()),
146 146
             'labels' => implode(',', $issue->getLabels()),
147 147
             'priority' => $issue->getPriority(),
148 148
             'duedate' => $issue->getDuedate(),
149 149
             'versions' => implode(',', $issue->getVersions()),
150 150
             'updated' => $issue->getUpdated()
151 151
         ));
152
-        return (bool)$ok;
152
+        return (bool) $ok;
153 153
     }
154 154
 
155 155
 
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
     public function removeOldLinks($serviceName, $projectKey, $issue_id, $isMergeRequest, $pages) {
237 237
         $activeLinks = array();
238 238
 
239
-        foreach($pages as $linkingPage) {
239
+        foreach ($pages as $linkingPage) {
240 240
             $changelog = new PageChangelog($linkingPage['page']);
241 241
             $currentRev = $changelog->getRelativeRevision(time(), -1);
242
-            if($linkingPage['rev'] < $currentRev) {
242
+            if ($linkingPage['rev'] < $currentRev) {
243 243
                 $entity = array(
244 244
                     'page'     => $linkingPage['page'],
245 245
                     'issue_id' => $issue_id,
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         if (!$util->isValidTimeStamp($rev)) {
277 277
             throw new InvalidArgumentException("Second parameter must be a valid timestamp!");
278 278
         }
279
-        if ((int)$rev === 0) {
279
+        if ((int) $rev === 0) {
280 280
             $rev = filemtime(wikiFN($page));
281 281
             $changelog = new PageChangelog($page);
282 282
             $rev_info = $changelog->getRevisionInfo($rev);
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
             $this->savePageRev($page, $rev, $rev_info['sum'], $user);
285 285
         }
286 286
         /** @noinspection TypeUnsafeComparisonInspection this is done to ensure $issue_id is a natural number */
287
-        if (!is_numeric($issue_id) || (int)$issue_id != $issue_id) {
287
+        if (!is_numeric($issue_id) || (int) $issue_id != $issue_id) {
288 288
             throw new InvalidArgumentException("IssueId must be an integer!");
289 289
         }
290
-        $ok = $this->saveEntity('pagerev_issues', array (
290
+        $ok = $this->saveEntity('pagerev_issues', array(
291 291
             'page' => $page,
292 292
             'rev' => $rev,
293 293
             'service' => $serviceName,
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
             'type' => $type
298 298
         ));
299 299
 
300
-        return (bool)$ok;
300
+        return (bool) $ok;
301 301
     }
302 302
 
303 303
     /**
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
         if (!$util->isValidTimeStamp($rev)) {
319 319
             throw new InvalidArgumentException("Second parameter must be a valid timestamp!");
320 320
         }
321
-        $ok = $this->saveEntity('pagerevs', array (
321
+        $ok = $this->saveEntity('pagerevs', array(
322 322
             'page' => $page,
323 323
             'rev' => $rev,
324 324
             'summary' => $summary,
325 325
             'user' => $user,
326 326
         ));
327
-        return (bool)$ok;
327
+        return (bool) $ok;
328 328
     }
329 329
 
330 330
     /**
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
      */
358 358
     private function deleteEntity($table, $entity) {
359 359
         $db = $this->getDB();
360
-        if(!$db) return;
360
+        if (!$db) return;
361 361
 
362 362
         $where = implode(' = ? AND ', array_keys($entity)) . ' = ?';
363 363
         $vals = array_values($entity);
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      */
376 376
     private function saveEntity($table, $entity) {
377 377
         $db = $this->getDB();
378
-        if(!$db) return false;
378
+        if (!$db) return false;
379 379
 
380 380
         $keys = implode(', ', array_keys($entity));
381 381
         $vals = array_values($entity);
@@ -403,16 +403,16 @@  discard block
 block discarded – undo
403 403
      * @return array|bool
404 404
      */
405 405
     private function sqlArrayQuery($sql, $conditional) {
406
-        if (substr(trim($sql),0,strlen('SELECT')) !== 'SELECT') {
406
+        if (substr(trim($sql), 0, strlen('SELECT')) !== 'SELECT') {
407 407
             throw new InvalidArgumentException("SQL-Statement must be a SELECT statement! \n" . $sql);
408 408
         }
409
-        if (strpos(trim($sql,';'), ';') !== false) {
409
+        if (strpos(trim($sql, ';'), ';') !== false) {
410 410
             throw new InvalidArgumentException("SQL-Statement must be one single statement! \n" . $sql);
411 411
         }
412 412
         $db = $this->getDB();
413
-        if(!$db) return false;
413
+        if (!$db) return false;
414 414
 
415
-        $res = $db->query($sql,$conditional);
415
+        $res = $db->query($sql, $conditional);
416 416
         $result = $db->res2arr($res);
417 417
         $db->res_close($res);
418 418
         return $result;
Please login to merge, or discard this patch.
helper/util.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // must be run within Dokuwiki
10
-if(!defined('DOKU_INC')) die();
10
+if (!defined('DOKU_INC')) die();
11 11
 
12 12
 class helper_plugin_issuelinks_util extends DokuWiki_Plugin {
13 13
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      * @param string $linkHeader
18 18
      * @return array
19 19
      */
20
-    public function parseHTTPLinkHeaders ($linkHeader) {
20
+    public function parseHTTPLinkHeaders($linkHeader) {
21 21
         $links = explode(',', $linkHeader);
22 22
         $linkarray = array();
23 23
         foreach ($links as $linkstring) {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     public function reportException(Exception $e) {
67 67
         msg(hsc($e->getMessage()), -1, $e->getLine(), $e->getFile());
68 68
         global $conf;
69
-        if($conf['allowdebug']) {
69
+        if ($conf['allowdebug']) {
70 70
             msg('<pre>' . hsc($e->getTraceAsString()) . '</pre>', -1);
71 71
         }
72 72
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public function sendResponse($code, $msg) {
79 79
         header('Content-Type: application/json');
80
-        if ((int)$code === 204) {
80
+        if ((int) $code === 204) {
81 81
             http_status(200);
82 82
         } else {
83 83
             http_status($code);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @return bool
97 97
      */
98 98
     public function isValidTimeStamp($timestamp) {
99
-        return ((string) (int) $timestamp === (string)$timestamp);
99
+        return ((string) (int) $timestamp === (string) $timestamp);
100 100
     }
101 101
 
102 102
 }
Please login to merge, or discard this patch.
services/AbstractService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 
9 9
     public static function getInstance($forcereload = false) {
10 10
         $class = static::class;
11
-        if(empty(self::$instance[$class]) || $forcereload) {
11
+        if (empty(self::$instance[$class]) || $forcereload) {
12 12
             self::$instance[$class] = new $class();
13 13
         }
14 14
         return self::$instance[$class];
Please login to merge, or discard this patch.
services/GitLab.service.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     {
117 117
         $groups = $this->makeSingleGitLabGetRequest('/groups');
118 118
 
119
-        return array_map(function ($group) {
119
+        return array_map(function($group) {
120 120
             return $group['full_path'];
121 121
         }, $groups);
122 122
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
             try {
140 140
                 $repoHooks = $this->makeSingleGitLabGetRequest("/projects/$organisation%2F{$project['path']}/hooks?per_page=100");
141 141
             } catch (HTTPRequestException $e) {
142
-                $repo->error = (int)$e->getCode();
142
+                $repo->error = (int) $e->getCode();
143 143
             }
144 144
 
145 145
             $repoHooks = array_filter($repoHooks, array($this, 'isOurIssueHook'));
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     public function retrieveAllIssues($projectKey, &$startat = 0)
316 316
     {
317 317
         $perPage = 100;
318
-        $page = ceil(($startat+1)/$perPage);
318
+        $page = ceil(($startat + 1) / $perPage);
319 319
         $endpoint = '/projects/' . urlencode($projectKey) . "/issues?page=$page&per_page=$perPage";
320 320
         $issues = $this->makeSingleGitLabGetRequest($endpoint);
321 321
         $this->total = $this->estimateTotal($perPage, count($issues));
Please login to merge, or discard this patch.
services/GitHub.service.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -334,7 +334,7 @@
 block discarded – undo
334 334
             }
335 335
         }
336 336
         // fixme: add 'user repos'!
337
-        return array_map(function ($org) {
337
+        return array_map(function($org) {
338 338
             return $org['login'];
339 339
         }, $this->orgs);
340 340
     }
Please login to merge, or discard this patch.
classes/Issue.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
      * @return Issue
69 69
      */
70 70
     public static function getInstance($serviceName, $projectKey, $issueId, $isMergeRequest = false, $forcereload = false) {
71
-        $issueHash = $serviceName.$projectKey.$issueId.'!'.$isMergeRequest;
72
-        if(empty(self::$instances[$issueHash]) || $forcereload) {
71
+        $issueHash = $serviceName . $projectKey . $issueId . '!' . $isMergeRequest;
72
+        if (empty(self::$instances[$issueHash]) || $forcereload) {
73 73
             self::$instances[$issueHash] = new Issue($serviceName, $projectKey, $issueId, $isMergeRequest);
74 74
         }
75 75
         return self::$instances[$issueHash];
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
     public function __toString() {
132 132
         $sep = $this->pmService->getProjectIssueSeparator($this->isMergeRequest);
133
-        return $this->projectId . $sep .$this->issueId;
133
+        return $this->projectId . $sep . $this->issueId;
134 134
     }
135 135
 
136 136
     /**
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public function setComponents($components) {
286 286
         if (!is_array($components)) {
287
-            $components = array_filter(array_map('trim', explode(',',$components)));
287
+            $components = array_filter(array_map('trim', explode(',', $components)));
288 288
         }
289 289
         if (!empty($components[0]['name'])) {
290
-            $components = array_map(function($component){return $component['name'];},$components);
290
+            $components = array_map(function($component) {return $component['name']; },$components);
291 291
         }
292 292
         $this->components = $components;
293 293
         return $this;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
      */
300 300
     public function setLabels($labels) {
301 301
         if (!is_array($labels)) {
302
-            $labels = array_filter(array_map('trim', explode(',',$labels)));
302
+            $labels = array_filter(array_map('trim', explode(',', $labels)));
303 303
         }
304 304
         $this->labels = $labels;
305 305
         return $this;
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
      */
312 312
     public function setVersions($versions) {
313 313
         if (!is_array($versions)) {
314
-            $versions = array_map('trim', explode(',',$versions));
314
+            $versions = array_map('trim', explode(',', $versions));
315 315
         }
316 316
         if (!empty($versions[0]['name'])) {
317
-            $versions = array_map(function($version){return $version['name'];},$versions);
317
+            $versions = array_map(function($version) {return $version['name']; },$versions);
318 318
         }
319 319
         $this->versions = $versions;
320 320
         return $this;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
         if (!$util->isValidTimeStamp($updated)) {
331 331
             $updated = strtotime($updated);
332 332
         }
333
-        $this->updated = (int)$updated;
333
+        $this->updated = (int) $updated;
334 334
         return $this;
335 335
     }
336 336
 
@@ -639,16 +639,16 @@  discard block
 block discarded – undo
639 639
      */
640 640
     private function calculateColor($color) {
641 641
         /** @noinspection PrintfScanfArgumentsInspection */
642
-        list($r, $g, $b) = array_map(function($color8bit){
643
-            $c = $color8bit/255;
642
+        list($r, $g, $b) = array_map(function($color8bit) {
643
+            $c = $color8bit / 255;
644 644
             if ($c <= 0.03928) {
645
-                $cl = $c/12.92;
645
+                $cl = $c / 12.92;
646 646
             } else {
647
-                $cl = pow(($c+0.055)/1.055,2.4);
647
+                $cl = pow(($c + 0.055) / 1.055, 2.4);
648 648
             }
649 649
             return $cl;
650 650
         }, sscanf($color, "%02x%02x%02x"));
651
-        if ($r*0.2126 + $g*0.7152 + $b*0.0722 > 0.179) {
651
+        if ($r * 0.2126 + $g * 0.7152 + $b * 0.0722 > 0.179) {
652 652
             return '#000000';
653 653
         }
654 654
         return '#FFFFFF';
Please login to merge, or discard this patch.
classes/IssueLinksException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         /** @var \helper_plugin_struct $plugin */
24 24
         $plugin = plugin_load('helper', 'issuelinks_util');
25 25
         $trans = $plugin->getLang($this->trans_prefix . $message);
26
-        if(!$trans) {
26
+        if (!$trans) {
27 27
             $trans = $message;
28 28
         }
29 29
 
Please login to merge, or discard this patch.