@@ -41,7 +41,7 @@ |
||
41 | 41 | * Lingo\Backend constructor. |
42 | 42 | * @param MessageLog|null $messages |
43 | 43 | */ |
44 | - public function __construct( MessageLog &$messages = null ) { |
|
44 | + public function __construct( MessageLog & $messages = null ) { |
|
45 | 45 | |
46 | 46 | if ( !$messages ) { |
47 | 47 | $this->mMessageLog = new MessageLog(); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param String $definition |
86 | 86 | * @return Array the tree node the element was stored in |
87 | 87 | */ |
88 | - protected function &addElement( Array &$path, &$term, &$definition ) { |
|
88 | + protected function &addElement( array &$path, &$term, &$definition ) { |
|
89 | 89 | |
90 | 90 | $tree = &$this->mTree; |
91 | 91 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - public function findNextTermNoSkip( Array &$tree, &$lexemes, $index, $countLexemes ) { |
|
145 | + public function findNextTermNoSkip( array &$tree, &$lexemes, $index, $countLexemes ) { |
|
146 | 146 | |
147 | 147 | if ( $index + 1 < $countLexemes && array_key_exists( $currLex = $lexemes[ $index + 1 ][ 0 ], $tree ) ) { |
148 | 148 | $ret = $this->findNextTermNoSkip( $tree[ $currLex ], $lexemes, $index + 1, $countLexemes ); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param int $severity |
54 | 54 | */ |
55 | 55 | public function addMessage( $message, $severity = self::MESSAGE_NOTICE ) { |
56 | - $this->mMessages[] = array( $message, $severity ); |
|
56 | + $this->mMessages[ ] = array( $message, $severity ); |
|
57 | 57 | |
58 | 58 | // log errors and warnings in debug log |
59 | 59 | if ( $severity == self::MESSAGE_WARNING || |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param $message |
68 | 68 | */ |
69 | 69 | public function addError( $message ) { |
70 | - $this->mMessages[] = array( $message, self::MESSAGE_ERROR ); |
|
70 | + $this->mMessages[ ] = array( $message, self::MESSAGE_ERROR ); |
|
71 | 71 | wfDebug( "Error: $message\n" ); |
72 | 72 | } |
73 | 73 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param $message |
76 | 76 | */ |
77 | 77 | public function addWarning( $message ) { |
78 | - $this->mMessages[] = array( $message, self::MESSAGE_WARNING ); |
|
78 | + $this->mMessages[ ] = array( $message, self::MESSAGE_WARNING ); |
|
79 | 79 | wfDebug( "Warning: $message\n" ); |
80 | 80 | } |
81 | 81 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param $message |
84 | 84 | */ |
85 | 85 | public function addNotice( $message ) { |
86 | - $this->mMessages[] = array( $message, self::MESSAGE_NOTICE ); |
|
86 | + $this->mMessages[ ] = array( $message, self::MESSAGE_NOTICE ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function initExtension() { |
46 | 46 | |
47 | - $GLOBALS[ 'wgExtensionFunctions' ][] = function () { |
|
47 | + $GLOBALS[ 'wgExtensionFunctions' ][ ] = function() { |
|
48 | 48 | |
49 | 49 | $parser = LingoParser::getInstance(); |
50 | 50 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | |
55 | 55 | \Hooks::register( 'ParserAfterParse', array( $parser, 'parse' ) ); |
56 | 56 | |
57 | - \Hooks::register( 'ParserFirstCallInit', function ( \Parser $parser ) { |
|
57 | + \Hooks::register( 'ParserFirstCallInit', function( \Parser $parser ) { |
|
58 | 58 | |
59 | - $parser->setHook( 'noglossary', function ( $input, array $args, Parser $parser, PPFrame $frame ) { |
|
59 | + $parser->setHook( 'noglossary', function( $input, array $args, Parser $parser, PPFrame $frame ) { |
|
60 | 60 | $output = $parser->recursiveTagParse( $input, $frame ); |
61 | 61 | return '<span class="noglossary">' . $output . '</span>'; |
62 | 62 | } ); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | return true; |
65 | 65 | } ); |
66 | 66 | |
67 | - MagicWord::$mDoubleUnderscoreIDs[] = 'noglossary'; |
|
67 | + MagicWord::$mDoubleUnderscoreIDs[ ] = 'noglossary'; |
|
68 | 68 | |
69 | 69 | foreach ( $GLOBALS[ 'wgExtensionCredits' ][ 'parserhook' ] as $index => $description ) { |
70 | 70 |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * Lingo\LingoParser constructor. |
58 | 58 | * @param MessageLog|null $messages |
59 | 59 | */ |
60 | - public function __construct( MessageLog &$messages = null ) { |
|
60 | + public function __construct( MessageLog & $messages = null ) { |
|
61 | 61 | // The RegEx to split a chunk of text into words |
62 | 62 | // Words are: placeholders for stripped items, sequences of letters and numbers, single characters that are neither letter nor number |
63 | 63 | $this->regex = '/' . preg_quote( Parser::MARKER_PREFIX, '/' ) . '.*?' . preg_quote( Parser::MARKER_SUFFIX, '/' ) . '|[\p{L}\p{N}]+|[^\p{L}\p{N}]/u'; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param string $text |
70 | 70 | * @return Boolean |
71 | 71 | */ |
72 | - public function parse( Parser &$parser, &$text ) { |
|
72 | + public function parse( Parser & $parser, &$text ) { |
|
73 | 73 | |
74 | 74 | // parse if |
75 | 75 | if ( $this->shouldParse( $parser ) ) { |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } else { |
162 | 162 | |
163 | 163 | wfDebug( "Cache miss: Lingo tree not found in cache.\n" ); |
164 | - $this->mLingoTree =& $this->buildLingo(); |
|
164 | + $this->mLingoTree = & $this->buildLingo(); |
|
165 | 165 | wfDebug( "Cached lingo tree.\n" ); |
166 | 166 | } |
167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | } else { |
174 | 174 | wfDebug( "Caching of lingo tree disabled.\n" ); |
175 | - $this->mLingoTree =& $this->buildLingo(); |
|
175 | + $this->mLingoTree = & $this->buildLingo(); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * @param Parser $parser |
386 | 386 | * @return bool |
387 | 387 | */ |
388 | - protected function shouldParse( Parser &$parser ) { |
|
388 | + protected function shouldParse( Parser & $parser ) { |
|
389 | 389 | global $wgexLingoUseNamespaces; |
390 | 390 | |
391 | 391 | $title = $parser->getTitle(); |
@@ -28,8 +28,6 @@ |
||
28 | 28 | */ |
29 | 29 | namespace Lingo; |
30 | 30 | |
31 | -use DOMDocument; |
|
32 | -use DOMXPath; |
|
33 | 31 | use Parser; |
34 | 32 | |
35 | 33 | /** |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Lingo\Element constructor. |
61 | - * @param $term |
|
62 | - * @param $definition |
|
61 | + * @param string $term |
|
62 | + * @param string $definition |
|
63 | 63 | */ |
64 | 64 | public function __construct( &$term, &$definition = null ) { |
65 | 65 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | /** |
154 | 154 | * @param $target |
155 | - * @param $link |
|
155 | + * @param DOMElement $link |
|
156 | 156 | * @return mixed |
157 | 157 | */ |
158 | 158 | protected function &addClassAttributeToLink( $target, &$link ) { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | /** |
205 | 205 | * @param StashingDOMDocument $doc |
206 | - * @return string |
|
206 | + * @return DOMElement |
|
207 | 207 | * @throws \MWException |
208 | 208 | */ |
209 | 209 | protected function getFullDefinitionAsTooltip( StashingDOMDocument &$doc ) { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | const ELEMENT_LINK = 3; |
48 | 48 | const ELEMENT_STYLE = 4; |
49 | 49 | |
50 | - const ELEMENT_FIELDCOUNT = 5; // number of fields stored for each element; (last field's index) + 1 |
|
50 | + const ELEMENT_FIELDCOUNT = 5; // number of fields stored for each element; (last field's index) + 1 |
|
51 | 51 | |
52 | 52 | const LINK_TEMPLATE_ID = 'LingoLink'; |
53 | 53 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * @param $definition |
75 | 75 | */ |
76 | 76 | public function addDefinition( &$definition ) { |
77 | - $this->mDefinitions[] = array_pad( $definition, self::ELEMENT_FIELDCOUNT, null ); |
|
77 | + $this->mDefinitions[ ] = array_pad( $definition, self::ELEMENT_FIELDCOUNT, null ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * @param StashingDOMDocument $doc |
82 | 82 | * @return DOMNode|DOMText |
83 | 83 | */ |
84 | - public function getFullDefinition( StashingDOMDocument &$doc ) { |
|
84 | + public function getFullDefinition( StashingDOMDocument & $doc ) { |
|
85 | 85 | |
86 | 86 | global $wgexLingoDisplayOnce; |
87 | 87 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * @param StashingDOMDocument $doc |
100 | 100 | */ |
101 | - private function buildFullDefinition( StashingDOMDocument &$doc ) { |
|
101 | + private function buildFullDefinition( StashingDOMDocument & $doc ) { |
|
102 | 102 | |
103 | 103 | // only create if not yet created |
104 | 104 | if ( $this->mFullDefinition === null || $this->mFullDefinition->ownerDocument !== $doc ) { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return DOMElement |
126 | 126 | * @throws \MWException |
127 | 127 | */ |
128 | - protected function getFullDefinitionAsLink( StashingDOMDocument &$doc ) { |
|
128 | + protected function getFullDefinitionAsLink( StashingDOMDocument & $doc ) { |
|
129 | 129 | |
130 | 130 | // create Title object for target page |
131 | 131 | $target = Title::newFromText( $this->mDefinitions[ 0 ][ self::ELEMENT_LINK ] ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @return string |
207 | 207 | * @throws \MWException |
208 | 208 | */ |
209 | - protected function getFullDefinitionAsTooltip( StashingDOMDocument &$doc ) { |
|
209 | + protected function getFullDefinitionAsTooltip( StashingDOMDocument & $doc ) { |
|
210 | 210 | |
211 | 211 | // Wrap term and definition in <span> tags |
212 | 212 | $span = $doc->createElement( 'span' ); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @param StashingDOMDocument $doc |
252 | 252 | * @return DOMNode |
253 | 253 | */ |
254 | - private function getLinkTemplate( StashingDOMDocument &$doc ) { |
|
254 | + private function getLinkTemplate( StashingDOMDocument & $doc ) { |
|
255 | 255 | |
256 | 256 | $mLinkTemplate = $doc->stashGet( self::LINK_TEMPLATE_ID ); |
257 | 257 |
@@ -70,7 +70,7 @@ |
||
70 | 70 | * @param $key |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | - public function isStashed ( $key ) { |
|
73 | + public function isStashed( $key ) { |
|
74 | 74 | return isset( $this->mStash[ $key ] ); |
75 | 75 | } |
76 | 76 |
@@ -128,8 +128,8 @@ |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * @param $definitions |
|
132 | - * @param $term |
|
131 | + * @param string[] $definitions |
|
132 | + * @param string $term |
|
133 | 133 | * @return array |
134 | 134 | */ |
135 | 135 | protected function queueDefinitions( $definitions, $term ) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * Lingo\BasicBackend constructor. |
51 | 51 | * @param MessageLog|null $messages |
52 | 52 | */ |
53 | - public function __construct( MessageLog &$messages = null ) { |
|
53 | + public function __construct( MessageLog & $messages = null ) { |
|
54 | 54 | |
55 | 55 | parent::__construct( $messages ); |
56 | 56 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $term = null; |
117 | 117 | } |
118 | 118 | |
119 | - $definitions[] = trim( $chunks[ 1 ] ); |
|
119 | + $definitions[ ] = trim( $chunks[ 1 ] ); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | // found a new term? |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $ret = array(); |
137 | 137 | |
138 | 138 | foreach ( $definitions as $definition ) { |
139 | - $ret[] = array( |
|
139 | + $ret[ ] = array( |
|
140 | 140 | Element::ELEMENT_TERM => $term, |
141 | 141 | Element::ELEMENT_DEFINITION => $definition, |
142 | 142 | Element::ELEMENT_LINK => null, |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @param WikiPage $wikipage |
256 | 256 | * @return Bool |
257 | 257 | */ |
258 | - public function purgeCache( WikiPage &$wikipage ) { |
|
258 | + public function purgeCache( WikiPage & $wikipage ) { |
|
259 | 259 | |
260 | 260 | if ( !is_null( $wikipage ) && ( $wikipage->getTitle()->getText() === $this->getLingoPageName() ) ) { |
261 | 261 |