Passed
Push — master ( ac79bd...625dce )
by Dispositif
13:46 queued 16s
created
src/Application/CLI/wikiwixListProcess.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * Traitement synchrone des URL brutes http:// transformée en {lien web} ou {article}
26 26
  */
27 27
 
28
-include __DIR__ . '/../myBootstrap.php';
28
+include __DIR__.'/../myBootstrap.php';
29 29
 
30 30
 echo "WikiwixListProcess\n";
31 31
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 $titles = [];
63 63
 foreach ($rawtitles as $rawtitle) {
64 64
     // $convTitle =  @iconv('UTF-8', 'latin1', $rawtitle);
65
-    $convTitle =  TextUtil::fixWrongUTF8Encoding($rawtitle);
65
+    $convTitle = TextUtil::fixWrongUTF8Encoding($rawtitle);
66 66
     if ($convTitle !== false && trim($convTitle) !== '') {
67 67
         $titles[] = $convTitle;
68 68
     }
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 echo sprintf("> %d converted titles\n", count($titles));
72 72
 
73 73
 // filtering
74
-echo '> before filtering: ' . count($titles) . " articles.\n";
75
-$edited = file(__DIR__ . '/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
74
+echo '> before filtering: '.count($titles)." articles.\n";
75
+$edited = file(__DIR__.'/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
76 76
 $titles = array_diff($titles, $edited);
77 77
 $list = new PageList($titles);
78 78
 // end HACK list manuelle
79 79
 
80 80
 
81
-echo ">" . $list->count() . " dans liste\n";
81
+echo ">".$list->count()." dans liste\n";
82 82
 if ($list->count() === 0) {
83 83
     echo "END of process: EMPTY ARTICLE LIST\n";
84 84
     sleep(120);
Please login to merge, or discard this patch.
src/Application/Utils/HttpUtil.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@
 block discarded – undo
42 42
 
43 43
         $charset = self::extractCharset($html) ?? 'WINDOWS-1252';
44 44
         if (empty($charset)) {
45
-            throw new DomainException('normalized html error and no charset found : ' . $url);
45
+            throw new DomainException('normalized html error and no charset found : '.$url);
46 46
         }
47 47
         try {
48 48
             // PHP Notice:  iconv(): Detected an illegal character in input string
49 49
             $html2 = @iconv($charset, 'UTF-8//TRANSLIT', $html);
50 50
             if (false === $html2) {
51
-                throw new DomainException("error iconv : $charset to UTF-8 on " . $url);
51
+                throw new DomainException("error iconv : $charset to UTF-8 on ".$url);
52 52
             }
53 53
             $html2 = Normalizer::normalize($html2);
54 54
             if (!is_string($html2)) {
55
-                throw new DomainException("error normalizer : $charset to UTF-8 on " . $url);
55
+                throw new DomainException("error normalizer : $charset to UTF-8 on ".$url);
56 56
             }
57 57
         } catch (Throwable $e) {
58
-            throw new DomainException("error converting : $charset to UTF-8 on " . $url, $e->getCode(), $e);
58
+            throw new DomainException("error converting : $charset to UTF-8 on ".$url, $e->getCode(), $e);
59 59
         }
60 60
 
61 61
         return $html2;
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 = 2; //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/Application/CLI/avancement2.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
 use App\Infrastructure\ServiceFactory;
14 14
 use Mediawiki\DataModel\EditInfo;
15 15
 
16
-include __DIR__ . '/../myBootstrap.php'; //myBootstrap.php';
16
+include __DIR__.'/../myBootstrap.php'; //myBootstrap.php';
17 17
 
18 18
 $title = 'Utilisateur:ZiziBot/task';
19 19
 $summary = 'bot : ⚙ mise à jour';
Please login to merge, or discard this patch.
src/Application/CLI/lastExternRefProcess.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,10 +86,10 @@
 block discarded – undo
86 86
 // filter titles already in edited.txt
87 87
 unset($list);
88 88
 //echo count($titles)." titles\n";
89
-$edited = file(__DIR__ . '/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
89
+$edited = file(__DIR__.'/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
90 90
 $filtered = array_diff($titles, $edited);
91 91
 $list = new PageList($filtered);
92
-echo ">" . $list->count() . " dans liste\n";
92
+echo ">".$list->count()." dans liste\n";
93 93
 
94 94
 
95 95
 $httpClient = ServiceFactory::getHttpClient();
Please login to merge, or discard this patch.
src/Domain/WikiOptimizer/Handlers/LocationHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
  */
22 22
 class LocationHandler extends AbstractOuvrageHandler
23 23
 {
24
-    final public const TRANSLATE_CITY_FR = __DIR__ . '/../../resources/traduction_ville.csv';
24
+    final public const TRANSLATE_CITY_FR = __DIR__.'/../../resources/traduction_ville.csv';
25 25
 
26 26
     public function __construct(OuvrageTemplate $ouvrage, OptiStatus $optiStatus, protected PageListInterface $pageListManager)
27 27
     {
Please login to merge, or discard this patch.
src/Application/WikiBotConfig.php 1 patch
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 class WikiBotConfig
32 32
 {
33 33
     public const VERSION = '2.2';
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'];
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @var DateTimeImmutable
58 58
      */
59 59
     protected $lastCheckStopDate;
60
-    protected SMSInterface|null $SMSClient;
60
+    protected SMSInterface | null $SMSClient;
61 61
     protected $mediawikiFactory;
62 62
     protected ?string $gitCommitHash = null;
63 63
 
@@ -91,9 +91,8 @@  discard block
 block discarded – undo
91 91
     {
92 92
         $text = WikiTextUtil::removeHTMLcomments($text);
93 93
         $botName = $botName ?: self::getBotName();
94
-        $denyReg = (empty($botName)) ? '' :
95
-            '|\{\{bots ?\| ?(optout|deny)\=[^\}]*' . preg_quote($botName, '#') . '[^\}]*\}\}';
96
-        return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}' . $denyReg . ')#i', $text) > 0;
94
+        $denyReg = (empty($botName)) ? '' : '|\{\{bots ?\| ?(optout|deny)\=[^\}]*'.preg_quote($botName, '#').'[^\}]*\}\}';
95
+        return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}'.$denyReg.')#i', $text) > 0;
97 96
     }
98 97
 
99 98
     /**
@@ -128,12 +127,12 @@  discard block
 block discarded – undo
128 127
         if ($this->gitCommitHash) {
129 128
             return $this->gitCommitHash;
130 129
         }
131
-        $path = __DIR__ . '/../../.git/';
130
+        $path = __DIR__.'/../../.git/';
132 131
         if (!file_exists($path)) {
133 132
             return null;
134 133
         }
135
-        $head = trim(substr(file_get_contents($path . 'HEAD'), 4));
136
-        $hash = trim(file_get_contents(sprintf($path . $head)));
134
+        $head = trim(substr(file_get_contents($path.'HEAD'), 4));
135
+        $hash = trim(file_get_contents(sprintf($path.$head)));
137 136
         $this->gitCommitHash = $hash; // cached
138 137
 
139 138
         return $hash;
@@ -204,7 +203,7 @@  discard block
 block discarded – undo
204 203
 
205 204
     protected function getBotTalkPageTitle(): string
206 205
     {
207
-        return self::TALK_PAGE_PREFIX . $this::getBotName();
206
+        return self::TALK_PAGE_PREFIX.$this::getBotName();
208 207
     }
209 208
 
210 209
     protected function sendSMSandFunnyTalk(string $lastEditor, ?bool $botTalk): void
@@ -304,8 +303,8 @@  discard block
 block discarded – undo
304 303
      */
305 304
     public function minutesSinceLastEdit(string $title): int
306 305
     {
307
-        $time = $this->getTimestamp($title);  // 2011-09-02T16:31:13Z
306
+        $time = $this->getTimestamp($title); // 2011-09-02T16:31:13Z
308 307
 
309
-        return (int)round((time() - strtotime($time)) / 60);
308
+        return (int) round((time() - strtotime($time)) / 60);
310 309
     }
311 310
 }
Please login to merge, or discard this patch.
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 CITATION_LIMIT = 150;
48 48
     final public const DELAY_BOTFLAG_SECONDS = 120;
49 49
     final public const DELAY_NO_BOTFLAG_SECONDS = 120;
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
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                 $this->log->alert("*** Invalid CSRF token \n");
264 264
                 throw new Exception('Invalid CSRF token', $e->getCode(), $e);
265 265
             } else {
266
-                $this->log->warning('Exception in editPage() ' . $e->getMessage());
266
+                $this->log->warning('Exception in editPage() '.$e->getMessage());
267 267
                 sleep(10);
268 268
 
269 269
                 return false;
@@ -285,16 +285,16 @@  discard block
 block discarded – undo
285 285
                 $this->sendOuvrageErrorsOnTalkPage($pageOuvrageCollection, $this->log);
286 286
             }
287 287
         } catch (Throwable $e) {
288
-            $this->log->warning('Exception in editPage() ' . $e->getMessage());
288
+            $this->log->warning('Exception in editPage() '.$e->getMessage());
289 289
             unset($e);
290 290
         }
291 291
 
292 292
         if (!$this->pageWorkStatus->botFlag) {
293
-            $this->log->debug("sleep " . self::DELAY_NO_BOTFLAG_SECONDS);
293
+            $this->log->debug("sleep ".self::DELAY_NO_BOTFLAG_SECONDS);
294 294
             sleep(self::DELAY_NO_BOTFLAG_SECONDS);
295 295
         }
296 296
         if ($this->pageWorkStatus->botFlag) {
297
-            $this->log->debug("sleep " . self::DELAY_BOTFLAG_SECONDS);
297
+            $this->log->debug("sleep ".self::DELAY_BOTFLAG_SECONDS);
298 298
             sleep(self::DELAY_BOTFLAG_SECONDS);
299 299
         }
300 300
     }
Please login to merge, or discard this patch.