Passed
Push — master ( 3a1d1d...d76cad )
by Dispositif
04:07
created
src/Application/OuvrageEdit/OuvrageEditWorker.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     final public const DELAY_BOTFLAG_SECONDS = 120;
48 48
     final public const DELAY_NO_BOTFLAG_SECONDS = 120;
49 49
     final public const DELAY_MINUTES_AFTER_HUMAN_EDIT = 10;
50
-    final public const ERROR_MSG_TEMPLATE = __DIR__ . '/templates/message_errors.wiki';
50
+    final public const ERROR_MSG_TEMPLATE = __DIR__.'/templates/message_errors.wiki';
51 51
     protected const ALWAYS_NO_BOTFLAG_ON_BA = true;
52 52
     protected const ALWAYS_NO_BOTFLAG_ON_ADQ = true;
53 53
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     {
95 95
         while (true) {
96 96
             echo "\n-------------------------------------\n\n";
97
-            echo date("Y-m-d H:i:s") . " ";
97
+            echo date("Y-m-d H:i:s")." ";
98 98
             $this->log->info($this->memory->getMemory(true));
99 99
             $this->pageProcess();
100 100
             sleep(2); // précaution boucle infinie
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         try {
127 127
             $this->wikiPageAction = ServiceFactory::wikiPageAction($this->pageWorkStatus->getTitle()); // , true ?
128 128
         } catch (Exception) {
129
-            $this->log->warning("*** WikiPageAction error : " . $this->pageWorkStatus->getTitle() . " \n");
129
+            $this->log->warning("*** WikiPageAction error : ".$this->pageWorkStatus->getTitle()." \n");
130 130
             sleep(20);
131 131
 
132 132
             return false;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
     protected function printTitle(string $title): void
164 164
     {
165
-        echo Color::BG_CYAN . $title . Color::NORMAL . " \n";
165
+        echo Color::BG_CYAN.$title.Color::NORMAL." \n";
166 166
     }
167 167
 
168 168
     protected function checkArticleLabels($title): void
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
 
241 241
     protected function printDebug(array $data)
242 242
     {
243
-        $this->log->debug('origin: ' . $data['raw']);
244
-        $this->log->debug('completed: ' . $data['opti']);
245
-        $this->log->debug('modifs: ' . $data['modifs']);
246
-        $this->log->debug('version: ' . $data['version']);
243
+        $this->log->debug('origin: '.$data['raw']);
244
+        $this->log->debug('completed: '.$data['opti']);
245
+        $this->log->debug('modifs: '.$data['modifs']);
246
+        $this->log->debug('version: '.$data['version']);
247 247
     }
248 248
 
249 249
     protected function editPage(): bool
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                 $this->log->alert("*** Invalid CSRF token \n");
263 263
                 throw new Exception('Invalid CSRF token', $e->getCode(), $e);
264 264
             } else {
265
-                $this->log->warning('Exception in editPage() ' . $e->getMessage());
265
+                $this->log->warning('Exception in editPage() '.$e->getMessage());
266 266
                 sleep(10);
267 267
 
268 268
                 return false;
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
                 $this->sendOuvrageErrorsOnTalkPage($pageOuvrageCollection, $this->log);
285 285
             }
286 286
         } catch (Throwable $e) {
287
-            $this->log->warning('Exception in editPage() ' . $e->getMessage());
287
+            $this->log->warning('Exception in editPage() '.$e->getMessage());
288 288
             unset($e);
289 289
         }
290 290
 
291 291
         if (!$this->pageWorkStatus->botFlag) {
292
-            $this->log->debug("sleep " . self::DELAY_NO_BOTFLAG_SECONDS);
292
+            $this->log->debug("sleep ".self::DELAY_NO_BOTFLAG_SECONDS);
293 293
             sleep(self::DELAY_NO_BOTFLAG_SECONDS);
294 294
         }
295 295
         if ($this->pageWorkStatus->botFlag) {
296
-            $this->log->debug("sleep " . self::DELAY_BOTFLAG_SECONDS);
296
+            $this->log->debug("sleep ".self::DELAY_BOTFLAG_SECONDS);
297 297
             sleep(self::DELAY_BOTFLAG_SECONDS);
298 298
         }
299 299
     }
Please login to merge, or discard this patch.
src/Application/TalkBotConfig.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 class TalkBotConfig extends WikiBotConfig
24 24
 {
25 25
     final public const BOT_TALK_SUMMARY = 'Réponse artificielle[[User:Irønie|.]]';
26
-    final public const BOT_TALK_FILE = __DIR__ . '/resources/phrases_zizibot.txt';
27
-    final public const TALKCONFIG_FILENAME = __DIR__ . '/resources/botTalk_config.json';
26
+    final public const BOT_TALK_FILE = __DIR__.'/resources/phrases_zizibot.txt';
27
+    final 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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     {
149 149
         // TODO client
150 150
         $url
151
-            = 'https://fr.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser=' . $this::getBotName()
151
+            = 'https://fr.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuser='.$this::getBotName()
152 152
             . '&ucnamespace=0&uclimit=40&ucprop=title|timestamp|comment&format=json';
153 153
 
154 154
         return file_get_contents($url);
Please login to merge, or discard this patch.
src/Application/AbstractBotTaskWorker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
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 = false;
39 39
     public const THROTTLE_DELAY_AFTER_EACH_TITLE = 1; //secs
40
-    protected const GIT_COMMIT_HASH_PATH = __DIR__ . '/resources/commithash.txt';
40
+    protected const GIT_COMMIT_HASH_PATH = __DIR__.'/resources/commithash.txt';
41 41
 
42 42
     /**
43 43
      * @var PageListInterface
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         $this->initializePastAnalyzedTitles();
94 94
 
95 95
         // @throw exception on "Invalid CSRF token"
96
-        $this->run();//todo delete that and use (Worker)->run($duration) or process management
96
+        $this->run(); //todo delete that and use (Worker)->run($duration) or process management
97 97
     }
98 98
 
99 99
     /**
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
     final public function run(): void
105 105
     {
106 106
         $this->log->notice('*** '.date('Y-m-d H:i')
107
-            .' New BotTaskWorker: ' . $this->defaultTaskname, ['stats' => 'bottaskworker.instance']);
107
+            .' New BotTaskWorker: '.$this->defaultTaskname, ['stats' => 'bottaskworker.instance']);
108 108
         $this->log->notice(sprintf(
109 109
             '*** Bot: %s - commit: %s',
110 110
             $this->bot::getBotName(),
111 111
             $this->bot->getCurrentGitCommitHash() ?? '??'
112 112
         ));
113
-        $this->log->notice('*** Stats: ' . $this->log->stats::class);
113
+        $this->log->notice('*** Stats: '.$this->log->stats::class);
114 114
 
115 115
         foreach ($this->getTitles() as $title) {
116 116
             try {
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         }
226 226
 
227 227
         $this->log->notice($result ? '>> EDIT OK' : '>>  NOCHANGE');
228
-        $this->log->debug("Sleep " . static::SLEEP_AFTER_EDITION);
228
+        $this->log->debug("Sleep ".static::SLEEP_AFTER_EDITION);
229 229
         sleep(static::SLEEP_AFTER_EDITION);
230 230
     }
231 231
 
Please login to merge, or discard this patch.
src/Domain/ExternLink/DeadLinkTransformer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
                 if ($webarchiveDTO->getArchiver() === '[[Internet Archive]]') {
64 64
                     $this->log->notice('
Please login to merge, or discard this patch.
src/Domain/ExternLink/SummaryExternTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
             $this->summary->memo['sites'][] = $this->externalPage->getPrettyDomainName(); // ???
33 33
         }
34 34
         if (isset($mapData['accès url'])) {
35
-            $this->log->debug('accès 
Please login to merge, or discard this patch.
src/Application/CLI/externRefProcess.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -63,13 +63,13 @@
 block discarded – undo
63 63
     $list = new PageList([trim($options['page'])]);
64 64
 
65 65
     // delete Title from edited.txt
66
-    $file = __DIR__ . '/../resources/article_externRef_edited.txt';
66
+    $file = __DIR__.'/../resources/article_externRef_edited.txt';
67 67
     $text = file_get_contents($file);
68
-    $newText = str_replace(trim($argv[1]) . "\n", '', $text);
68
+    $newText = str_replace(trim($argv[1])."\n", '', $text);
69 69
     if (!empty($text) && $text !== $newText) {
70 70
         @file_put_contents($file, $newText);
71 71
     }
72
-    $botConfig->setTaskName('
Please login to merge, or discard this patch.
src/Application/ExternLink/RecentChangeWorker.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 {
32 32
     protected const USER_RC_LIMIT = 100;
33 33
     protected const TASK_NAME = '
Please login to merge, or discard this patch.
src/Application/ExternLink/ExternRefWorker.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     public const SLEEP_AFTER_EDITION = 5; // sec
29 29
     public const MINUTES_DELAY_AFTER_LAST_HUMAN_EDIT = 10; // minutes
30 30
     public const CHECK_EDIT_CONFLICT = true;
31
-    public const ARTICLE_ANALYZED_FILENAME = __DIR__ . '/../resources/article_externRef_edited.txt';
31
+    public const ARTICLE_ANALYZED_FILENAME = __DIR__.'/../resources/article_externRef_edited.txt';
32 32
     public const SKIP_ADQ = false;
33 33
     public const SKIP_LASTEDIT_BY_BOT = false;
34 34
     public const CITATION_NUMBER_ON_FIRE = 15;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             $result = $this->transformer->process($refContent, $this->summary);
78 78
         } catch (Throwable $e) {
79 79
             $this->log->critical(
80
-                'Error patate34 ' . $e->getMessage() . " " . $e->getFile() . ":" . $e->getLine(),
80
+                'Error patate34 '.$e->getMessage()." ".$e->getFile().":".$e->getLine(),
81 81
                 ['stats' => 'externref.exception.patate34']
82 82
             );
83 83
             // TODO : parse $e->message -> variable process, taskName, botflag...
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
         $suffix = '';
145 145
         if (isset($this->summary->memo['count article'])) {
146 146
             $this->log->stats->increment('externref.count.article');
147
-            $suffix .= ' ' . $this->summary->memo['count article'] . 'x {article}';
147
+            $suffix .= ' '.$this->summary->memo['count article'].'x {article}';
148 148
         }
149 149
         if (isset($this->summary->memo['count lien web'])) {
150 150
             $this->log->stats->increment('externref.count.lienweb');
151
-            $suffix .= ' ' . $this->summary->memo['count lien web'] . 'x {lien web}';
151
+            $suffix .= ' '.$this->summary->memo['count lien web'].'x {lien web}';
152 152
         }
153 153
         if (isset($this->summary->memo['presse'])) {
154 154
             $this->log->stats->increment('externref.count.presse');
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
             $this->log->stats->increment('externref.count.lienbrisé');
163 163
             $suffix .= ' ⚠️️️lien brisé'; //⚠️
Please login to merge, or discard this patch.