Passed
Push — master ( 44ff32...6b8380 )
by Dispositif
02:20
created
src/Application/Examples/testExternLink.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
     // Attention : pas de post-processing (sanitize title, etc.)
35 35
     $result = $trans->process($url, $summary);
36 36
 } catch (Exception $e) {
37
-    echo "EXCEPTION ". $e->getMessage().$e->getFile().$e->getLine();
37
+    echo "EXCEPTION ".$e->getMessage().$e->getFile().$e->getLine();
38 38
 }
39 39
 
40 40
 echo $result."\n";
Please login to merge, or discard this patch.
src/Domain/Utils/TextUtil.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -274,7 +274,7 @@
 block discarded – undo
274 274
         if (mb_strlen($text) > $maxLength) {
275 275
             $spacePos = mb_strrpos(mb_substr($text, 0, $maxLength), ' ');
276 276
             $spacePos = ($spacePos > ($maxLength - 12)) ? $spacePos : $maxLength;
277
-            $text = trim(mb_substr($text, 0, $spacePos)) . self::SYMBOL_TEXT_CUT;
277
+            $text = trim(mb_substr($text, 0, $spacePos)).self::SYMBOL_TEXT_CUT;
278 278
         }
279 279
 
280 280
         return $text;
Please login to merge, or discard this patch.
src/Domain/Publisher/SeoSanitizer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         }
55 55
 
56 56
         // rebuild title but keep only the first 2 segments
57
-        return trim($titleSegments[0]) . self::REBUILD_SEPARATOR . trim($titleSegments[1]);
57
+        return trim($titleSegments[0]).self::REBUILD_SEPARATOR.trim($titleSegments[1]);
58 58
     }
59 59
 
60 60
     /**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
         return array_values(array_filter(
104 104
             $seoSegments,
105
-            function ($segment) use ($prettyDomainName, $siteName) {
105
+            function($segment) use ($prettyDomainName, $siteName) {
106 106
                 $strippedSegment = mb_strtolower(TextUtil::stripPunctuation(TextUtil::stripAccents($segment)));
107 107
                 $strippedSegment = str_replace(['.', '-', ' '], '', $strippedSegment);
108 108
 
Please login to merge, or discard this patch.
src/Application/WikiBotConfig.php 1 patch
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 {
34 34
     public const VERSION = '1.0';
35 35
 
36
-    public const WATCHPAGE_FILENAME = __DIR__ . '/resources/watch_pages.json';
36
+    public const WATCHPAGE_FILENAME = __DIR__.'/resources/watch_pages.json';
37 37
 
38 38
     public const EXIT_ON_CHECK_WATCHPAGE = false;
39 39
 
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function minutesSinceLastEdit(string $title): int
158 158
     {
159
-        $time = $this->getTimestamp($title);  // 2011-09-02T16:31:13Z
159
+        $time = $this->getTimestamp($title); // 2011-09-02T16:31:13Z
160 160
 
161
-        return (int)round((time() - strtotime($time)) / 60);
161
+        return (int) round((time() - strtotime($time)) / 60);
162 162
     }
163 163
 
164 164
     /**
@@ -169,9 +169,8 @@  discard block
 block discarded – undo
169 169
     {
170 170
         $text = WikiTextUtil::removeHTMLcomments($text);
171 171
         $botName = $botName ?: self::getBotName();
172
-        $denyReg = (empty($botName)) ? '' :
173
-            '|\{\{bots ?\| ?(optout|deny)\=[^\}]*' . preg_quote($botName, '#') . '[^\}]*\}\}';
174
-        return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}' . $denyReg . ')#i', $text) > 0;
172
+        $denyReg = (empty($botName)) ? '' : '|\{\{bots ?\| ?(optout|deny)\=[^\}]*'.preg_quote($botName, '#').'[^\}]*\}\}';
173
+        return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}'.$denyReg.')#i', $text) > 0;
175 174
     }
176 175
 
177 176
     /**
@@ -227,14 +226,14 @@  discard block
 block discarded – undo
227 226
 
228 227
     protected function getBotTalkPageTitle(): string
229 228
     {
230
-        return self::TALK_PAGE_PREFIX . $this::getBotName();
229
+        return self::TALK_PAGE_PREFIX.$this::getBotName();
231 230
     }
232 231
 
233 232
     protected function sendSMSandFunnyTalk(string $lastEditor, ?bool $botTalk): void
234 233
     {
235 234
         if (class_exists(SMS::class)) {
236 235
             try {
237
-                new SMS($this::getBotName() . ' {stop} by ' . $lastEditor);
236
+                new SMS($this::getBotName().' {stop} by '.$lastEditor);
238 237
             } catch (Exception $smsException) {
239 238
                 unset($smsException);
240 239
             }
Please login to merge, or discard this patch.
src/Application/Traits/WorkerCLITrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         if ($this->modeAuto) {
24 24
             return true;
25 25
         }
26
-        $ask = readline(Color::LIGHT_MAGENTA . '*** '.$question.' [y/n/auto]' . Color::NORMAL);
26
+        $ask = readline(Color::LIGHT_MAGENTA.'*** '.$question.' [y/n/auto]'.Color::NORMAL);
27 27
         if ('auto' === $ask) {
28 28
             $this->modeAuto = true;
29 29
 
Please login to merge, or discard this patch.
src/Application/Traits/WorkerAnalyzedTitlesTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
                 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
25 25
             );
26 26
         } catch (Throwable $e) {
27
-            $this->log->critical("Can't parse ARTICLE_ANALYZED_FILENAME : " . $e->getMessage());
27
+            $this->log->critical("Can't parse ARTICLE_ANALYZED_FILENAME : ".$e->getMessage());
28 28
             $analyzed = [];
29 29
         }
30 30
         $this->pastAnalyzed = ($analyzed !== false) ? $analyzed : [];
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         if (!$this->checkAlreadyAnalyzed($title)) {
36 36
             $this->pastAnalyzed[] = $title; // skip doublon title
37
-            @file_put_contents(static::ARTICLE_ANALYZED_FILENAME, $title . PHP_EOL, FILE_APPEND);
37
+            @file_put_contents(static::ARTICLE_ANALYZED_FILENAME, $title.PHP_EOL, FILE_APPEND);
38 38
         }
39 39
     }
40 40
 
Please login to merge, or discard this patch.
src/Application/Traits/BotWorkerTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
     protected function printTitle(string $title): void
53 53
     {
54 54
         echo "---------------------\n";
55
-        echo date('d-m-Y H:i:s') . ' ' . Color::BG_CYAN . "  $title " . Color::NORMAL . "\n";
55
+        echo date('d-m-Y H:i:s').' '.Color::BG_CYAN."  $title ".Color::NORMAL."\n";
56 56
     }
57 57
 
58 58
     protected function canProcessTitleArticle(string $title, ?string $text): bool
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
     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
 block discarded – undo
37 37
         // ugly dependency
38 38
         $wiki = ServiceFactory::wikiApi();
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
     /**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Application/WikiPageAction.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.