1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 08:39:00 +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> <MissingConstructor>
<code>$pdo</code> <code>$pdo</code>
</MissingConstructor> </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>
<file src="src/Db/PostgresArray.php"> <file src="src/Db/PostgresArray.php">
<MissingClosureParamType> <MissingClosureParamType>
@ -487,6 +480,11 @@
<code>$peersResolved</code> <code>$peersResolved</code>
</PropertyNotSetInConstructor> </PropertyNotSetInConstructor>
</file> </file>
<file src="src/EventHandler/Filter/FilterForwardedFrom.php">
<PropertyNotSetInConstructor>
<code>$peerResolved</code>
</PropertyNotSetInConstructor>
</file>
<file src="src/EventHandler/Filter/FilterFromAdmin.php"> <file src="src/EventHandler/Filter/FilterFromAdmin.php">
<MissingConstructor> <MissingConstructor>
<code>$adminIds</code> <code>$adminIds</code>
@ -648,12 +646,15 @@
<file src="src/EventHandler/Message.php"> <file src="src/EventHandler/Message.php">
<LessSpecificReturnStatement> <LessSpecificReturnStatement>
<code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code> <code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code>
<code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code>
</LessSpecificReturnStatement> </LessSpecificReturnStatement>
<MoreSpecificReturnType> <MoreSpecificReturnType>
<code>Message</code> <code>Message</code>
<code>Message</code>
</MoreSpecificReturnType> </MoreSpecificReturnType>
<NullableReturnStatement> <NullableReturnStatement>
<code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code> <code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code>
<code><![CDATA[$this->getClient()->wrapMessage($this->getClient()->extractMessage($result))]]></code>
</NullableReturnStatement> </NullableReturnStatement>
<PropertyNotSetInConstructor> <PropertyNotSetInConstructor>
<code>$html</code> <code>$html</code>
@ -737,6 +738,12 @@
<code><![CDATA[$API->getIdInternal($rawPinned)]]></code> <code><![CDATA[$API->getIdInternal($rawPinned)]]></code>
</PossiblyNullPropertyAssignmentValue> </PossiblyNullPropertyAssignmentValue>
</file> </file>
<file src="src/EventHandler/Poll/QuizPoll.php">
<PropertyNotSetInConstructor>
<code>$html</code>
<code>$htmlTelegram</code>
</PropertyNotSetInConstructor>
</file>
<file src="src/EventHandler/Privacy.php"> <file src="src/EventHandler/Privacy.php">
<PropertyTypeCoercion> <PropertyTypeCoercion>
<code><![CDATA[array_map(RuleDestination::fromRawRule(...), $rawPrivacy['rules'])]]></code> <code><![CDATA[array_map(RuleDestination::fromRawRule(...), $rawPrivacy['rules'])]]></code>
@ -745,6 +752,7 @@
<file src="src/EventHandler/Query/ChatTrait.php"> <file src="src/EventHandler/Query/ChatTrait.php">
<MoreSpecificReturnType> <MoreSpecificReturnType>
<code>Message</code> <code>Message</code>
<code>Message</code>
</MoreSpecificReturnType> </MoreSpecificReturnType>
<PossiblyNullPropertyAssignmentValue> <PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$API->getIdInternal($rawCallback['peer'])]]></code> <code><![CDATA[$API->getIdInternal($rawCallback['peer'])]]></code>
@ -1710,7 +1718,6 @@
</MissingReturnType> </MissingReturnType>
<PossiblyNullArgument> <PossiblyNullArgument>
<code><![CDATA[$this->getIdInternal($message['action']['from_id'])]]></code> <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> <code><![CDATA[$this->getIdInternal($message['action']['to_id'])]]></code>
</PossiblyNullArgument> </PossiblyNullArgument>
<PossiblyNullArrayAccess> <PossiblyNullArrayAccess>
@ -2207,7 +2214,6 @@
</PossiblyNullArgument> </PossiblyNullArgument>
<PossiblyNullReference> <PossiblyNullReference>
<code>botAPIToMTProto</code> <code>botAPIToMTProto</code>
<code>logger</code>
</PossiblyNullReference> </PossiblyNullReference>
<PossiblyUndefinedArrayOffset> <PossiblyUndefinedArrayOffset>
<code>$elem[1]</code> <code>$elem[1]</code>
@ -2256,10 +2262,6 @@
</PossiblyNullArrayAccess> </PossiblyNullArrayAccess>
</file> </file>
<file src="src/Tools.php"> <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> <MissingClosureParamType>
<code>$val</code> <code>$val</code>
</MissingClosureParamType> </MissingClosureParamType>
@ -2429,9 +2431,6 @@
<code><![CDATA[$this->authorization['phone_number']]]></code> <code><![CDATA[$this->authorization['phone_number']]]></code>
<code><![CDATA[$this->authorization['phone_number']]]></code> <code><![CDATA[$this->authorization['phone_number']]]></code>
</PossiblyNullArrayAccess> </PossiblyNullArrayAccess>
<PossiblyUndefinedVariable>
<code>$datacenter</code>
</PossiblyUndefinedVariable>
<RedundantConditionGivenDocblockType> <RedundantConditionGivenDocblockType>
<code>\is_array($auth_key)</code> <code>\is_array($auth_key)</code>
</RedundantConditionGivenDocblockType> </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... * @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) { if (!$this->entities) {
return StrTools::htmlEscape($this->solution); return StrTools::htmlEscape($this->solution);
} }

View File

@ -242,6 +242,7 @@ final class PeerDatabase implements TLCallback
$id = $content; $id = $content;
} }
} }
if (\is_string($id)) {
$id = strtolower(str_replace('@', '', $id)); $id = strtolower(str_replace('@', '', $id));
if ($id === 'me') { if ($id === 'me') {
$id = $this->API->authorization['user']['id']; $id = $this->API->authorization['user']['id'];
@ -254,6 +255,7 @@ final class PeerDatabase implements TLCallback
} }
} }
} }
}
unset($this->fullDb[$this->API->getIdInternal($id)]); unset($this->fullDb[$this->API->getIdInternal($id)]);
$this->API->getFullInfo($id); $this->API->getFullInfo($id);
} }

View File

@ -457,6 +457,7 @@ trait PeerHandler
$id = $content; $id = $content;
} }
} }
if (\is_string($id)) {
$id = strtolower(str_replace('@', '', $id)); $id = strtolower(str_replace('@', '', $id));
if ($id === 'me') { if ($id === 'me') {
return $this->getInfo($this->authorization['user']['id'], $type); return $this->getInfo($this->authorization['user']['id'], $type);
@ -473,6 +474,9 @@ trait PeerHandler
if ($bot_api_id = $this->peerDatabase->resolveUsername($id)) { if ($bot_api_id = $this->peerDatabase->resolveUsername($id)) {
return $this->getInfo($bot_api_id, $type); return $this->getInfo($bot_api_id, $type);
} }
} else {
return $this->getInfo($id, $type);
}
if ($this->cacheFullDialogs()) { if ($this->cacheFullDialogs()) {
return $this->getInfo($id, $type); return $this->getInfo($id, $type);
} }
@ -602,6 +606,7 @@ trait PeerHandler
$id = $content; $id = $content;
} }
} }
if (\is_string($id)) {
$id = strtolower(str_replace('@', '', $id)); $id = strtolower(str_replace('@', '', $id));
if ($id === 'me') { if ($id === 'me') {
$id = $this->authorization['user']['id']; $id = $this->authorization['user']['id'];
@ -615,6 +620,7 @@ trait PeerHandler
} }
} }
} }
}
$id = $this->getIdInternal($id); $id = $this->getIdInternal($id);
Assert::notNull($id); Assert::notNull($id);
switch (DialogId::getType($id)) { switch (DialogId::getType($id)) {