From 541db2e507e5c751bf45ce4ab8bcabac4bb05337 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 26 Jul 2017 08:53:58 +0200 Subject: [PATCH] whoops --- src/danog/MadelineProto/MTProto.php | 2 +- .../MadelineProto/TL/PrettyException.php | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/danog/MadelineProto/TL/PrettyException.php diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index d27dcedf..8709defc 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -44,7 +44,7 @@ class MTProto extends \Volatile use \danog\MadelineProto\Wrappers\DialogHandler; use \danog\MadelineProto\Wrappers\Login; - const V = 59; + const V = 60; const NOT_LOGGED_IN = 0; const WAITING_CODE = 1; diff --git a/src/danog/MadelineProto/TL/PrettyException.php b/src/danog/MadelineProto/TL/PrettyException.php new file mode 100644 index 00000000..8d3b17fe --- /dev/null +++ b/src/danog/MadelineProto/TL/PrettyException.php @@ -0,0 +1,39 @@ +. +*/ + +namespace danog\MadelineProto\TL; + +trait PrettyException +{ + private $tl_trace; + public function getTLTrace() { + return $this->tl_trace; + } + public function prettify_tl($init = '') { + $tl = false; + foreach (array_reverse($this->getTrace()) as $frame){ + if (isset($frame['function']) && in_array($frame['function'], ['serialize_params', 'serialize_object'])) { + $this->tl_trace .= $tl ? "['".$frame['args'][2]."']" : "While serializing: \t".$frame['args'][2]; + $tl = true; + } else { + if ($tl) $this->tl_trace .= PHP_EOL; + $this->tl_trace .= isset($frame['file']) ? str_pad(basename($frame['file']).'('.$frame['line'].'):', 16)."\t" : ''; + $this->tl_trace .= isset($frame['function']) ? $frame['function'].'(' : ''; + $this->tl_trace .= isset($frame['args']) ? substr(json_encode($frame['args']), 1, -1) : ''; + $this->tl_trace .= ')'; + $this->tl_trace .= PHP_EOL; + $tl = false; + } + } + $this->tl_trace = $this->tl_trace."['".$init."']"; + } +}