Skip to content

Commit 27d2168

Browse files
committed
Change cs rules
1 parent 523a2e9 commit 27d2168

File tree

174 files changed

+1665
-1664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+1665
-1664
lines changed

‎.php-cs-fixer.dist.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public function getRules(): array
88
'array_indentation' => true,
99
'ternary_to_null_coalescing' => true,
1010
'assign_null_coalescing_to_coalesce_equal' => true,
11+
"native_function_invocation" => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
1112
]);
1213
}
1314
};

‎src/API.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public static function startAndLoopMulti(array $instances, array|string $eventHa
400400
if (\is_string($eventHandler)) {
401401
Assert::classExists($eventHandler);
402402
$eventHandler::cachePlugins($eventHandler);
403-
$eventHandler = \array_fill_keys(\array_keys($instances), $eventHandler);
403+
$eventHandler = array_fill_keys(array_keys($instances), $eventHandler);
404404
} else {
405405
Assert::notEmpty($eventHandler);
406406
Assert::allClassExists($eventHandler);
@@ -410,8 +410,8 @@ public static function startAndLoopMulti(array $instances, array|string $eventHa
410410
}
411411

412412
$errors = [];
413-
$started = \array_fill_keys(\array_keys($instances), false);
414-
$instanceOne = \array_values($instances)[0];
413+
$started = array_fill_keys(array_keys($instances), false);
414+
$instanceOne = array_values($instances)[0];
415415

416416
$prev = EventLoop::getErrorHandler();
417417
EventLoop::setErrorHandler(
@@ -422,13 +422,13 @@ public static function startAndLoopMulti(array $instances, array|string $eventHa
422422
if ($e instanceof SecurityException || $e instanceof SignalException) {
423423
throw $e;
424424
}
425-
if (\str_starts_with($e->getMessage(), 'Could not connect to DC ')) {
425+
if (str_starts_with($e->getMessage(), 'Could not connect to DC ')) {
426426
throw $e;
427427
}
428-
$t = \time();
428+
$t = time();
429429
$errors = [$t => $errors[$t] ?? 0];
430430
$errors[$t]++;
431-
if ($errors[$t] > 10 && \array_sum($started) !== \count($eventHandler)) {
431+
if ($errors[$t] > 10 && array_sum($started) !== \count($eventHandler)) {
432432
$instanceOne->wrapper->logger('More than 10 errors in a second and not inited, exiting!', Logger::FATAL_ERROR);
433433
return;
434434
}

‎src/AbstractAPI.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ protected function startAndLoopInternal(string $eventHandler): void
4646
if ($e instanceof SecurityException || $e instanceof SignalException) {
4747
throw $e;
4848
}
49-
if (\str_starts_with($e->getMessage(), 'Could not connect to DC ')) {
49+
if (str_starts_with($e->getMessage(), 'Could not connect to DC ')) {
5050
throw $e;
5151
}
52-
$t = \time();
52+
$t = time();
5353
$errors = [$t => $errors[$t] ?? 0];
5454
$errors[$t]++;
5555
if ($errors[$t] > 10 && (!$this->wrapper->getAPI()->isInited() || !$started)) {

‎src/AnnotationsBuilder.php

+98-98
Large diffs are not rendered by default.

‎src/ApiWrappers/Start.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private function APIStart(Settings $settings)
5454
$app = [];
5555
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
5656
$stdout = getStdout();
57-
$stdout->write(\sprintf(Lang::$current_lang['apiChooseManualAutoTip'], 'https://docs.madelineproto.xyz/docs/SETTINGS.html').PHP_EOL);
57+
$stdout->write(sprintf(Lang::$current_lang['apiChooseManualAutoTip'], 'https://docs.madelineproto.xyz/docs/SETTINGS.html').PHP_EOL);
5858
$stdout->write('1) '.Lang::$current_lang['apiManualInstructions0'].PHP_EOL);
5959
$stdout->write('2) '.Lang::$current_lang['apiManualInstructions1'].PHP_EOL);
6060
$stdout->write('3) ');
@@ -84,28 +84,28 @@ private function APIStart(Settings $settings)
8484
*/
8585
private function webAPIEcho(Settings $settings, string $message = ''): void
8686
{
87-
$message = \htmlentities($message);
87+
$message = htmlentities($message);
8888
$title = MTProto::getWebWarnings();
89-
$title .= \htmlentities(Lang::$current_lang['apiManualWeb']);
89+
$title .= htmlentities(Lang::$current_lang['apiManualWeb']);
9090
$title .= "<br>";
91-
$title .= \sprintf(Lang::$current_lang['apiChooseManualAutoTipWeb'], 'https://docs.madelineproto.xyz/docs/SETTINGS.html');
91+
$title .= sprintf(Lang::$current_lang['apiChooseManualAutoTipWeb'], 'https://docs.madelineproto.xyz/docs/SETTINGS.html');
9292
$title .= "<br><b>$message</b>";
9393
$title .= '<ol>';
94-
$title .= '<li>'.\str_replace('https://my.telegram.org', '<a href="https://my.telegram.org" target="_blank">https://my.telegram.org</a>', \htmlentities(Lang::$current_lang['apiManualInstructions0'])).'</li>';
95-
$title .= '<li>'.\htmlentities(Lang::$current_lang['apiManualInstructions1']).'</li>';
94+
$title .= '<li>'.str_replace('https://my.telegram.org', '<a href="https://my.telegram.org" target="_blank">https://my.telegram.org</a>', htmlentities(Lang::$current_lang['apiManualInstructions0'])).'</li>';
95+
$title .= '<li>'.htmlentities(Lang::$current_lang['apiManualInstructions1']).'</li>';
9696
$title .= '<li><ul>';
9797
foreach (['App title', 'Short name', 'URL', 'Platform', 'Description'] as $k => $key) {
9898
$title .= "<li>$key: ";
99-
$title .= \htmlentities(Lang::$current_lang["apiAppInstructionsManual$k"]);
99+
$title .= htmlentities(Lang::$current_lang["apiAppInstructionsManual$k"]);
100100
$title .= '</li>';
101101
}
102102
$title .= '</li></ul>';
103-
$title .= '<li>'.\htmlentities(Lang::$current_lang['apiManualInstructions2']).'</li>';
103+
$title .= '<li>'.htmlentities(Lang::$current_lang['apiManualInstructions2']).'</li>';
104104
$title .= '</ol>';
105105
$form = '<input type="string" name="api_id" placeholder="API ID" required/>';
106106
$form .= '<input type="string" name="api_hash" placeholder="API hash" required/>';
107107
getOutputBufferStream()->write(
108-
\sprintf(
108+
sprintf(
109109
$settings->getTemplates()->getHtmlTemplate(),
110110
$title,
111111
$form,

‎src/AsyncTools.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ public static function callFork(callable|Generator|Future $callable, ...$args):
8282
*/
8383
public static function flock(string $file, int $operation, float $polling = 0.1, ?Cancellation $token = null, ?Closure $failureCb = null): ?Closure
8484
{
85-
if (!\file_exists($file)) {
86-
\touch($file);
85+
if (!file_exists($file)) {
86+
touch($file);
8787
}
8888
$operation |= LOCK_NB;
89-
$res = \fopen($file, 'c');
89+
$res = fopen($file, 'c');
9090
do {
91-
$result = \flock($res, $operation);
91+
$result = flock($res, $operation);
9292
if (!$result) {
9393
if ($failureCb) {
9494
EventLoop::queue($failureCb);
@@ -110,8 +110,8 @@ public static function flock(string $file, int $operation, float $polling = 0.1,
110110
} while (!$result);
111111
return static function () use (&$res): void {
112112
if ($res) {
113-
\flock($res, LOCK_UN);
114-
\fclose($res);
113+
flock($res, LOCK_UN);
114+
fclose($res);
115115
$res = null;
116116
}
117117
};
@@ -153,14 +153,14 @@ public static function readLine(string $prompt = '', ?Cancellation $cancel = nul
153153
}
154154
static $lines = [''];
155155
while (\count($lines) < 2 && ($chunk = $stdin->read($cancel)) !== null) {
156-
$chunk = \explode("\n", \str_replace(["\r", "\n\n"], "\n", $chunk));
157-
$lines[\count($lines) - 1] .= \array_shift($chunk);
158-
$lines = \array_merge($lines, $chunk);
156+
$chunk = explode("\n", str_replace(["\r", "\n\n"], "\n", $chunk));
157+
$lines[\count($lines) - 1] .= array_shift($chunk);
158+
$lines = array_merge($lines, $chunk);
159159
}
160160
} finally {
161161
Magic::togglePeriodicLogging();
162162
}
163-
return \array_shift($lines) ?? '';
163+
return array_shift($lines) ?? '';
164164
}
165165
/**
166166
* Asynchronously write to stdout/browser.

‎src/Broadcast/Action/ActionForward.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function act(int $broadcastId, int $peer, Cancellation $cancellation): vo
5050
$id = 0;
5151
foreach ($updates as $update) {
5252
if (\in_array($update['_'], ['updateNewMessage', 'updateNewChannelMessage'], true)) {
53-
$id = \max($id, $update['message']['id']);
53+
$id = max($id, $update['message']['id']);
5454
}
5555
}
5656
try {

‎src/Broadcast/Action/ActionSend.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function act(int $broadcastId, int $peer, Cancellation $cancellation): vo
4444
$message['media']['_'] !== 'messageMediaWebPage'
4545
? 'messages.sendMedia'
4646
: 'messages.sendMessage',
47-
\array_merge($message, ['peer' => $peer]),
47+
array_merge($message, ['peer' => $peer]),
4848
['FloodWaitLimit' => 2*86400]
4949
));
5050
}

‎src/Broadcast/Broadcast.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function broadcastForwardMessages(mixed $from_peer, array $message_ids, b
9696
public function broadcastCustom(Action $action, ?Filter $filter = null): int
9797
{
9898
// Ensure it can be serialized
99-
Assert::eq(\unserialize(\serialize($action))::class, $action::class);
99+
Assert::eq(unserialize(serialize($action))::class, $action::class);
100100

101101
$id = $this->broadcastId--;
102102
$this->broadcasts[$id] = new InternalState($id, $this, $action, $filter ?? Filter::default());

‎src/Broadcast/InternalState.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(
5656
}
5757
public function __serialize(): array
5858
{
59-
$vars = \get_object_vars($this);
59+
$vars = get_object_vars($this);
6060
$vars['status'] = match ($vars['status']) {
6161
StatusInternal::GATHERING_PEERS => StatusInternal::IDLING_BEFORE_GATHERING_PEERS,
6262
StatusInternal::BROADCASTING => StatusInternal::IDLING_BEFORE_BROADCASTING,
@@ -131,7 +131,7 @@ private function gatherPeers(): void
131131
}
132132
}
133133
}
134-
$peers = \array_filter($peers, function (int $peer): bool {
134+
$peers = array_filter($peers, function (int $peer): bool {
135135
if (\in_array($peer, $this->filter->blacklist, true)) {
136136
return false;
137137
}

‎src/Connection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ private function methodAbstractions(string &$method, array &$arguments): void
439439
}
440440
}
441441
return;
442-
} elseif (\in_array($method, ['messages.addChatUser', 'messages.deleteChatUser', 'messages.editChatAdmin', 'messages.editChatPhoto', 'messages.editChatTitle', 'messages.getFullChat', 'messages.exportChatInvite', 'messages.editChatAdmin', 'messages.migrateChat'], true) && isset($arguments['chat_id']) && (!\is_numeric($arguments['chat_id']) || $arguments['chat_id'] < 0)) {
442+
} elseif (\in_array($method, ['messages.addChatUser', 'messages.deleteChatUser', 'messages.editChatAdmin', 'messages.editChatPhoto', 'messages.editChatTitle', 'messages.getFullChat', 'messages.exportChatInvite', 'messages.editChatAdmin', 'messages.migrateChat'], true) && isset($arguments['chat_id']) && (!is_numeric($arguments['chat_id']) || $arguments['chat_id'] < 0)) {
443443
$res = $this->API->getInfo($arguments['chat_id']);
444444
if ($res['type'] !== 'chat') {
445445
throw new Exception('chat_id is not a chat id (only normal groups allowed, not supergroups)!');

0 commit comments

Comments
 (0)