mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 08:18:59 +01:00
Fixes
This commit is contained in:
parent
935e0daf86
commit
b63099b130
@ -2340,6 +2340,7 @@
|
|||||||
<code><![CDATA[$media['media']]]></code>
|
<code><![CDATA[$media['media']]]></code>
|
||||||
</MixedArrayAccess>
|
</MixedArrayAccess>
|
||||||
<MixedAssignment>
|
<MixedAssignment>
|
||||||
|
<code><![CDATA[$arg]]></code>
|
||||||
<code><![CDATA[$callable]]></code>
|
<code><![CDATA[$callable]]></code>
|
||||||
<code><![CDATA[$callable]]></code>
|
<code><![CDATA[$callable]]></code>
|
||||||
<code><![CDATA[$dir]]></code>
|
<code><![CDATA[$dir]]></code>
|
||||||
@ -2510,6 +2511,9 @@
|
|||||||
<code><![CDATA[Wrapper]]></code>
|
<code><![CDATA[Wrapper]]></code>
|
||||||
<code><![CDATA[Wrapper]]></code>
|
<code><![CDATA[Wrapper]]></code>
|
||||||
</PropertyNotSetInConstructor>
|
</PropertyNotSetInConstructor>
|
||||||
|
<PropertyTypeCoercion>
|
||||||
|
<code><![CDATA[$this->callbackIds]]></code>
|
||||||
|
</PropertyTypeCoercion>
|
||||||
<UnsafeInstantiation>
|
<UnsafeInstantiation>
|
||||||
<code><![CDATA[new $class($this, $ids)]]></code>
|
<code><![CDATA[new $class($this, $ids)]]></code>
|
||||||
</UnsafeInstantiation>
|
</UnsafeInstantiation>
|
||||||
@ -2518,10 +2522,13 @@
|
|||||||
<code><![CDATA[$this->callbackIds[] = &$callback]]></code>
|
<code><![CDATA[$this->callbackIds[] = &$callback]]></code>
|
||||||
</UnsupportedReferenceUsage>
|
</UnsupportedReferenceUsage>
|
||||||
</file>
|
</file>
|
||||||
<file src="src/Ipc/Wrapper/Cancellation.php">
|
<file src="src/Ipc/Wrapper/CancellationInner.php">
|
||||||
|
<MixedAssignment>
|
||||||
|
<code><![CDATA[$id]]></code>
|
||||||
|
</MixedAssignment>
|
||||||
<MixedReturnStatement>
|
<MixedReturnStatement>
|
||||||
|
<code><![CDATA[$id]]></code>
|
||||||
<code><![CDATA[$this->__call('isRequested')]]></code>
|
<code><![CDATA[$this->__call('isRequested')]]></code>
|
||||||
<code><![CDATA[$this->__call('unsubscribe', [$callback])]]></code>
|
|
||||||
</MixedReturnStatement>
|
</MixedReturnStatement>
|
||||||
</file>
|
</file>
|
||||||
<file src="src/Ipc/Wrapper/ReadableStream.php">
|
<file src="src/Ipc/Wrapper/ReadableStream.php">
|
||||||
@ -2536,6 +2543,14 @@
|
|||||||
<code><![CDATA[$this->__call('isReadable')]]></code>
|
<code><![CDATA[$this->__call('isReadable')]]></code>
|
||||||
</MixedReturnStatement>
|
</MixedReturnStatement>
|
||||||
</file>
|
</file>
|
||||||
|
<file src="src/Ipc/Wrapper/WrappedCancellation.php">
|
||||||
|
<DocblockTypeContradiction>
|
||||||
|
<code><![CDATA[$this->handlers[$id]]]></code>
|
||||||
|
</DocblockTypeContradiction>
|
||||||
|
<RedundantConditionGivenDocblockType>
|
||||||
|
<code><![CDATA[$this->handlers[$id]?->complete()]]></code>
|
||||||
|
</RedundantConditionGivenDocblockType>
|
||||||
|
</file>
|
||||||
<file src="src/Ipc/Wrapper/WritableStream.php">
|
<file src="src/Ipc/Wrapper/WritableStream.php">
|
||||||
<MixedReturnStatement>
|
<MixedReturnStatement>
|
||||||
<code><![CDATA[$this->__call('isWritable')]]></code>
|
<code><![CDATA[$this->__call('isWritable')]]></code>
|
||||||
|
@ -121,8 +121,7 @@ final class Wrapper extends ClientAbstract
|
|||||||
}
|
}
|
||||||
$ids = [];
|
$ids = [];
|
||||||
foreach (get_class_methods($callback) as $method) {
|
foreach (get_class_methods($callback) as $method) {
|
||||||
//$id = $this->id++;
|
$id = $this->id++;
|
||||||
$id = $this->id++.'_'.$method;
|
|
||||||
$this->callbacks[$id] = [$callback, $method];
|
$this->callbacks[$id] = [$callback, $method];
|
||||||
$ids[$method] = $id;
|
$ids[$method] = $id;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,9 @@ use danog\MadelineProto\Ipc\ClientAbstract;
|
|||||||
*/
|
*/
|
||||||
final class Cancellation implements AmpCancellation
|
final class Cancellation implements AmpCancellation
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var array<string, true> $handlers
|
||||||
|
*/
|
||||||
private array $handlers = [];
|
private array $handlers = [];
|
||||||
private CancellationInner $inner;
|
private CancellationInner $inner;
|
||||||
/**
|
/**
|
||||||
@ -50,7 +53,9 @@ final class Cancellation implements AmpCancellation
|
|||||||
*/
|
*/
|
||||||
public function subscribe(\Closure $callback): string
|
public function subscribe(\Closure $callback): string
|
||||||
{
|
{
|
||||||
return $this->inner->subscribe($callback);
|
$id = $this->inner->subscribe($callback);
|
||||||
|
$this->handlers[$id] = true;
|
||||||
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,6 +65,7 @@ final class Cancellation implements AmpCancellation
|
|||||||
*/
|
*/
|
||||||
public function unsubscribe(string $id): void
|
public function unsubscribe(string $id): void
|
||||||
{
|
{
|
||||||
|
unset($this->handlers[$id]);
|
||||||
$this->inner->unsubscribe($id);
|
$this->inner->unsubscribe($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +89,7 @@ final class Cancellation implements AmpCancellation
|
|||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
foreach ($this->handlers as $handler) {
|
foreach ($this->handlers as $handler => $_) {
|
||||||
$this->inner->unsubscribe($handler);
|
$this->inner->unsubscribe($handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,10 @@ final class WrappedCancellation
|
|||||||
*/
|
*/
|
||||||
public function unsubscribe(string $id): void
|
public function unsubscribe(string $id): void
|
||||||
{
|
{
|
||||||
$this->handlers[$id]?->complete();
|
if (isset($this->handlers[$id])) {
|
||||||
unset($this->handlers[$id]);
|
$this->handlers[$id]->complete();
|
||||||
|
unset($this->handlers[$id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user