Passed
Push — master ( 2432f8...918912 )
by Dispositif
02:37
created
src/Application/OuvrageEdit/OuvrageEditSummaryTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
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
     /**
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
     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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
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
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             $this->page = $wiki->newPageGetter()->getFromTitle($title);
55 55
             $this->ns = $this->page->getPageIdentifier()->getTitle()->getNs();
56 56
         } catch (Throwable $e) {
57
-            throw new Exception('Erreur construct WikiPageAction ' . $e->getMessage() . $e->getFile() . $e->getLine(), $e->getCode(), $e);
57
+            throw new Exception('Erreur construct WikiPageAction '.$e->getMessage().$e->getFile().$e->getLine(), $e->getCode(), $e);
58 58
         }
59 59
     }
60 60
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         // "{{en}} {{zh}} {{ouvrage...}}"
74 74
         // todo test U
75 75
         if (preg_match_all(
76
-            '#(?<langTemp>{{[a-z][a-z]}} ?{{[a-z][a-z]}}) ?' . preg_quote($tplOrigin, '#') . '#i',
76
+            '#(?<langTemp>{{[a-z][a-z]}} ?{{[a-z][a-z]}}) ?'.preg_quote($tplOrigin, '#').'#i',
77 77
             $text,
78 78
             $matches
79 79
         )
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         // hack // todo: autres patterns {{en}} ?
88 88
         // OK : {{en}} \n {{ouvrage}}
89 89
         if (preg_match_all(
90
-                "#(?<langTemp>{{(?<lang>[a-z][a-z])}} *\n?)?" . preg_quote($tplOrigin, '#') . '#i',
90
+                "#(?<langTemp>{{(?<lang>[a-z][a-z])}} *\n?)?".preg_quote($tplOrigin, '#').'#i',
91 91
                 $text,
92 92
                 $matches
93 93
             ) > 0
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 // example : {{en}} {{template|lang=ru}}
103 103
                 if (!empty($lang) && self::SKIP_LANG_INDICATOR !== $lang
104 104
                     && preg_match('#langue *=#', $tplReplace)
105
-                    && !preg_match('#langue *= ?' . $lang . '#i', $tplReplace)
105
+                    && !preg_match('#langue *= ?'.$lang.'#i', $tplReplace)
106 106
                     && !preg_match('#\| ?langue *= ?\n?\|#', $tplReplace)
107 107
                 ) {
108 108
                     echo sprintf(
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                 // FIX dirty : {{en}} mais langue= avec value non définie sur new template...
126 126
                 if (!empty($lang) && preg_match('#\| ?(langue *=) ?\n? ?\|#', $tplReplace, $matchLangue) > 0) {
127 127
                     $previousTpl = $tplReplace;
128
-                    $tplReplace = str_replace($matchLangue[1], 'langue=' . $lang, $tplReplace);
128
+                    $tplReplace = str_replace($matchLangue[1], 'langue='.$lang, $tplReplace);
129 129
                     //dump('origin', $tplOrigin);
130 130
                     $text = str_replace($previousTpl, $tplReplace, $text);
131 131
                 }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                 // replace {template} and {{lang}} {template}
141 141
                 $text = str_replace($mention, $tplReplace, $text);
142 142
                 $text = str_replace(
143
-                    $matches['langTemp'][$num] . $tplReplace,
143
+                    $matches['langTemp'][$num].$tplReplace,
144 144
                     $tplReplace,
145 145
                     $text
146 146
                 ); // si 1er replace global sans
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     public function getRedirect(): ?string
211 211
     {
212 212
         if ($this->getText() && preg_match('/^#REDIRECT(?:ION)? ?\[\[([^]]+)]]/i', $this->getText(), $matches)) {
213
-            return (string)trim($matches[1]);
213
+            return (string) trim($matches[1]);
214 214
         }
215 215
 
216 216
         return null;
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             throw new Exception('That page does not exist');
260 260
         }
261 261
         $oldText = $this->getText();
262
-        $newText = $oldText . "\n" . $addText;
262
+        $newText = $oldText."\n".$addText;
263 263
 
264 264
         return $this->editPage($newText, $editInfo);
265 265
     }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
             throw new Exception('That page does not exist');
316 316
         }
317 317
         $oldText = $this->getText();
318
-        $newText = $addText . $oldText;
318
+        $newText = $addText.$oldText;
319 319
 
320 320
         return $this->editPage($newText, $editInfo);
321 321
     }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
         foreach ($refs as $ref) {
344 344
             if (preg_match(
345 345
                     '#(?<url>https?://(?:www\.)?lemonde\.fr/[^ \]]+)#i',
346
-                    (string)$ref,
346
+                    (string) $ref,
347 347
                     $matches
348 348
                 ) > 0
349 349
             ) {
Please login to merge, or discard this patch.
src/Application/CLI/Monitor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use Mediawiki\Api\MediawikiFactory;
17 17
 use Normalizer;
18 18
 
19
-include __DIR__ . '/../myBootstrap.php';
19
+include __DIR__.'/../myBootstrap.php';
20 20
 
21 21
 $process = new Monitor();
22 22
 $process->run();
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             [
98 98
                 'page' => $title ?? '',
99 99
                 'verify' => date("Y-m-d H:i:s"),
100
-                'altered' => (int)$stat,
100
+                'altered' => (int) $stat,
101 101
             ]
102 102
         );
103 103
     }
@@ -147,6 +147,6 @@  discard block
 block discarded – undo
147 147
 
148 148
         }
149 149
 
150
-        return (int)round(($count - $found) / count($data) * 100);
150
+        return (int) round(($count - $found) / count($data) * 100);
151 151
     }
152 152
 }
Please login to merge, or discard this patch.
src/Domain/ExternLink/ExternHttpErrorLogic.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 class ExternHttpErrorLogic
16 16
 {
17
-    public const LOG_REQUEST_ERROR = __DIR__ . '/../../Application/resources/external_request_error.log';
17
+    public const LOG_REQUEST_ERROR = __DIR__.'/../../Application/resources/external_request_error.log';
18 18
 
19 19
     public function __construct(
20 20
         protected DeadLinkTransformer $deadLinkTransformer,
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
             }
47 47
             return $url;
48 48
         } elseif (preg_match('#401 Unauthorized#i', $errorMessage)) {
49
-            $this->log->notice('401 Unauthorized : skip ' . $url);
49
+            $this->log->notice('401 Unauthorized : skip '.$url);
50 50
 
51 51
             return $url;
52 52
         } else {
53 53
             //  autre : ne pas générer de {lien brisé}, car peut-être 404 temporaire
54
-            $this->log->warning('erreur sur extractWebData ' . $errorMessage);
54
+            $this->log->warning('erreur sur extractWebData '.$errorMessage);
55 55
 
56 56
             //file_put_contents(self::LOG_REQUEST_ERROR, $this->domain."\n", FILE_APPEND);
57 57
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
     protected function log403(string $url): void
63 63
     {
64
-        $this->log->warning('403 Forbidden : ' . $url);
64
+        $this->log->warning('403 Forbidden : '.$url);
65 65
         //file_put_contents(self::LOG_REQUEST_ERROR, '403 Forbidden : ' . $url . "\n", FILE_APPEND);
66 66
     }
67 67
 }
68 68
\ No newline at end of file
Please login to merge, or discard this patch.
src/Domain/ExternLink/Validators/RobotNoIndexValidator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
         if (
37 37
             !empty($robots)
38 38
             && (
39
-                stripos((string)$robots, 'noindex') !== false
40
-                || stripos((string)$robots, 'none') !== false
39
+                stripos((string) $robots, 'noindex') !== false
40
+                || stripos((string) $robots, 'none') !== false
41 41
             )
42 42
         ) {
43
-            $this->log->notice('robots NOINDEX : ' . $this->url);
43
+            $this->log->notice('robots NOINDEX : '.$this->url);
44 44
 
45 45
             if (empty($this->pageData['meta']['prettyDomainName'])) {
46
-                $this->log->warning('No prettyDomainName for ' . $this->url);
46
+                $this->log->warning('No prettyDomainName for '.$this->url);
47 47
 
48 48
                 return true;
49 49
             }
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     protected function isNoIndexDomainWhitelisted(?string $prettyDomain): bool
58 58
     {
59 59
         if (in_array($prettyDomain ?? '', $this->noindexWhitelist)) {
60
-            $this->log->notice('ROBOT_NOINDEX_WHITELIST ' . $prettyDomain);
60
+            $this->log->notice('ROBOT_NOINDEX_WHITELIST '.$prettyDomain);
61 61
 
62 62
             return true;
63 63
         }
Please login to merge, or discard this patch.
src/Domain/Publisher/BnfMapper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         $this->xml = $xml;
38 38
 
39 39
         // skip multi-records
40
-        $nbResults = (int)$xml->xpath('//srw:numberOfRecords[1]')[0] ?? 0;
40
+        $nbResults = (int) $xml->xpath('//srw:numberOfRecords[1]')[0] ?? 0;
41 41
         if (1 !== $nbResults) {
42 42
             return [];
43 43
         }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         $res = [];
122 122
         foreach ($elements as $element) {
123 123
             if (isset($element) && $element instanceof SimpleXMLElement) {
124
-                $res[] = (string)$element;
124
+                $res[] = (string) $element;
125 125
             }
126 126
         }
127 127
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     {
186 186
         $raw = $this->xpath2string('//mxc:datafield[@tag="215"]/mxc:subfield[@code="a"]');
187 187
         if (!empty($raw) && preg_match('#(\d{2,}) p\.#', $raw, $matches) > 0) {
188
-            return (string)$matches[1];
188
+            return (string) $matches[1];
189 189
         }
190 190
 
191 191
         return null;
Please login to merge, or discard this patch.
src/Domain/ExternLink/ExternRefTransformer.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
     use SummaryExternTrait, PublisherLogicTrait;
36 36
 
37 37
     public const HTTP_REQUEST_LOOP_DELAY = 10;
38
-    public const SKIP_DOMAIN_FILENAME = __DIR__ . '/../resources/config_skip_domain.txt';
38
+    public const SKIP_DOMAIN_FILENAME = __DIR__.'/../resources/config_skip_domain.txt';
39 39
     public const REPLACE_404 = true;
40 40
     public const REPLACE_410 = true;
41
-    public const CONFIG_PRESSE = __DIR__ . '/../resources/config_presse.yaml';
42
-    public const CONFIG_NEWSPAPER_JSON = __DIR__ . '/../resources/data_newspapers.json';
43
-    public const CONFIG_SCIENTIFIC_JSON = __DIR__ . '/../resources/data_scientific_domain.json';
44
-    public const CONFIG_SCIENTIFIC_WIKI_JSON = __DIR__ . '/../resources/data_scientific_wiki.json';
41
+    public const CONFIG_PRESSE = __DIR__.'/../resources/config_presse.yaml';
42
+    public const CONFIG_NEWSPAPER_JSON = __DIR__.'/../resources/data_newspapers.json';
43
+    public const CONFIG_SCIENTIFIC_JSON = __DIR__.'/../resources/data_scientific_domain.json';
44
+    public const CONFIG_SCIENTIFIC_WIKI_JSON = __DIR__.'/../resources/data_scientific_wiki.json';
45 45
 
46 46
     public bool $skipSiteBlacklisted = true;
47 47
     public bool $skipRobotNoIndex = true;
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
         }
94 94
         $this->registrableDomain = $this->urlChecker->getRegistrableDomain($url); // hack
95 95
         if ($this->isSiteBlackListed()) {
96
-            $this->log->debug('Site blacklisted : ' . $this->registrableDomain);
96
+            $this->log->debug('Site blacklisted : '.$this->registrableDomain);
97 97
             return $url;
98 98
         }
99 99
 
100 100
         if (!$this->validateConfigWebDomain($this->registrableDomain)) {
101
-            $this->log->debug('Domain not validate by config : ' . $this->registrableDomain);
101
+            $this->log->debug('Domain not validate by config : '.$this->registrableDomain);
102 102
             return $url;
103 103
         }
104 104
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     protected function isSiteBlackListed(): bool
151 151
     {
152 152
         if ($this->skipSiteBlacklisted && in_array($this->registrableDomain, $this->skip_domain)) {
153
-            $this->log->notice("Skip web site " . $this->registrableDomain);
153
+            $this->log->notice("Skip web site ".$this->registrableDomain);
154 154
             return true;
155 155
         }
156 156
         return false;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $this->config[$domain] = is_array($this->config[$domain]) ? $this->config[$domain] : [];
169 169
 
170 170
         if ($this->config[$domain] === 'deactivated' || isset($this->config[$domain]['deactivated'])) {
171
-            $this->log->info("Domain " . $domain . " disabled\n");
171
+            $this->log->info("Domain ".$domain." disabled\n");
172 172
 
173 173
             return false;
174 174
         }
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
     protected function logDebugConfigWebDomain(string $domain): void
180 180
     {
181 181
         if (!isset($this->config[$domain])) {
182
-            $this->log->debug("Domain " . $domain . " non configuré");
182
+            $this->log->debug("Domain ".$domain." non configuré");
183 183
         } else {
184
-            $this->log->debug("Domain " . $domain . " configuré");
184
+            $this->log->debug("Domain ".$domain." configuré");
185 185
         }
186 186
     }
187 187
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         if ($pageData === []
207 207
             || (empty($pageData['JSON-LD']) && empty($pageData['meta']))
208 208
         ) {
209
-            $this->log->notice('No metadata : ' . $url);
209
+            $this->log->notice('No metadata : '.$url);
210 210
 
211 211
             return true;
212 212
         }
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     protected function emptyMapData(array $mapData, string $url): bool
222 222
     {
223 223
         if ($mapData === [] || empty($mapData['url']) || empty($mapData['titre'])) {
224
-            $this->log->info('Mapping incomplet : ' . $url);
224
+            $this->log->info('Mapping incomplet : '.$url);
225 225
 
226 226
             return true;
227 227
         }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
         $template = WikiTemplateFactory::create($templateName);
276 276
         $template->userSeparator = " |";
277
-        $this->summary->memo['count ' . $templateName] = 1 + ($this->summary->memo['count ' . $templateName] ?? 0);
277
+        $this->summary->memo['count '.$templateName] = 1 + ($this->summary->memo['count '.$templateName] ?? 0);
278 278
 
279 279
         return $template;
280 280
     }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
         $templateOptimized = $optimizer->getOptiTemplate();
331 331
 
332 332
         $serialized = $templateOptimized->serialize(true);
333
-        $this->log->info('Serialized 444: ' . $serialized . "\n");
333
+        $this->log->info('Serialized 444: '.$serialized."\n");
334 334
         return $serialized;
335 335
     }
336 336
 
Please login to merge, or discard this patch.
src/Infrastructure/WikiwixAdapter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $url,
53 53
             (string) $archiveData['longformurl'],
54 54
             $archiveData['timestamp']
55
-                ? DateTimeImmutable::createFromFormat('U', (string)$archiveData['timestamp'])
55
+                ? DateTimeImmutable::createFromFormat('U', (string) $archiveData['timestamp'])
56 56
                 : null
57 57
         ); // todo factory ?
58 58
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     {
62 62
         $response = $this->externHttpClient->getClient()->request(
63 63
             'GET',
64
-            self::API_URL . urlencode($url)
64
+            self::API_URL.urlencode($url)
65 65
         );
66 66
 
67 67
         if (!$response instanceof ResponseInterface || $response->getStatusCode() !== 200) {
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
         $data = json_decode($jsonString, true) ?? [];
76 76
 
77 77
         // check wikiwix archive status
78
-        if (empty($data['status']) || (int)$data['status'] !== 200) {
79
-            $this->log->debug('WikiwixAdapter incorrect response: ' . $jsonString);
78
+        if (empty($data['status']) || (int) $data['status'] !== 200) {
79
+            $this->log->debug('WikiwixAdapter incorrect response: '.$jsonString);
80 80
 
81 81
             return [];
82 82
         }
Please login to merge, or discard this patch.