@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | class TalkBotConfig extends WikiBotConfig |
24 | 24 | { |
25 | 25 | public const BOT_TALK_SUMMARY = 'Réponse artificielle'; |
26 | - public const BOT_TALK_FILE = __DIR__ . '/resources/phrases_zizibot.txt'; |
|
27 | - public const TALKCONFIG_FILENAME = __DIR__ . '/resources/botTalk_config.json'; |
|
26 | + public const BOT_TALK_FILE = __DIR__.'/resources/phrases_zizibot.txt'; |
|
27 | + public const TALKCONFIG_FILENAME = __DIR__.'/resources/botTalk_config.json'; |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Add a freaky response in the bottom of the talk page. |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | // ugly dependency |
38 | 38 | $wiki = ServiceFactory::getMediawikiFactory(); |
39 | 39 | if (!$pageTitle) { |
40 | - $pageTitle = 'Discussion utilisateur:' . $this::getBotName(); |
|
40 | + $pageTitle = 'Discussion utilisateur:'.$this::getBotName(); |
|
41 | 41 | } |
42 | 42 | $page = new WikiPageAction($wiki, $pageTitle); |
43 | 43 | $last = $page->page->getRevisions()->getLatest(); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | |
58 | 58 | // No response if time < 24h since last bot owner response |
59 | 59 | if ($last->getUser() == self::getBotOwner()) { |
60 | - $talkConfig['owner_last_time'] = (int)strtotime($last->getTimestamp()); |
|
60 | + $talkConfig['owner_last_time'] = (int) strtotime($last->getTimestamp()); |
|
61 | 61 | file_put_contents(self::TALKCONFIG_FILENAME, json_encode($talkConfig, JSON_THROW_ON_ERROR)); |
62 | 62 | |
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | // No response if time < 24h since last owner response |
66 | - if (isset($talkConfig['owner_last_time']) && (int)$talkConfig['owner_last_time'] > (time() - 60 * 60 * 48)) { |
|
66 | + if (isset($talkConfig['owner_last_time']) && (int) $talkConfig['owner_last_time'] > (time() - 60 * 60 * 48)) { |
|
67 | 67 | echo "No response if time < 24h after last owner response\n"; |
68 | 68 | |
69 | 69 | return false; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $editInfo = new EditInfo(static::BOT_TALK_SUMMARY); |
80 | 80 | $success = $page->addToBottomOfThePage($addText, $editInfo); |
81 | 81 | |
82 | - return (bool)$success; |
|
82 | + return (bool) $success; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | $lines = explode("\n", trim($text)); |
111 | 111 | $lastLine = $lines[count($lines) - 1]; |
112 | 112 | if (preg_match('#^(:*).+#', $lastLine, $matches) && !empty($matches[1])) { |
113 | - $nextIdent = $matches[1] . ':'; |
|
113 | + $nextIdent = $matches[1].':'; |
|
114 | 114 | if (empty($author)) { |
115 | 115 | return $nextIdent; |
116 | 116 | } |
117 | 117 | // search author signature link to check that he wrote on the page bottom |
118 | 118 | if (preg_match( |
119 | - '#\[\[(?:User|Utilisateur|Utilisatrice):' . preg_quote($author, '#') . '[|\]]#i', |
|
119 | + '#\[\[(?:User|Utilisateur|Utilisatrice):'.preg_quote($author, '#').'[|\]]#i', |
|
120 | 120 | $matches[0] |
121 | 121 | ) |
122 | 122 | ) { |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | throw new ConfigException('Pas de phrases disponibles pour TalkBot'); |
138 | 138 | } |
139 | 139 | |
140 | - return (string)trim($sentences[array_rand($sentences)]); |
|
140 | + return (string) trim($sentences[array_rand($sentences)]); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | public function botContribs(): string |
148 | 148 | { |
149 | 149 | $url |
150 | - = 'https://fr.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=' . $this::getBotName() |
|
150 | + = 'https://fr.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser='.$this::getBotName() |
|
151 | 151 | . '&ucnamespace=0&uclimit=40&ucprop=title|timestamp|comment&format=json'; |
152 | 152 | |
153 | 153 | return file_get_contents($url); |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | class ExternRefTransformer implements TransformerInterface |
36 | 36 | { |
37 | 37 | public const HTTP_REQUEST_LOOP_DELAY = 10; |
38 | - public const LOG_REQUEST_ERROR = __DIR__ . '/resources/external_request_error.log'; |
|
39 | - public const SKIP_DOMAIN_FILENAME = __DIR__ . '/resources/config_skip_domain.txt'; |
|
38 | + public const LOG_REQUEST_ERROR = __DIR__.'/resources/external_request_error.log'; |
|
39 | + public const SKIP_DOMAIN_FILENAME = __DIR__.'/resources/config_skip_domain.txt'; |
|
40 | 40 | public const REPLACE_404 = true; |
41 | 41 | |
42 | 42 | public $skipUnauthorised = true; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | $this->url = $url; |
135 | 135 | if (!ExternHttpClient::isHttpURL($url)) { |
136 | - $this->log->debug('Skip : not a valid URL : ' . $url); |
|
136 | + $this->log->debug('Skip : not a valid URL : '.$url); |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | return false; |
142 | 142 | } |
143 | 143 | if (!ExternHttpClient::isHttpURL($url)) { |
144 | - throw new Exception('string is not an URL ' . $url); |
|
144 | + throw new Exception('string is not an URL '.$url); |
|
145 | 145 | } |
146 | 146 | try { |
147 | 147 | $this->domain = InternetDomainParser::getRegistrableDomainFromURL($url); |
148 | 148 | } catch (Exception $e) { |
149 | - $this->log->warning('Skip : not a valid URL : ' . $url); |
|
149 | + $this->log->warning('Skip : not a valid URL : '.$url); |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $this->summary->memo['sites'][] = $this->externalPage->getPrettyDomainName(); |
182 | 182 | } |
183 | 183 | if (isset($mapData['accès url'])) { |
184 | - $this->log->notice('accès |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->page = $wiki->newPageGetter()->getFromTitle($title); |
64 | 64 | $this->ns = $this->page->getPageIdentifier()->getTitle()->getNs(); |
65 | 65 | } catch (Throwable $e) { |
66 | - throw new Exception('Erreur construct WikiPageAction ' . $e->getMessage() . $e->getFile() . $e->getLine(), $e->getCode(), $e); |
|
66 | + throw new Exception('Erreur construct WikiPageAction '.$e->getMessage().$e->getFile().$e->getLine(), $e->getCode(), $e); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | public function getRedirect(): ?string |
132 | 132 | { |
133 | 133 | if ($this->getText() && preg_match('/^#REDIRECT(?:ION)? ?\[\[([^]]+)]]/i', $this->getText(), $matches)) { |
134 | - return (string)trim($matches[1]); |
|
134 | + return (string) trim($matches[1]); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return null; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | throw new Exception('That page does not exist'); |
223 | 223 | } |
224 | 224 | $oldText = $this->getText(); |
225 | - $newText = $oldText . "\n" . $addText; |
|
225 | + $newText = $oldText."\n".$addText; |
|
226 | 226 | |
227 | 227 | return $this->editPage($newText, $editInfo); |
228 | 228 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | throw new Exception('That page does not exist'); |
240 | 240 | } |
241 | 241 | $oldText = $this->getText(); |
242 | - $newText = $addText . $oldText; |
|
242 | + $newText = $addText.$oldText; |
|
243 | 243 | |
244 | 244 | return $this->editPage($newText, $editInfo); |
245 | 245 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | // "{{en}} {{zh}} {{ouvrage...}}" |
255 | 255 | // todo test U |
256 | 256 | if (preg_match_all( |
257 | - '#(?<langTemp>{{[a-z][a-z]}} ?{{[a-z][a-z]}}) ?' . preg_quote($tplOrigin, '#') . '#i', |
|
257 | + '#(?<langTemp>{{[a-z][a-z]}} ?{{[a-z][a-z]}}) ?'.preg_quote($tplOrigin, '#').'#i', |
|
258 | 258 | $text, |
259 | 259 | $matches |
260 | 260 | ) |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | // hack // todo: autres patterns {{en}} ? |
269 | 269 | // OK : {{en}} \n {{ouvrage}} |
270 | 270 | if (preg_match_all( |
271 | - "#(?<langTemp>{{(?<lang>[a-z][a-z])}} *\n?)?" . preg_quote($tplOrigin, '#') . '#i', |
|
271 | + "#(?<langTemp>{{(?<lang>[a-z][a-z])}} *\n?)?".preg_quote($tplOrigin, '#').'#i', |
|
272 | 272 | $text, |
273 | 273 | $matches |
274 | 274 | ) > 0 |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | // example : {{en}} {{template|lang=ru}} |
284 | 284 | if (!empty($lang) && self::SKIP_LANG_INDICATOR !== $lang |
285 | 285 | && preg_match('#langue *=#', $tplReplace) |
286 | - && !preg_match('#langue *= ?' . $lang . '#i', $tplReplace) |
|
286 | + && !preg_match('#langue *= ?'.$lang.'#i', $tplReplace) |
|
287 | 287 | && !preg_match('#\| ?langue *= ?\n?\|#', $tplReplace) |
288 | 288 | ) { |
289 | 289 | echo sprintf( |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | // FIX dirty : {{en}} mais langue= avec value non définie sur new template... |
307 | 307 | if (!empty($lang) && preg_match('#\| ?(langue *=) ?\n? ?\|#', $tplReplace, $matchLangue) > 0) { |
308 | 308 | $previousTpl = $tplReplace; |
309 | - $tplReplace = str_replace($matchLangue[1], 'langue=' . $lang, $tplReplace); |
|
309 | + $tplReplace = str_replace($matchLangue[1], 'langue='.$lang, $tplReplace); |
|
310 | 310 | //dump('origin', $tplOrigin); |
311 | 311 | $text = str_replace($previousTpl, $tplReplace, $text); |
312 | 312 | } |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | // replace {template} and {{lang}} {template} |
322 | 322 | $text = str_replace($mention, $tplReplace, $text); |
323 | 323 | $text = str_replace( |
324 | - $matches['langTemp'][$num] . $tplReplace, |
|
324 | + $matches['langTemp'][$num].$tplReplace, |
|
325 | 325 | $tplReplace, |
326 | 326 | $text |
327 | 327 | ); // si 1er replace global sans |