@@ -24,6 +24,10 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | trait NavigationMenuAccessControl |
| 26 | 26 | { |
| 27 | + /** |
|
| 28 | + * @param string $name |
|
| 29 | + * @param boolean $value |
|
| 30 | + */ |
|
| 27 | 31 | protected abstract function assign($name, $value); |
| 28 | 32 | |
| 29 | 33 | /** |
@@ -32,7 +36,7 @@ discard block |
||
| 32 | 36 | protected abstract function getSecurityManager(); |
| 33 | 37 | |
| 34 | 38 | /** |
| 35 | - * @param $currentUser |
|
| 39 | + * @param \Waca\DataObjects\User $currentUser |
|
| 36 | 40 | */ |
| 37 | 41 | protected function setupNavMenuAccess($currentUser) |
| 38 | 42 | { |
@@ -136,7 +136,7 @@ |
||
| 136 | 136 | /** |
| 137 | 137 | * Assigns a Smarty variable |
| 138 | 138 | * |
| 139 | - * @param array|string $name the template variable name(s) |
|
| 139 | + * @param string $name the template variable name(s) |
|
| 140 | 140 | * @param mixed $value the value to assign |
| 141 | 141 | */ |
| 142 | 142 | abstract protected function assign($name, $value); |
@@ -295,8 +295,7 @@ |
||
| 295 | 295 | if (!$proxyIsInPrivateRange) { |
| 296 | 296 | $proxyReverseDns = $this->getRdnsProvider()->getReverseDNS($proxyAddress); |
| 297 | 297 | $proxyLocation = $this->getLocationProvider()->getIpLocation($proxyAddress); |
| 298 | - } |
|
| 299 | - else { |
|
| 298 | + } else { |
|
| 300 | 299 | // this is going to fail, so why bother trying? |
| 301 | 300 | $proxyReverseDns = false; |
| 302 | 301 | $proxyLocation = false; |
@@ -44,6 +44,9 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | + /** |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 47 | 50 | protected abstract function getRegistrationTemplate(); |
| 48 | 51 | |
| 49 | 52 | protected function isProtectedPage() |
@@ -70,12 +73,12 @@ discard block |
||
| 70 | 73 | } |
| 71 | 74 | |
| 72 | 75 | /** |
| 73 | - * @param $emailAddress |
|
| 74 | - * @param $password |
|
| 75 | - * @param $username |
|
| 76 | + * @param null|string $emailAddress |
|
| 77 | + * @param null|string $password |
|
| 78 | + * @param null|string $username |
|
| 76 | 79 | * @param $useOAuthSignup |
| 77 | - * @param $confirmationId |
|
| 78 | - * @param $onwikiUsername |
|
| 80 | + * @param null|integer $confirmationId |
|
| 81 | + * @param null|string $onwikiUsername |
|
| 79 | 82 | * |
| 80 | 83 | * @throws ApplicationLogicException |
| 81 | 84 | */ |
@@ -36,8 +36,7 @@ discard block |
||
| 36 | 36 | SessionAlert::error($ex->getMessage()); |
| 37 | 37 | $this->redirect('register'); |
| 38 | 38 | } |
| 39 | - } |
|
| 40 | - else { |
|
| 39 | + } else { |
|
| 41 | 40 | $this->assignCSRFToken(); |
| 42 | 41 | $this->assign("useOAuthSignup", $useOAuthSignup); |
| 43 | 42 | $this->setTemplate($this->getRegistrationTemplate()); |
@@ -198,8 +197,7 @@ discard block |
||
| 198 | 197 | WebRequest::setPartialLogin($user); |
| 199 | 198 | |
| 200 | 199 | $this->redirectUrl($oauthHelper->getAuthoriseUrl($requestToken->key)); |
| 201 | - } |
|
| 202 | - else { |
|
| 200 | + } else { |
|
| 203 | 201 | // only notify if we're not using the oauth signup. |
| 204 | 202 | $this->getNotificationHelper()->userNew($user); |
| 205 | 203 | WebRequest::setLoggedInUser($user); |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | /** |
| 48 | 48 | * Gets the default route if no explicit route is requested. |
| 49 | 49 | * |
| 50 | - * @return callable |
|
| 50 | + * @return string[] |
|
| 51 | 51 | */ |
| 52 | 52 | protected function getDefaultRoute() |
| 53 | 53 | { |
@@ -440,7 +440,7 @@ |
||
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | /** |
| 443 | - * @return callable |
|
| 443 | + * @return string[] |
|
| 444 | 444 | */ |
| 445 | 445 | protected function getDefaultRoute() |
| 446 | 446 | { |
@@ -340,8 +340,7 @@ discard block |
||
| 340 | 340 | if (count($pathInfo) === 0) { |
| 341 | 341 | // No pathInfo, so no page to load. Load the main page. |
| 342 | 342 | return $this->getDefaultRoute(); |
| 343 | - } |
|
| 344 | - elseif (count($pathInfo) === 1) { |
|
| 343 | + } elseif (count($pathInfo) === 1) { |
|
| 345 | 344 | // Exactly one path info segment, it's got to be a page. |
| 346 | 345 | $classSegment = $pathInfo[0]; |
| 347 | 346 | |
@@ -353,8 +352,7 @@ discard block |
||
| 353 | 352 | // Let's handle more than two, and collapse it down into two. |
| 354 | 353 | $requestedAction = array_pop($pathInfo); |
| 355 | 354 | $classSegment = implode('/', $pathInfo); |
| 356 | - } |
|
| 357 | - else { |
|
| 355 | + } else { |
|
| 358 | 356 | // Two path info segments. |
| 359 | 357 | $classSegment = $pathInfo[0]; |
| 360 | 358 | $requestedAction = $pathInfo[1]; |
@@ -383,8 +381,7 @@ discard block |
||
| 383 | 381 | $action = 'main'; |
| 384 | 382 | |
| 385 | 383 | return array($pageClass, $action); |
| 386 | - } |
|
| 387 | - else { |
|
| 384 | + } else { |
|
| 388 | 385 | // Doesn't exist in map. Fall back to 404 |
| 389 | 386 | $pageClass = Page404::class; |
| 390 | 387 | $action = "main"; |
@@ -413,16 +410,14 @@ discard block |
||
| 413 | 410 | $action = $requestedAction; |
| 414 | 411 | |
| 415 | 412 | return array($pageClass, $action); |
| 416 | - } |
|
| 417 | - else { |
|
| 413 | + } else { |
|
| 418 | 414 | // Valid page, invalid action. 404 our way out. |
| 419 | 415 | $pageClass = Page404::class; |
| 420 | 416 | $action = 'main'; |
| 421 | 417 | |
| 422 | 418 | return array($pageClass, $action); |
| 423 | 419 | } |
| 424 | - } |
|
| 425 | - else { |
|
| 420 | + } else { |
|
| 426 | 421 | // Class doesn't exist in map. Fall back to 404 |
| 427 | 422 | $pageClass = Page404::class; |
| 428 | 423 | $action = 'main'; |
@@ -24,8 +24,7 @@ |
||
| 24 | 24 | $dateString = $date->format('Y-m-d H:i:s'); |
| 25 | 25 | |
| 26 | 26 | return $dateString; |
| 27 | - } |
|
| 28 | - else { |
|
| 27 | + } else { |
|
| 29 | 28 | return $input; |
| 30 | 29 | } |
| 31 | 30 | } |
| 32 | 31 | \ No newline at end of file |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | && (get_class($input) === DateTime::class || get_class($input) === DateTimeImmutable::class) |
| 23 | 23 | ) { |
| 24 | 24 | $then = $input; |
| 25 | - } |
|
| 26 | - else { |
|
| 25 | + } else { |
|
| 27 | 26 | $then = new DateTime($input); |
| 28 | 27 | } |
| 29 | 28 | |
@@ -48,29 +47,21 @@ discard block |
||
| 48 | 47 | if ($secs <= 10) { |
| 49 | 48 | $output = "just now"; |
| 50 | 49 | $pluralise = false; |
| 51 | - } |
|
| 52 | - elseif ($secs > 10 && $secs < $minuteCut) { |
|
| 50 | + } elseif ($secs > 10 && $secs < $minuteCut) { |
|
| 53 | 51 | $output = round($secs / $second) . " second"; |
| 54 | - } |
|
| 55 | - elseif ($secs >= $minuteCut && $secs < $hourCut) { |
|
| 52 | + } elseif ($secs >= $minuteCut && $secs < $hourCut) { |
|
| 56 | 53 | $output = round($secs / $minute) . " minute"; |
| 57 | - } |
|
| 58 | - elseif ($secs >= $hourCut && $secs < $dayCut) { |
|
| 54 | + } elseif ($secs >= $hourCut && $secs < $dayCut) { |
|
| 59 | 55 | $output = round($secs / $hour) . " hour"; |
| 60 | - } |
|
| 61 | - elseif ($secs >= $dayCut && $secs < $weekCut) { |
|
| 56 | + } elseif ($secs >= $dayCut && $secs < $weekCut) { |
|
| 62 | 57 | $output = round($secs / $day) . " day"; |
| 63 | - } |
|
| 64 | - elseif ($secs >= $weekCut && $secs < $monthCut) { |
|
| 58 | + } elseif ($secs >= $weekCut && $secs < $monthCut) { |
|
| 65 | 59 | $output = round($secs / $week) . " week"; |
| 66 | - } |
|
| 67 | - elseif ($secs >= $monthCut && $secs < $yearCut) { |
|
| 60 | + } elseif ($secs >= $monthCut && $secs < $yearCut) { |
|
| 68 | 61 | $output = round($secs / $month) . " month"; |
| 69 | - } |
|
| 70 | - elseif ($secs >= $yearCut && $secs < $year * 10) { |
|
| 62 | + } elseif ($secs >= $yearCut && $secs < $year * 10) { |
|
| 71 | 63 | $output = round($secs / $year) . " year"; |
| 72 | - } |
|
| 73 | - else { |
|
| 64 | + } else { |
|
| 74 | 65 | $output = "a long time ago"; |
| 75 | 66 | $pluralise = false; |
| 76 | 67 | } |
@@ -75,8 +75,7 @@ |
||
| 75 | 75 | ob_end_clean(); |
| 76 | 76 | |
| 77 | 77 | $message = str_replace('$2$', $textErrorData, $message); |
| 78 | - } |
|
| 79 | - else { |
|
| 78 | + } else { |
|
| 80 | 79 | $message = str_replace('$2$', "", $message); |
| 81 | 80 | } |
| 82 | 81 | |
@@ -52,7 +52,8 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return int |
| 54 | 54 | */ |
| 55 | - $sortKey = function(DataObject $item) { |
|
| 55 | + $sortKey = function(DataObject $item) |
|
| 56 | + { |
|
| 56 | 57 | if ($item instanceof Log) { |
| 57 | 58 | return $item->getTimestamp()->getTimestamp(); |
| 58 | 59 | } |
@@ -296,8 +297,7 @@ discard block |
||
| 296 | 297 | // some old templates have been completely deleted and lost to the depths of time. |
| 297 | 298 | if ($welcomeTemplate === false) { |
| 298 | 299 | return "Welcome template #{$objectId}"; |
| 299 | - } |
|
| 300 | - else { |
|
| 300 | + } else { |
|
| 301 | 301 | $userCode = htmlentities($welcomeTemplate->getUserCode(), ENT_COMPAT, 'UTF-8'); |
| 302 | 302 | |
| 303 | 303 | return "<a href=\"{$baseurl}/internal.php/welcomeTemplates/view?template={$objectId}\">{$userCode}</a>"; |