1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 04:08:59 +01:00

Psalm fix

This commit is contained in:
Daniil Gentili 2024-01-17 11:10:46 +01:00
parent 7f0dd3bfb3
commit bd4643fa97
4 changed files with 60 additions and 50 deletions

View File

@ -282,13 +282,6 @@
<MissingConstructor>
<code>$pdo</code>
</MissingConstructor>
<PossiblyNullArrayAccess>
<code><![CDATA[$this->db->query("SELECT data_free FROM information_schema.tables WHERE table_schema=`{$database}` AND table_name=`{$this->table}`")->fetchRow()['data_free']]]></code>
</PossiblyNullArrayAccess>
<UndefinedMethod>
<code>getOptimizeIfWastedGtMb</code>
<code>getOptimizeIfWastedGtMb</code>
</UndefinedMethod>
</file>
<file src="src/Db/PostgresArray.php">
<MissingClosureParamType>
@ -487,6 +480,11 @@
<code>$peersResolved</code>
</PropertyNotSetInConstructor>
</file>
<file src="src/EventHandler/Filter/FilterForwardedFrom.php">
<PropertyNotSetInConstructor>
<code>$peerResolved</code>
</PropertyNotSetInConstructor>
</file>
<file src="src/EventHandler/Filter/FilterFromAdmin.php">
<MissingConstructor>
<code>$adminIds</code>
@ -648,12 +646,15 @@
<file src="src/EventHandler/Message.php">
<LessSpecificReturnStatement>
<code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code>
<code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code>Message</code>
<code>Message</code>
</MoreSpecificReturnType>
<NullableReturnStatement>
<code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code>
<code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code>
</NullableReturnStatement>
<PropertyNotSetInConstructor>
<code>$html</code>
@ -737,6 +738,12 @@
<code><![CDATA[$API->getIdInternal($rawPinned)]]></code>
</PossiblyNullPropertyAssignmentValue>
</file>
<file src="src/EventHandler/Poll/QuizPoll.php">
<PropertyNotSetInConstructor>
<code>$html</code>
<code>$htmlTelegram</code>
</PropertyNotSetInConstructor>
</file>
<file src="src/EventHandler/Privacy.php">
<PropertyTypeCoercion>
<code><![CDATA[array_map(RuleDestination::fromRawRule(...), $rawPrivacy['rules'])]]></code>
@ -745,6 +752,7 @@
<file src="src/EventHandler/Query/ChatTrait.php">
<MoreSpecificReturnType>
<code>Message</code>
<code>Message</code>
</MoreSpecificReturnType>
<PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$API->getIdInternal($rawCallback['peer'])]]></code>
@ -1710,7 +1718,6 @@
</MissingReturnType>
<PossiblyNullArgument>
<code><![CDATA[$this->getIdInternal($message['action']['from_id'])]]></code>
<code><![CDATA[$this->getIdInternal($message['action']['peer'])]]></code>
<code><![CDATA[$this->getIdInternal($message['action']['to_id'])]]></code>
</PossiblyNullArgument>
<PossiblyNullArrayAccess>
@ -2207,7 +2214,6 @@
</PossiblyNullArgument>
<PossiblyNullReference>
<code>botAPIToMTProto</code>
<code>logger</code>
</PossiblyNullReference>
<PossiblyUndefinedArrayOffset>
<code>$elem[1]</code>
@ -2256,10 +2262,6 @@
</PossiblyNullArrayAccess>
</file>
<file src="src/Tools.php">
<ArgumentTypeCoercion>
<code><![CDATA[static fn (ClassLike $c): bool => $c->name !== null]]></code>
<code><![CDATA[static fn (ClassLike $c): bool => $c->name !== null]]></code>
</ArgumentTypeCoercion>
<MissingClosureParamType>
<code>$val</code>
</MissingClosureParamType>
@ -2429,9 +2431,6 @@
<code><![CDATA[$this->authorization['phone_number']]]></code>
<code><![CDATA[$this->authorization['phone_number']]]></code>
</PossiblyNullArrayAccess>
<PossiblyUndefinedVariable>
<code>$datacenter</code>
</PossiblyUndefinedVariable>
<RedundantConditionGivenDocblockType>
<code>\is_array($auth_key)</code>
</RedundantConditionGivenDocblockType>

View File

@ -47,8 +47,11 @@ final class QuizPoll extends AbstractPoll
*
* @param bool $allowTelegramTags Whether to allow telegram-specific tags like tg-spoiler, tg-emoji, mention links and so on...
*/
public function getHTML(bool $allowTelegramTags = false): string
public function getHTML(bool $allowTelegramTags = false): ?string
{
if ($this->solution === null) {
return null;
}
if (!$this->entities) {
return StrTools::htmlEscape($this->solution);
}

View File

@ -242,15 +242,17 @@ final class PeerDatabase implements TLCallback
$id = $content;
}
}
$id = strtolower(str_replace('@', '', $id));
if ($id === 'me') {
$id = $this->API->authorization['user']['id'];
} elseif ($id === 'support') {
$id = $this->API->methodCallAsyncRead('help.getSupport', [])['user'];
} else {
$id = $this->resolveUsername($id);
if ($id === null) {
throw new PeerNotInDbException;
if (\is_string($id)) {
$id = strtolower(str_replace('@', '', $id));
if ($id === 'me') {
$id = $this->API->authorization['user']['id'];
} elseif ($id === 'support') {
$id = $this->API->methodCallAsyncRead('help.getSupport', [])['user'];
} else {
$id = $this->resolveUsername($id);
if ($id === null) {
throw new PeerNotInDbException;
}
}
}
}

View File

@ -457,21 +457,25 @@ trait PeerHandler
$id = $content;
}
}
$id = strtolower(str_replace('@', '', $id));
if ($id === 'me') {
return $this->getInfo($this->authorization['user']['id'], $type);
}
if ($id === 'support') {
if (!$this->supportUser) {
$this->methodCallAsyncRead('help.getSupport', []);
if (\is_string($id)) {
$id = strtolower(str_replace('@', '', $id));
if ($id === 'me') {
return $this->getInfo($this->authorization['user']['id'], $type);
}
return $this->getInfo($this->supportUser, $type);
}
if ($bot_api_id = $this->peerDatabase->getIdFromUsername($id)) {
return $this->getInfo($bot_api_id, $type);
}
if ($bot_api_id = $this->peerDatabase->resolveUsername($id)) {
return $this->getInfo($bot_api_id, $type);
if ($id === 'support') {
if (!$this->supportUser) {
$this->methodCallAsyncRead('help.getSupport', []);
}
return $this->getInfo($this->supportUser, $type);
}
if ($bot_api_id = $this->peerDatabase->getIdFromUsername($id)) {
return $this->getInfo($bot_api_id, $type);
}
if ($bot_api_id = $this->peerDatabase->resolveUsername($id)) {
return $this->getInfo($bot_api_id, $type);
}
} else {
return $this->getInfo($id, $type);
}
if ($this->cacheFullDialogs()) {
return $this->getInfo($id, $type);
@ -602,16 +606,18 @@ trait PeerHandler
$id = $content;
}
}
$id = strtolower(str_replace('@', '', $id));
if ($id === 'me') {
$id = $this->authorization['user']['id'];
} elseif ($id === 'support') {
$this->methodCallAsyncRead('help.getSupport', []);
continue;
} else {
$id = $this->peerDatabase->resolveUsername($id);
if ($id === null) {
throw new PeerNotInDbException;
if (\is_string($id)) {
$id = strtolower(str_replace('@', '', $id));
if ($id === 'me') {
$id = $this->authorization['user']['id'];
} elseif ($id === 'support') {
$this->methodCallAsyncRead('help.getSupport', []);
continue;
} else {
$id = $this->peerDatabase->resolveUsername($id);
if ($id === null) {
throw new PeerNotInDbException;
}
}
}
}