| Conditions | 8 |
| Paths | 12 |
| Total Lines | 61 |
| 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 |
||
| 74 | public function getRevisionHeader( $rev, $complete = '' ) { |
||
| 75 | //NOTE: This must be kept in sync with the parent implementation. |
||
| 76 | // Perhaps some parts could be factored out to reduce code duplication. |
||
| 77 | |||
| 78 | if ( $rev instanceof Revision ) { |
||
| 79 | wfDeprecated( __METHOD__ . ' with Revision objects', '1.35' ); |
||
| 80 | $rev = $rev->getRevisionRecord(); |
||
| 81 | } |
||
| 82 | |||
| 83 | $lang = $this->getLanguage(); |
||
| 84 | $user = $this->getUser(); |
||
| 85 | $revtimestamp = $rev->getTimestamp(); |
||
| 86 | $timestamp = $lang->userTimeAndDate( $revtimestamp, $user ); |
||
| 87 | $dateofrev = $lang->userDate( $revtimestamp, $user ); |
||
| 88 | $timeofrev = $lang->userTime( $revtimestamp, $user ); |
||
| 89 | |||
| 90 | $headerMsg = $this->msg( |
||
| 91 | $rev->isCurrent() ? 'currentrev-asof' : 'revisionasof', |
||
| 92 | $timestamp, |
||
| 93 | $dateofrev, |
||
| 94 | $timeofrev |
||
| 95 | ); |
||
| 96 | |||
| 97 | if ( $complete !== 'complete' ) { |
||
| 98 | return $headerMsg->escaped(); |
||
| 99 | } |
||
| 100 | |||
| 101 | $title = $rev->getPageAsLinkTarget(); |
||
| 102 | |||
| 103 | $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); |
||
| 104 | |||
| 105 | $header = $linkRenderer->makeKnownLink( $title, $headerMsg->text(), [], |
||
| 106 | [ 'oldid' => $rev->getId() ] ); |
||
| 107 | |||
| 108 | if ( RevisionRecord::userCanBitfield( |
||
| 109 | $rev->getVisibility(), |
||
| 110 | RevisionRecord::DELETED_TEXT, |
||
| 111 | $user |
||
| 112 | ) ) { |
||
| 113 | if ( MediaWikiServices::getInstance()->getPermissionManager() |
||
| 114 | ->quickUserCan( 'edit', $user, $title ) && !$rev->isCurrent() |
||
| 115 | ) { |
||
| 116 | $editQuery = [ |
||
| 117 | 'action' => 'edit', |
||
| 118 | 'restore' => $rev->getId() |
||
| 119 | ]; |
||
| 120 | $msg = $this->msg( 'wikibase-restoreold' )->text(); |
||
| 121 | $header .= ' ' . $this->msg( 'parentheses' )->rawParams( |
||
| 122 | $linkRenderer->makeKnownLink( $title, $msg, [], $editQuery ) |
||
| 123 | )->escaped(); |
||
| 124 | } |
||
| 125 | |||
| 126 | if ( $rev->isDeleted( RevisionRecord::DELETED_TEXT ) ) { |
||
| 127 | $header = Html::rawElement( 'span', [ 'class' => 'history-deleted' ], $header ); |
||
| 128 | } |
||
| 129 | } else { |
||
| 130 | $header = Html::rawElement( 'span', [ 'class' => 'history-deleted' ], $header ); |
||
| 131 | } |
||
| 132 | |||
| 133 | return $header; |
||
| 134 | } |
||
| 135 | |||
| 197 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..