@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | if (isset($meta['citation_firstpage'])) { |
29 | 29 | $page = $meta['citation_firstpage']; |
30 | 30 | if (isset($meta['citation_lastpage'])) { |
31 | - $page .= '–' . $meta['citation_lastpage']; |
|
31 | + $page .= '–'.$meta['citation_lastpage']; |
|
32 | 32 | } |
33 | 33 | |
34 | - return (string)$page; |
|
34 | + return (string) $page; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | return null; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } catch (Exception) { |
161 | 161 | // 23/11/2015 00:00:00 |
162 | 162 | if (isset($this->log) && method_exists($this->log, 'notice')) { |
163 | - $this->log->notice('tryFormatDateOrComment failed with ' . $str); |
|
163 | + $this->log->notice('tryFormatDateOrComment failed with '.$str); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return sprintf('<!-- %s -->', $str); |
@@ -266,7 +266,7 @@ |
||
266 | 266 | * @return string|string[] |
267 | 267 | * @throws Throwable |
268 | 268 | */ |
269 | - private function processExternLinks(string $text, array $links): string|array |
|
269 | + private function processExternLinks(string $text, array $links): string | array |
|
270 | 270 | { |
271 | 271 | foreach ($links as $pattern) { |
272 | 272 | if ($this->quota->isQuotaReached()) { |
@@ -128,10 +128,10 @@ |
||
128 | 128 | JSON_THROW_ON_ERROR |
129 | 129 | ); |
130 | 130 | } catch (Throwable $e) { |
131 | - $this->log->error('Catch EDITOR_TITLES_FILENAME import ' . $e->getMessage()); |
|
131 | + $this->log->error('Catch EDITOR_TITLES_FILENAME import '.$e->getMessage()); |
|
132 | 132 | } |
133 | 133 | if (isset($data[$publisherName])) { |
134 | - return (string)urldecode((string) $data[$publisherName]); |
|
134 | + return (string) urldecode((string) $data[$publisherName]); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return null; |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | return OuvrageFactory::GoogleFromIsbn($this->isbn); |
40 | 40 | } catch (Throwable $e) { |
41 | - $this->logger->warning("*** ERREUR GOOGLE Isbn Search ***" . $e->getMessage()); |
|
41 | + $this->logger->warning("*** ERREUR GOOGLE Isbn Search ***".$e->getMessage()); |
|
42 | 42 | if (!str_contains($e->getMessage(), 'Could not resolve host: www.googleapis.com')) { |
43 | 43 | throw $e; |
44 | 44 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | class WikiBotConfig |
32 | 32 | { |
33 | 33 | public const VERSION = '2.0'; |
34 | - public const WATCHPAGE_FILENAME = __DIR__ . '/resources/watch_pages.json'; |
|
34 | + public const WATCHPAGE_FILENAME = __DIR__.'/resources/watch_pages.json'; |
|
35 | 35 | public const EXIT_ON_CHECK_WATCHPAGE = false; |
36 | 36 | // do not stop if they play with {stop} on bot talk page |
37 | 37 | public const BLACKLIST_EDITOR = ['OrlodrimBot']; |
@@ -96,9 +96,8 @@ discard block |
||
96 | 96 | { |
97 | 97 | $text = WikiTextUtil::removeHTMLcomments($text); |
98 | 98 | $botName = $botName ?: self::getBotName(); |
99 | - $denyReg = (empty($botName)) ? '' : |
|
100 | - '|\{\{bots ?\| ?(optout|deny)\=[^\}]*' . preg_quote($botName, '#') . '[^\}]*\}\}'; |
|
101 | - return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}' . $denyReg . ')#i', $text) > 0; |
|
99 | + $denyReg = (empty($botName)) ? '' : '|\{\{bots ?\| ?(optout|deny)\=[^\}]*'.preg_quote($botName, '#').'[^\}]*\}\}'; |
|
100 | + return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}'.$denyReg.')#i', $text) > 0; |
|
102 | 101 | } |
103 | 102 | |
104 | 103 | protected static function getBotOwner() |
@@ -152,7 +151,7 @@ discard block |
||
152 | 151 | |
153 | 152 | protected function getBotTalkPageTitle(): string |
154 | 153 | { |
155 | - return self::TALK_PAGE_PREFIX . $this::getBotName(); |
|
154 | + return self::TALK_PAGE_PREFIX.$this::getBotName(); |
|
156 | 155 | } |
157 | 156 | |
158 | 157 | /** |
@@ -263,8 +262,8 @@ discard block |
||
263 | 262 | */ |
264 | 263 | public function minutesSinceLastEdit(string $title): int |
265 | 264 | { |
266 | - $time = $this->getTimestamp($title); // 2011-09-02T16:31:13Z |
|
265 | + $time = $this->getTimestamp($title); // 2011-09-02T16:31:13Z |
|
267 | 266 | |
268 | - return (int)round((time() - strtotime($time)) / 60); |
|
267 | + return (int) round((time() - strtotime($time)) / 60); |
|
269 | 268 | } |
270 | 269 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | { |
45 | 45 | foreach ($this->validators as $validator) { |
46 | 46 | if (!$validator instanceof ValidatorInterface) { |
47 | - throw new RuntimeException($validator::class . ' must implement ValidatorInterface.'); |
|
47 | + throw new RuntimeException($validator::class.' must implement ValidatorInterface.'); |
|
48 | 48 | } |
49 | 49 | if (!$validator->validate()) { |
50 | 50 | return false; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | || $this->isTextCreatingError($this->ouvrageData['raw']) |
55 | 55 | ) { |
56 | 56 | $this->log->notice("SKIP: template avec commentaire HTML ou modèle problématique."); |
57 | - $this->db->skipRow((int)$this->ouvrageData['id']); |
|
57 | + $this->db->skipRow((int) $this->ouvrageData['id']); |
|
58 | 58 | |
59 | 59 | return false; |
60 | 60 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $find = mb_strpos($this->wikiText, (string) $this->ouvrageData['raw']); |
73 | 73 | if ($find === false) { |
74 | 74 | $this->log->notice("String non trouvée."); |
75 | - $this->db->skipRow((int)$this->ouvrageData['id']); |
|
75 | + $this->db->skipRow((int) $this->ouvrageData['id']); |
|
76 | 76 | |
77 | 77 | return false; |
78 | 78 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | $prefix = ($this->pageWorkStatus->botFlag) ? 'bot ' : ''; |
72 | 72 | $prefix .= (empty($this->pageWorkStatus->errorWarning)) ? '' : ' ⚠️'; // AdQ, BA |
73 | 73 | |
74 | - return $prefix . ((empty($this->pageWorkStatus->featured_article)) ? '' : ' ☆'); |
|
74 | + return $prefix.((empty($this->pageWorkStatus->featured_article)) ? '' : ' ☆'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public const DELAY_BOTFLAG_SECONDS = 60; |
48 | 48 | public const DELAY_NO_BOTFLAG_SECONDS = 60; |
49 | 49 | public const DELAY_MINUTES_AFTER_HUMAN_EDIT = 10; |
50 | - public const ERROR_MSG_TEMPLATE = __DIR__ . '/templates/message_errors.wiki'; |
|
50 | + public const ERROR_MSG_TEMPLATE = __DIR__.'/templates/message_errors.wiki'; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var PageWorkStatus |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | while (true) { |
94 | 94 | echo "\n-------------------------------------\n\n"; |
95 | - echo date("Y-m-d H:i:s") . " "; |
|
95 | + echo date("Y-m-d H:i:s")." "; |
|
96 | 96 | $this->log->info($this->memory->getMemory(true)); |
97 | 97 | $this->pageProcess(); |
98 | 98 | sleep(2); // précaution boucle infinie |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | try { |
125 | 125 | $this->wikiPageAction = ServiceFactory::wikiPageAction($this->pageWorkStatus->getTitle()); // , true ? |
126 | 126 | } catch (Exception) { |
127 | - $this->log->warning("*** WikiPageAction error : " . $this->pageWorkStatus->getTitle() . " \n"); |
|
127 | + $this->log->warning("*** WikiPageAction error : ".$this->pageWorkStatus->getTitle()." \n"); |
|
128 | 128 | sleep(20); |
129 | 129 | |
130 | 130 | return false; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | protected function printTitle(string $title): void |
162 | 162 | { |
163 | - echo Color::BG_CYAN . $title . Color::NORMAL . " \n"; |
|
163 | + echo Color::BG_CYAN.$title.Color::NORMAL." \n"; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | protected function checkArticleLabels($title): void |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | |
234 | 234 | protected function printDebug(array $data) |
235 | 235 | { |
236 | - $this->log->debug('origin: ' . $data['raw']); |
|
237 | - $this->log->debug('completed: ' . $data['opti']); |
|
238 | - $this->log->debug('modifs: ' . $data['modifs']); |
|
239 | - $this->log->debug('version: ' . $data['version']); |
|
236 | + $this->log->debug('origin: '.$data['raw']); |
|
237 | + $this->log->debug('completed: '.$data['opti']); |
|
238 | + $this->log->debug('modifs: '.$data['modifs']); |
|
239 | + $this->log->debug('version: '.$data['version']); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | protected function editPage(): bool |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $this->log->alert("*** Invalid CSRF token \n"); |
256 | 256 | throw new Exception('Invalid CSRF token', $e->getCode(), $e); |
257 | 257 | } else { |
258 | - $this->log->warning('Exception in editPage() ' . $e->getMessage()); |
|
258 | + $this->log->warning('Exception in editPage() '.$e->getMessage()); |
|
259 | 259 | sleep(10); |
260 | 260 | |
261 | 261 | return false; |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | $this->sendOuvrageErrorsOnTalkPage($pageOuvrageCollection, $this->log); |
278 | 278 | } |
279 | 279 | } catch (Throwable $e) { |
280 | - $this->log->warning('Exception in editPage() ' . $e->getMessage()); |
|
280 | + $this->log->warning('Exception in editPage() '.$e->getMessage()); |
|
281 | 281 | unset($e); |
282 | 282 | } |
283 | 283 | |
284 | 284 | if (!$this->pageWorkStatus->botFlag) { |
285 | - $this->log->debug("sleep " . self::DELAY_NO_BOTFLAG_SECONDS); |
|
285 | + $this->log->debug("sleep ".self::DELAY_NO_BOTFLAG_SECONDS); |
|
286 | 286 | sleep(self::DELAY_NO_BOTFLAG_SECONDS); |
287 | 287 | } |
288 | 288 | if ($this->pageWorkStatus->botFlag) { |
289 | - $this->log->debug("sleep " . self::DELAY_BOTFLAG_SECONDS); |
|
289 | + $this->log->debug("sleep ".self::DELAY_BOTFLAG_SECONDS); |
|
290 | 290 | sleep(self::DELAY_BOTFLAG_SECONDS); |
291 | 291 | } |
292 | 292 | } |