@@ -48,16 +48,16 @@ discard block |
||
48 | 48 | return new WebarchiveDTO( |
49 | 49 | self::ARCHIVER_NAME, |
50 | 50 | $url, |
51 | - (string)$archiveData['longformurl'], |
|
51 | + (string) $archiveData['longformurl'], |
|
52 | 52 | $archiveData['timestamp'] |
53 | - ? DateTimeImmutable::createFromFormat('U', (string)$archiveData['timestamp']) |
|
53 | + ? DateTimeImmutable::createFromFormat('U', (string) $archiveData['timestamp']) |
|
54 | 54 | : null |
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |
58 | 58 | protected function requestWikiwixApi(string $url): array |
59 | 59 | { |
60 | - $response = $this->externHttpClient->get(self::API_URL . urlencode($url), [ |
|
60 | + $response = $this->externHttpClient->get(self::API_URL.urlencode($url), [ |
|
61 | 61 | 'timeout' => 20, |
62 | 62 | 'allow_redirects' => true, |
63 | 63 | 'headers' => ['User-Agent' => getenv('USER_AGENT')], |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | $data = json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR) ?? []; |
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 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | class LocationHandler extends AbstractOuvrageHandler |
20 | 20 | { |
21 | - final public const TRANSLATE_CITY_FR = __DIR__ . '/../../resources/traduction_ville.csv'; |
|
21 | + final public const TRANSLATE_CITY_FR = __DIR__.'/../../resources/traduction_ville.csv'; |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @var PageListInterface |
@@ -35,7 +35,7 @@ |
||
35 | 35 | { |
36 | 36 | final public const CONVERT_GOOGLEBOOK_TEMPLATE = false; // change OuvrageOptimizeTest !! |
37 | 37 | final public const WIKI_LANGUAGE = 'fr'; |
38 | - final public const PUBLISHER_FRWIKI_FILENAME = __DIR__ . '/../resources/data_editors_wiki.json'; |
|
38 | + final public const PUBLISHER_FRWIKI_FILENAME = __DIR__.'/../resources/data_editors_wiki.json'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var OptiStatus |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | return new WebarchiveDTO( |
46 | 46 | self::ARCHIVER_NAME, |
47 | 47 | $url, |
48 | - (string)$archiveData['url'], |
|
48 | + (string) $archiveData['url'], |
|
49 | 49 | $iaDateOrNull |
50 | 50 | ); |
51 | 51 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | protected function requestInternetArchiveApi(string $url, ?DateTimeInterface $date = null): array |
54 | 54 | { |
55 | 55 | $response = $this->client->get( |
56 | - 'https://archive.org/wayback/available?timestamp=' . self::SEARCH_CLOSEST_TIMESTAMP . '&url=' . urlencode($url), |
|
56 | + 'https://archive.org/wayback/available?timestamp='.self::SEARCH_CLOSEST_TIMESTAMP.'&url='.urlencode($url), |
|
57 | 57 | [ |
58 | 58 | 'timeout' => 20, |
59 | 59 | 'allow_redirects' => true, |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | } |
104 | 104 | $iaDateTime = new DateTime(); |
105 | 105 | $iaDateTime->setDate( |
106 | - (int)substr($iaTimestamp, 0, 4), |
|
107 | - (int)substr($iaTimestamp, 4, 2), |
|
108 | - (int)substr($iaTimestamp, 6, 2) |
|
106 | + (int) substr($iaTimestamp, 0, 4), |
|
107 | + (int) substr($iaTimestamp, 4, 2), |
|
108 | + (int) substr($iaTimestamp, 6, 2) |
|
109 | 109 | ); |
110 | 110 | $iaDateTime->setTime( |
111 | - (int)substr($iaTimestamp, 8, 2), |
|
112 | - (int)substr($iaTimestamp, 10, 2), |
|
113 | - (int)substr($iaTimestamp, 12, 2) |
|
111 | + (int) substr($iaTimestamp, 8, 2), |
|
112 | + (int) substr($iaTimestamp, 10, 2), |
|
113 | + (int) substr($iaTimestamp, 12, 2) |
|
114 | 114 | ); |
115 | 115 | |
116 | 116 | return $iaDateTime; |
@@ -24,7 +24,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -56,10 +56,10 @@ |
||
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(); |
@@ -37,7 +37,7 @@ discard block |
||
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 |
||
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 |
@@ -18,7 +18,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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); |
@@ -31,7 +31,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |