Passed
Push — master ( 9f9e2a...75e8d8 )
by Dispositif
02:34
created
src/Application/AbstractRefBotWorker.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function hasWarning(): bool
26 26
     {
27
-        return (bool)$this->warning;
27
+        return (bool) $this->warning;
28 28
     }
29 29
 
30 30
     /**
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $refs = array_slice($refs, 0, self::MAX_REFS_PROCESSED_IN_ARTICLE, true);
56 56
 
57 57
         foreach ($refs as $ref) {
58
-            $refContent = WikiTextUtil::stripFinalPoint(trim((string)$ref[1]));
58
+            $refContent = WikiTextUtil::stripFinalPoint(trim((string) $ref[1]));
59 59
 
60 60
             $newRefContent = $this->processRefContent($refContent);
61 61
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
     protected function replaceRefInText(array $ref, string $replace, string $text)
71 71
     {
72 72
         // Pas de changement
73
-        if (WikiTextUtil::stripFinalPoint(trim($replace)) === WikiTextUtil::stripFinalPoint(trim((string)$ref[1]))) {
73
+        if (WikiTextUtil::stripFinalPoint(trim($replace)) === WikiTextUtil::stripFinalPoint(trim((string) $ref[1]))) {
74 74
             return $text;
75 75
         }
76 76
         $replace = $this->addFinalPeriod($ref[0], $replace);
77
-        $result = str_replace($ref[1], $replace, (string)$ref[0]);
77
+        $result = str_replace($ref[1], $replace, (string) $ref[0]);
78 78
         $this->printDiff($ref[0], $result);
79 79
 
80 80
         return str_replace($ref[0], $result, $text);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     protected function addFinalPeriod($ref, string $replace): string
87 87
     {
88
-        if (preg_match('#</ref>#', (string)$ref)) {
88
+        if (preg_match('#</ref>#', (string) $ref)) {
89 89
             $replace .= '.';
90 90
         }
91 91
         return $replace;
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
@@ -56,10 +56,10 @@
 block discarded – undo
56 56
 $titles = $list->getPageTitles();
57 57
 unset($list);
58 58
 //echo count($titles)." titles\n";
59
-$edited = file(__DIR__ . '/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
59
+$edited = file(__DIR__.'/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
60 60
 $filtered = array_diff($titles, $edited);
61 61
 $list = new PageList($filtered);
62
-echo ">" . $list->count() . " dans liste\n";
62
+echo ">".$list->count()." dans liste\n";
63 63
 
64 64
 
65 65
 $httpClient = ServiceFactory::getHttpClient();
Please login to merge, or discard this patch.
src/Application/CLI/testExternLink.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
 
38 38
 // todo command --tor --wikiwix --internetarchive
39 39
 $torEnabled = false;
40
-echo "TOR enabled : ".($torEnabled ? "oui" : "non"). "\n";
40
+echo "TOR enabled : ".($torEnabled ? "oui" : "non")."\n";
41 41
 
42 42
 $client = ServiceFactory::getHttpClient();
43 43
 $wikiwix = new WikiwixAdapter($client, $logger);
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
     // Attention : pas de post-processing (sanitize title, etc.)
57 57
     $result = $trans->process($url, $summary);
58 58
 } catch (Exception $e) {
59
-    $result = "EXCEPTION ". $e->getMessage().$e->getFile().$e->getLine();
59
+    $result = "EXCEPTION ".$e->getMessage().$e->getFile().$e->getLine();
60 60
 }
61 61
 
62
-echo '>>> '. $result."\n";
62
+echo '>>> '.$result."\n";
63 63
 
64 64
 
65 65
 
Please login to merge, or discard this patch.
src/Domain/ExternLink/ExternHttpErrorLogic.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class ExternHttpErrorLogic
20 20
 {
21
-    final public const LOG_REQUEST_ERROR = __DIR__ . '/../../Application/resources/external_request_error.log';
21
+    final public const LOG_REQUEST_ERROR = __DIR__.'/../../Application/resources/external_request_error.log';
22 22
     protected const LOOSE = true;
23 23
 
24 24
     public function __construct(
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
             return $url;
41 41
         }
42 42
         if (preg_match('#400 Bad Request#i', $errorMessage)) {
43
-            $this->log->warning('400 Bad Request : ' . $url, ['stats' => 'externHttpErrorLogic.400']);
43
+            $this->log->warning('400 Bad Request : '.$url, ['stats' => 'externHttpErrorLogic.400']);
44 44
 
45 45
             return $url;
46 46
         }
47 47
         if (preg_match('#(403 Forbidden|403 Access Forbidden)#i', $errorMessage)) {
48
-            $this->log->warning('403 Forbidden : ' . $url, ['stats' => 'externHttpErrorLogic.403']);
48
+            $this->log->warning('403 Forbidden : '.$url, ['stats' => 'externHttpErrorLogic.403']);
49 49
             // TODO return blankLienWeb without consulté le=...
50 50
 
51 51
             return $url;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             return $url;
60 60
         }
61 61
         if (preg_match('#401 (Unauthorized|Authorization Required)#i', $errorMessage)) {
62
-            $this->log->notice('401 Unauthorized : skip ' . $url, ['stats' => 'externHttpErrorLogic.401']);
62
+            $this->log->notice('401 Unauthorized : skip '.$url, ['stats' => 'externHttpErrorLogic.401']);
63 63
 
64 64
             return $url;
65 65
         }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         // "cURL error 28: Connection timed out after 20005 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
113 113
         //"cURL error 28: Connection timed out after 20005 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
114 114
         $this->log->notice(
115
-            'erreur non gérée sur extractWebData: "' . $errorMessage . "\" URL: " . $url,
115
+            'erreur non gérée sur extractWebData: "'.$errorMessage."\" URL: ".$url,
116 116
             ['stats' => 'externHttpErrorLogic.defaultSkip']
117 117
         );
118 118
         //file_put_contents(self::LOG_REQUEST_ERROR, $this->domain."\n", FILE_APPEND);
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.1';
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'];
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      * @var DateTimeImmutable
57 57
      */
58 58
     protected $lastCheckStopDate;
59
-    protected SMSInterface|null $SMSClient;
59
+    protected SMSInterface | null $SMSClient;
60 60
     protected $mediawikiFactory;
61 61
     protected ?string $gitCommitHash = null;
62 62
 
@@ -90,9 +90,8 @@  discard block
 block discarded – undo
90 90
     {
91 91
         $text = WikiTextUtil::removeHTMLcomments($text);
92 92
         $botName = $botName ?: self::getBotName();
93
-        $denyReg = (empty($botName)) ? '' :
94
-            '|\{\{bots ?\| ?(optout|deny)\=[^\}]*' . preg_quote($botName, '#') . '[^\}]*\}\}';
95
-        return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}' . $denyReg . ')#i', $text) > 0;
93
+        $denyReg = (empty($botName)) ? '' : '|\{\{bots ?\| ?(optout|deny)\=[^\}]*'.preg_quote($botName, '#').'[^\}]*\}\}';
94
+        return preg_match('#({{nobots}}|{{bots ?\| ?(optout|deny) ?= ?all ?}}'.$denyReg.')#i', $text) > 0;
96 95
     }
97 96
 
98 97
     /**
@@ -127,12 +126,12 @@  discard block
 block discarded – undo
127 126
         if ($this->gitCommitHash) {
128 127
             return $this->gitCommitHash;
129 128
         }
130
-        $path = __DIR__ . '/../../.git/';
129
+        $path = __DIR__.'/../../.git/';
131 130
         if (!file_exists($path)) {
132 131
             return null;
133 132
         }
134
-        $head = trim(substr(file_get_contents($path . 'HEAD'), 4));
135
-        $hash = trim(file_get_contents(sprintf($path . $head)));
133
+        $head = trim(substr(file_get_contents($path.'HEAD'), 4));
134
+        $hash = trim(file_get_contents(sprintf($path.$head)));
136 135
         $this->gitCommitHash = $hash; // cached
137 136
 
138 137
         return $hash;
@@ -190,7 +189,7 @@  discard block
 block discarded – undo
190 189
 
191 190
     protected function getBotTalkPageTitle(): string
192 191
     {
193
-        return self::TALK_PAGE_PREFIX . $this::getBotName();
192
+        return self::TALK_PAGE_PREFIX.$this::getBotName();
194 193
     }
195 194
 
196 195
     protected function sendSMSandFunnyTalk(string $lastEditor, ?bool $botTalk): void
@@ -290,8 +289,8 @@  discard block
 block discarded – undo
290 289
      */
291 290
     public function minutesSinceLastEdit(string $title): int
292 291
     {
293
-        $time = $this->getTimestamp($title);  // 2011-09-02T16:31:13Z
292
+        $time = $this->getTimestamp($title); // 2011-09-02T16:31:13Z
294 293
 
295
-        return (int)round((time() - strtotime($time)) / 60);
294
+        return (int) round((time() - strtotime($time)) / 60);
296 295
     }
297 296
 }
Please login to merge, or discard this patch.
src/Infrastructure/Monitor/StatsSqlite3.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class StatsSqlite3 implements StatsInterface
20 20
 {
21
-    protected const DEFAULT_FILEPATH = __DIR__ . '/../../../log/stats.db';
21
+    protected const DEFAULT_FILEPATH = __DIR__.'/../../../log/stats.db';
22 22
     protected const MAX_TAG_LENGTH = 100;
23 23
 
24 24
     protected SQLite3 $db;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         // `num` default value is 1 so insert is enough to set num=1
76 76
         try {
77 77
             return $this->sqliteExecWriteOrWait(
78
-                'INSERT INTO ' . $table . ' (tag) VALUES("' . $tag . '") ON CONFLICT(tag) DO UPDATE SET num=num+1'
78
+                'INSERT INTO '.$table.' (tag) VALUES("'.$tag.'") ON CONFLICT(tag) DO UPDATE SET num=num+1'
79 79
             );
80 80
         } catch (Exception $e) {
81 81
             return false;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         $tag = $this->formatTag($tag);
108 108
         try {
109 109
             return $this->sqliteExecWriteOrWait(
110
-                'INSERT OR REPLACE INTO tagnum (tag,num) VALUES("' . $tag . '", ' . $num . ')'
110
+                'INSERT OR REPLACE INTO tagnum (tag,num) VALUES("'.$tag.'", '.$num.')'
111 111
             );
112 112
         } catch (Exception $e) {
113 113
             return false;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $tag = $this->formatTag($tag);
120 120
         try {
121 121
             return $this->sqliteExecWriteOrWait(
122
-                'INSERT INTO tagnum (tag) VALUES("' . $tag . '") ON CONFLICT(tag) DO UPDATE SET num=num-1'
122
+                'INSERT INTO tagnum (tag) VALUES("'.$tag.'") ON CONFLICT(tag) DO UPDATE SET num=num-1'
123 123
             );
124 124
         } catch (Exception $e) {
125 125
             return false;
Please login to merge, or discard this patch.
src/Infrastructure/Monitor/ConsoleLogger.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 {
21 21
     //    use LoggerTrait;
22 22
 
23
-    protected const CRITICAL_LOG_PATH = __DIR__ . '/../../../log/critical.log';
23
+    protected const CRITICAL_LOG_PATH = __DIR__.'/../../../log/critical.log';
24 24
     public bool $verbose = false;
25 25
     public bool $debug = false;
26 26
     public bool $colorMode = false;
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function __call(string $method, array $args): void
38 38
     {
39
-        $this->notice('Call to undefined method ConsoleLogger:' . $method . '()');
39
+        $this->notice('Call to undefined method ConsoleLogger:'.$method.'()');
40 40
     }
41 41
 
42 42
     /**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             case 'emergency':
63 63
             case 'alert':
64 64
             case 'critical':
65
-                $this->echoColor("[$level] " . $date . ' : ' . $message . "\n", Color::BG_RED . Color::WHITE);
65
+                $this->echoColor("[$level] ".$date.' : '.$message."\n", Color::BG_RED.Color::WHITE);
66 66
                 if ($context !== []) {
67 67
                     dump($context);
68 68
                 }
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
                 break;
71 71
             case 'error':
72 72
             case 'warning':
73
-                $this->echoColor("[$level] " . $date . ' : ' . $message . "\n", Color::BG_YELLOW . Color::BLACK);
73
+                $this->echoColor("[$level] ".$date.' : '.$message."\n", Color::BG_YELLOW.Color::BLACK);
74 74
                 if ($context !== []) {
75 75
                     dump($context);
76 76
                 }
77 77
                 break;
78 78
             case 'notice':
79
-                $this->echoColor("[$level] " . $message . "\n");
79
+                $this->echoColor("[$level] ".$message."\n");
80 80
                 if ($context !== []) {
81 81
                     dump($context);
82 82
                 }
83 83
                 break;
84 84
             case 'info':
85 85
                 if ($this->verbose || $this->debug) {
86
-                    $this->echoColor("[$level] " . $message . "\n", Color::GRAY);
86
+                    $this->echoColor("[$level] ".$message."\n", Color::GRAY);
87 87
                     if ($context !== []) {
88 88
                         dump($context);
89 89
                     }
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
                 break;
92 92
             case 'debug':
93 93
                 if ($this->debug) {
94
-                    $this->echoColor("[$level] " . $message . "\n", Color::GRAY);
94
+                    $this->echoColor("[$level] ".$message."\n", Color::GRAY);
95 95
                     if ($context !== []) {
96 96
                         dump($context);
97 97
                     }
98 98
                 }
99 99
                 break;
100 100
             case 'echo':
101
-                $this->echoColor($message . "\n");
101
+                $this->echoColor($message."\n");
102 102
                 break;
103 103
         }
104 104
     }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     private function echoColor(string $text, ?string $color = null): void
122 122
     {
123 123
         if ($this->colorMode && !empty($color)) {
124
-            echo $color . $text . Color::NORMAL;
124
+            echo $color.$text.Color::NORMAL;
125 125
 
126 126
             return;
127 127
         }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     {
133 133
         file_put_contents(
134 134
             self::CRITICAL_LOG_PATH,
135
-            date('d-m-Y H:i:s') . " : $level : " . $message . PHP_EOL,
135
+            date('d-m-Y H:i:s')." : $level : ".$message.PHP_EOL,
136 136
             FILE_APPEND
137 137
         );
138 138
     }
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 = true;
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
     /**
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
      */
104 104
     final public function run(): void
105 105
     {
106
-        $this->log->notice('*** New BotTaskWorker: ' . $this->defaultTaskname, ['stats' => 'bottaskworker.instance']);
106
+        $this->log->notice('*** New BotTaskWorker: '.$this->defaultTaskname, ['stats' => 'bottaskworker.instance']);
107 107
         $this->log->notice(sprintf(
108 108
             '*** Bot: %s - commit: %s',
109 109
             $this->bot::getBotName(),
110 110
             $this->bot->getCurrentGitCommitHash() ?? '??'
111 111
         ));
112
-        $this->log->notice('*** Stats: ' . $this->log->stats::class);
112
+        $this->log->notice('*** Stats: '.$this->log->stats::class);
113 113
 
114 114
         foreach ($this->getTitles() as $title) {
115 115
             try {
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
         }
219 219
 
220 220
         $this->log->notice($result ? '>> OK' : '>>  NOCHANGE');
221
-        $this->log->debug("Sleep " . static::SLEEP_AFTER_EDITION);
221
+        $this->log->debug("Sleep ".static::SLEEP_AFTER_EDITION);
222 222
         sleep(static::SLEEP_AFTER_EDITION);
223 223
     }
224 224
 
Please login to merge, or discard this patch.
src/Domain/ExternLink/CheckURL.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
         $this->url = $url;
50 50
         $this->registrableDomain = null;
51 51
         if (!HttpUtil::isHttpURL($url)) {
52
-            $this->log->debug('Skip : not Http URL : ' . $url, ['stats' => 'externref.skip.notRawURL']);
52
+            $this->log->debug('Skip : not Http URL : '.$url, ['stats' => 'externref.skip.notRawURL']);
53 53
             return false;
54 54
         }
55 55
 
56 56
         if ($this->hasForbiddenFilenameExtension()) {
57
-            $this->log->debug('Skip : ForbiddenFilenameExtension : ' . $url, ['stats' => 'externref.skip.forbiddenFilenameExtension']);
57
+            $this->log->debug('Skip : ForbiddenFilenameExtension : '.$url, ['stats' => 'externref.skip.forbiddenFilenameExtension']);
58 58
             return false;
59 59
         }
60 60
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     protected function hasForbiddenFilenameExtension(): bool
72 72
     {
73
-        return (bool)preg_match(
73
+        return (bool) preg_match(
74 74
             '#\.(pdf|jpg|jpeg|gif|png|webp|xls|xlsx|xlr|xml|xlt|txt|csv|js|docx|exe|gz|zip|ini|movie|mp3|mp4|ogg|raw|rss|tar|tgz|wma)$#i',
75 75
             $this->url
76 76
         );
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         try {
82 82
             $this->registrableDomain = $this->internetDomainParser->getRegistrableDomainFromURL($this->url);
83 83
         } catch (Exception) {
84
-            $this->log->warning('Skip : registrableDomain not a valid URL : ' . $this->url,
84
+            $this->log->warning('Skip : registrableDomain not a valid URL : '.$this->url,
85 85
                 ['stats' => 'externref.skip.URLAuthorized.exception2']
86 86
             );
87 87
             return null;
Please login to merge, or discard this patch.