We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 15 |
| Paths | 2176 |
| Total Lines | 78 |
| Code Lines | 49 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php declare(strict_types=1); |
||
| 5 | function logException(Throwable $e) : void { |
||
| 6 | $message = ''; |
||
| 7 | $delim = "\n\n-----------\n\n"; |
||
| 8 | |||
| 9 | $session = Smr\Session::getInstance(); |
||
| 10 | |||
| 11 | if ($session->hasAccount()) { |
||
| 12 | $account = $session->getAccount(); |
||
| 13 | $message .= 'Login: ' . $account->getLogin() . "\n" . |
||
| 14 | 'E-Mail: ' . $account->getEmail() . "\n" . |
||
| 15 | 'Account ID: ' . $account->getAccountID() . "\n" . |
||
| 16 | 'Game ID: ' . $session->getGameID() . $delim; |
||
| 17 | } |
||
| 18 | $message .= 'Error Message: ' . $e . $delim; |
||
| 19 | |||
| 20 | $message .= '$var: ' . var_export($session->getCurrentVar(), true); |
||
| 21 | |||
| 22 | // Don't display passwords input by users in the log message! |
||
| 23 | if (isset($_REQUEST['password'])) { |
||
| 24 | $_REQUEST['password'] = '*****'; |
||
| 25 | } |
||
| 26 | $message .= "\n\n" . '$_REQUEST: ' . var_export($_REQUEST, true); |
||
| 27 | $message .= $delim; |
||
| 28 | |||
| 29 | $message .= |
||
| 30 | 'User IP: ' . getIpAddress() . "\n" . |
||
| 31 | 'User Agent: ' . ($_SERVER['HTTP_USER_AGENT'] ?? 'undefined') . "\n" . |
||
| 32 | 'USING_AJAX: ' . (defined('USING_AJAX') ? var_export(USING_AJAX, true) : 'undefined') . "\n" . |
||
| 33 | 'URL: ' . (defined('URL') ? URL : 'undefined'); |
||
| 34 | |||
| 35 | try { |
||
| 36 | if (function_exists('release_lock')) { |
||
| 37 | release_lock(); //Try to release lock so they can carry on normally |
||
| 38 | } |
||
| 39 | } catch (Throwable $ee) { |
||
| 40 | $message .= $delim . |
||
| 41 | 'Releasing Lock Failed' . "\n" . |
||
| 42 | 'Message: ' . $ee . "\n"; |
||
| 43 | } |
||
| 44 | |||
| 45 | if (defined('SCRIPT_ID')) { |
||
| 46 | $message = 'Script: ' . SCRIPT_ID . $delim . $message . "\n\n"; |
||
| 47 | } |
||
| 48 | |||
| 49 | // Unconditionally send error message to the log |
||
| 50 | error_log($message); |
||
| 51 | |||
| 52 | if (ENABLE_DEBUG) { |
||
| 53 | // Display error message on the page (redundant with error_log for CLI) |
||
| 54 | if (php_sapi_name() !== 'cli') { |
||
| 55 | echo nl2br($message); |
||
| 56 | } |
||
| 57 | // Skip remaining log methods (too disruptive during development) |
||
| 58 | return; |
||
| 59 | } |
||
| 60 | |||
| 61 | // Send error message to the in-game auto bugs mailbox |
||
| 62 | if ($session->hasPlayer()) { |
||
|
|
|||
| 63 | $session->getPlayer()->sendMessageToBox(BOX_BUGS_AUTO, $message); |
||
| 64 | } elseif ($session->hasAccount()) { |
||
| 65 | // Will be logged without a game_id |
||
| 66 | $session->getAccount()->sendMessageToBox(BOX_BUGS_AUTO, $message); |
||
| 67 | } else { |
||
| 68 | // Will be logged without a game_id or sender_id |
||
| 69 | SmrAccount::doMessageSendingToBox(0, BOX_BUGS_AUTO, $message, 0); |
||
| 70 | } |
||
| 71 | |||
| 72 | // Send error message to e-mail so that we have a permanent record |
||
| 73 | if (!empty(BUG_REPORT_TO_ADDRESSES)) { |
||
| 74 | $mail = setupMailer(); |
||
| 75 | $mail->Subject = (defined('PAGE_PREFIX') ? PAGE_PREFIX : '??? ') . |
||
| 76 | 'Automatic Bug Report'; |
||
| 77 | $mail->setFrom('[email protected]'); |
||
| 78 | $mail->Body = $message; |
||
| 79 | foreach (BUG_REPORT_TO_ADDRESSES as $toAddress) { |
||
| 80 | $mail->addAddress($toAddress); |
||
| 81 | } |
||
| 82 | $mail->send(); |
||
| 83 | } |
||
| 208 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.