@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $this->page = $wiki->newPageGetter()->getFromTitle($title); |
63 | 63 | $this->ns = $this->page->getPageIdentifier()->getTitle()->getNs(); |
64 | 64 | } catch (Throwable $e) { |
65 | - throw new Exception('Erreur construct WikiPageAction ' . $e->getMessage() . $e->getFile() . $e->getLine(), $e->getCode(), $e); |
|
65 | + throw new Exception('Erreur construct WikiPageAction '.$e->getMessage().$e->getFile().$e->getLine(), $e->getCode(), $e); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | public function getRedirect(): ?string |
131 | 131 | { |
132 | 132 | if ($this->getText() && preg_match('/^#REDIRECT(?:ION)? ?\[\[([^]]+)]]/i', $this->getText(), $matches)) { |
133 | - return (string)trim($matches[1]); |
|
133 | + return (string) trim($matches[1]); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return null; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | throw new Exception('That page does not exist'); |
222 | 222 | } |
223 | 223 | $oldText = $this->getText(); |
224 | - $newText = $oldText . "\n" . $addText; |
|
224 | + $newText = $oldText."\n".$addText; |
|
225 | 225 | |
226 | 226 | return $this->editPage($newText, $editInfo); |
227 | 227 | } |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | throw new Exception('That page does not exist'); |
239 | 239 | } |
240 | 240 | $oldText = $this->getText(); |
241 | - $newText = $addText . $oldText; |
|
241 | + $newText = $addText.$oldText; |
|
242 | 242 | |
243 | 243 | return $this->editPage($newText, $editInfo); |
244 | 244 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | // "{{en}} {{zh}} {{ouvrage...}}" |
254 | 254 | // todo test U |
255 | 255 | if (preg_match_all( |
256 | - '#(?<langTemp>{{[a-z][a-z]}} ?{{[a-z][a-z]}}) ?' . preg_quote($tplOrigin, '#') . '#i', |
|
256 | + '#(?<langTemp>{{[a-z][a-z]}} ?{{[a-z][a-z]}}) ?'.preg_quote($tplOrigin, '#').'#i', |
|
257 | 257 | $text, |
258 | 258 | $matches |
259 | 259 | ) |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | // hack // todo: autres patterns {{en}} ? |
268 | 268 | // OK : {{en}} \n {{ouvrage}} |
269 | 269 | if (preg_match_all( |
270 | - "#(?<langTemp>{{(?<lang>[a-z][a-z])}} *\n?)?" . preg_quote($tplOrigin, '#') . '#i', |
|
270 | + "#(?<langTemp>{{(?<lang>[a-z][a-z])}} *\n?)?".preg_quote($tplOrigin, '#').'#i', |
|
271 | 271 | $text, |
272 | 272 | $matches |
273 | 273 | ) > 0 |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | // example : {{en}} {{template|lang=ru}} |
283 | 283 | if (!empty($lang) && self::SKIP_LANG_INDICATOR !== $lang |
284 | 284 | && preg_match('#langue *=#', $tplReplace) |
285 | - && !preg_match('#langue *= ?' . $lang . '#i', $tplReplace) |
|
285 | + && !preg_match('#langue *= ?'.$lang.'#i', $tplReplace) |
|
286 | 286 | && !preg_match('#\| ?langue *= ?\n?\|#', $tplReplace) |
287 | 287 | ) { |
288 | 288 | echo sprintf( |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | // FIX dirty : {{en}} mais langue= avec value non définie sur new template... |
306 | 306 | if (!empty($lang) && preg_match('#\| ?(langue *=) ?\n? ?\|#', $tplReplace, $matchLangue) > 0) { |
307 | 307 | $previousTpl = $tplReplace; |
308 | - $tplReplace = str_replace($matchLangue[1], 'langue=' . $lang, $tplReplace); |
|
308 | + $tplReplace = str_replace($matchLangue[1], 'langue='.$lang, $tplReplace); |
|
309 | 309 | //dump('origin', $tplOrigin); |
310 | 310 | $text = str_replace($previousTpl, $tplReplace, $text); |
311 | 311 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | // replace {template} and {{lang}} {template} |
321 | 321 | $text = str_replace($mention, $tplReplace, $text); |
322 | 322 | $text = str_replace( |
323 | - $matches['langTemp'][$num] . $tplReplace, |
|
323 | + $matches['langTemp'][$num].$tplReplace, |
|
324 | 324 | $tplReplace, |
325 | 325 | $text |
326 | 326 | ); // si 1er replace global sans |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | $parser = new TagParser(); // todo ParserFactory |
341 | 341 | $refs = $parser->importHtml($text)->getRefValues(); // [] |
342 | 342 | |
343 | - return (array)$refs; |
|
343 | + return (array) $refs; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public const SLEEP_AFTER_EDITION = 60; |
33 | 33 | public const MINUTES_DELAY_AFTER_LAST_HUMAN_EDIT = 15; |
34 | 34 | public const CHECK_EDIT_CONFLICT = true; |
35 | - public const ARTICLE_ANALYZED_FILENAME = __DIR__ . '/resources/article_edited.txt'; |
|
35 | + public const ARTICLE_ANALYZED_FILENAME = __DIR__.'/resources/article_edited.txt'; |
|
36 | 36 | public const SKIP_LASTEDIT_BY_BOT = true; |
37 | 37 | public const SKIP_NOT_IN_MAIN_WIKISPACE = true; |
38 | 38 | public const SKIP_ADQ = true; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $this->initializePastAnalyzedTitles(); |
87 | 87 | |
88 | 88 | // @throw exception on "Invalid CSRF token" |
89 | - $this->run();//todo delete that and use (Worker)->run($duration) or process management |
|
89 | + $this->run(); //todo delete that and use (Worker)->run($duration) or process management |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | protected function setUpInConstructor(): void |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | final public function run(): void |
103 | 103 | { |
104 | - echo date('d-m-Y H:i:s') . " *** NEW WORKER ***\n"; |
|
104 | + echo date('d-m-Y H:i:s')." *** NEW WORKER ***\n"; |
|
105 | 105 | foreach ($this->getTitles() as $title) { |
106 | 106 | try { |
107 | 107 | $this->titleProcess($title); |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | |
203 | 203 | // If not a critical edition error |
204 | 204 | // example : Wiki Conflict : Page has been edited after getText() |
205 | - echo "Error : " . $e->getMessage() . "\n"; |
|
205 | + echo "Error : ".$e->getMessage()."\n"; |
|
206 | 206 | $this->log->warning($e->getMessage()); |
207 | 207 | |
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | 211 | dump($result); |
212 | - echo "Sleep " . static::SLEEP_AFTER_EDITION . "\n"; |
|
212 | + echo "Sleep ".static::SLEEP_AFTER_EDITION."\n"; |
|
213 | 213 | sleep(static::SLEEP_AFTER_EDITION); |
214 | 214 | } |
215 | 215 |
@@ -61,20 +61,20 @@ discard block |
||
61 | 61 | // idn_to_ascii('teßt.com',IDNA_NONTRANSITIONAL_TO_ASCII,INTL_IDNA_VARIANT_UTS46) |
62 | 62 | // checkdnsrr($string, "A") // check DNS record |
63 | 63 | if (!self::isHttpURL($url)) { |
64 | - throw new DomainException('URL not compatible : ' . $url); |
|
64 | + throw new DomainException('URL not compatible : '.$url); |
|
65 | 65 | } |
66 | 66 | $response = $this->client->get($url); |
67 | 67 | |
68 | 68 | if (200 !== $response->getStatusCode()) { |
69 | - echo 'HTTP error ' . $response->getStatusCode(); |
|
69 | + echo 'HTTP error '.$response->getStatusCode(); |
|
70 | 70 | if ($this->log !== null) { |
71 | - $this->log->error('HTTP error ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
71 | + $this->log->error('HTTP error '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return null; |
75 | 75 | } |
76 | 76 | |
77 | - $html = (string)$response->getBody()->getContents() ?? ''; |
|
77 | + $html = (string) $response->getBody()->getContents() ?? ''; |
|
78 | 78 | |
79 | 79 | return ($normalized) ? $this->normalizeHtml($html, $url) : $html; |
80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function isHttpURL(string $url): bool |
87 | 87 | { |
88 | - return (bool)preg_match('#^https?://[^ ]+$#i', $url); |
|
88 | + return (bool) preg_match('#^https?://[^ ]+$#i', $url); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $charset = $this->extractCharset($html) ?? 'WINDOWS-1252'; |
113 | 113 | |
114 | 114 | if (empty($charset)) { |
115 | - throw new DomainException('normalized html error and no charset found : ' . $url); |
|
115 | + throw new DomainException('normalized html error and no charset found : '.$url); |
|
116 | 116 | } |
117 | 117 | try { |
118 | 118 | $html2 = iconv($charset, 'UTF-8//TRANSLIT', $html); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return ''; |
122 | 122 | } |
123 | 123 | } catch (Throwable $e) { |
124 | - throw new DomainException("error converting : $charset to UTF-8 on " . $url, $e->getCode(), $e); |
|
124 | + throw new DomainException("error converting : $charset to UTF-8 on ".$url, $e->getCode(), $e); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | return $html2; |
@@ -126,8 +126,7 @@ |
||
126 | 126 | } |
127 | 127 | if (isset($this->summary->memo['count lien brisé'])) { |
128 | 128 | $suffix .= ', ⚠️️️lien brisé'; //⚠️ |