| Conditions | 9 |
| Paths | 10 |
| Total Lines | 56 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 93 | protected function successfulAction( $direct = false, $extraMessages = null ) { |
||
| 94 | $session = $this->getRequest()->getSession(); |
||
| 95 | $user = $this->targetUser ?: $this->getUser(); |
||
| 96 | |||
| 97 | if ( $direct ) { |
||
| 98 | # Only save preferences if the user is not creating an account for someone else. |
||
| 99 | if ( !$this->proxyAccountCreation ) { |
||
| 100 | Hooks::run( 'AddNewAccount', [ $user, false ] ); |
||
| 101 | |||
| 102 | // If the user does not have a session cookie at this point, they probably need to |
||
| 103 | // do something to their browser. |
||
| 104 | if ( !$this->hasSessionCookie() ) { |
||
| 105 | $this->mainLoginForm( [ /*?*/ ], $session->getProvider()->whyNoSession() ); |
||
|
|
|||
| 106 | // TODO something more specific? This used to use nocookiesnew |
||
| 107 | // FIXME should redirect to login page instead? |
||
| 108 | return; |
||
| 109 | } |
||
| 110 | } else { |
||
| 111 | $byEmail = false; // FIXME no way to set this |
||
| 112 | |||
| 113 | Hooks::run( 'AddNewAccount', [ $user, $byEmail ] ); |
||
| 114 | |||
| 115 | $out = $this->getOutput(); |
||
| 116 | $out->setPageTitle( $this->msg( $byEmail ? 'accmailtitle' : 'accountcreated' ) ); |
||
| 117 | if ( $byEmail ) { |
||
| 118 | $out->addWikiMsg( 'accmailtext', $user->getName(), $user->getEmail() ); |
||
| 119 | } else { |
||
| 120 | $out->addWikiMsg( 'accountcreatedtext', $user->getName() ); |
||
| 121 | } |
||
| 122 | |||
| 123 | $rt = Title::newFromText( $this->mReturnTo ); |
||
| 124 | $out->addReturnTo( |
||
| 125 | ( $rt && !$rt->isExternal() ) ? $rt : $this->getPageTitle(), |
||
| 126 | wfCgiToArray( $this->mReturnToQuery ) |
||
| 127 | ); |
||
| 128 | return; |
||
| 129 | } |
||
| 130 | } |
||
| 131 | |||
| 132 | $this->clearToken(); |
||
| 133 | |||
| 134 | # Run any hooks; display injected HTML |
||
| 135 | $injected_html = ''; |
||
| 136 | $welcome_creation_msg = 'welcomecreation-msg'; |
||
| 137 | Hooks::run( 'UserLoginComplete', [ &$user, &$injected_html, $direct ] ); |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Let any extensions change what message is shown. |
||
| 141 | * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforeWelcomeCreation |
||
| 142 | * @since 1.18 |
||
| 143 | */ |
||
| 144 | Hooks::run( 'BeforeWelcomeCreation', [ &$welcome_creation_msg, &$injected_html ] ); |
||
| 145 | |||
| 146 | $this->showSuccessPage( 'signup', $this->msg( 'welcomeuser', $this->getUser()->getName() ), |
||
| 147 | $welcome_creation_msg, $injected_html, $extraMessages ); |
||
| 148 | } |
||
| 149 | |||
| 174 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.