Applied fixes from StyleCI

This commit is contained in:
Daniil Gentili 2016-11-23 20:04:51 +00:00 committed by StyleCI Bot
parent 109c887337
commit 87e625ea9c
3 changed files with 12 additions and 5 deletions

View File

@ -60,14 +60,17 @@ class TL extends \danog\MadelineProto\Tools
if ($tl_constructor === false) { if ($tl_constructor === false) {
throw new Exception('Could not extract type: '.$object); throw new Exception('Could not extract type: '.$object);
} }
return $this->serialize_generic($tl_constructor, $arguments); return $this->serialize_generic($tl_constructor, $arguments);
} }
public function serialize_method($method, $arguments) public function serialize_method($method, $arguments)
{ {
$tl_method = $this->methods->find_by_method($method); $tl_method = $this->methods->find_by_method($method);
if ($tl_method === false) { if ($tl_method === false) {
throw new Exception('Could not extract type: '.$method); throw new Exception('Could not extract type: '.$method);
} }
return $this->serialize_generic($tl_method, $arguments); return $this->serialize_generic($tl_method, $arguments);
} }
@ -86,7 +89,9 @@ class TL extends \danog\MadelineProto\Tools
break; break;
case 'Bool': case 'Bool':
$arguments[$cur_flag['name']] = (isset($arguments[$cur_flag['name']]) && $arguments[$cur_flag['name']]) && (($flags & $flag_pow) != 0); $arguments[$cur_flag['name']] = (isset($arguments[$cur_flag['name']]) && $arguments[$cur_flag['name']]) && (($flags & $flag_pow) != 0);
if (($flags & $flag_pow) == 0) unset($arguments[$cur_flag['name']]); if (($flags & $flag_pow) == 0) {
unset($arguments[$cur_flag['name']]);
}
break; break;
default: default:
$flags = (isset($arguments[$cur_flag['name']]) && $arguments[$cur_flag['name']] !== null) ? ($flags | $flag_pow) : ($flags & ~$flag_pow); $flags = (isset($arguments[$cur_flag['name']]) && $arguments[$cur_flag['name']] !== null) ? ($flags | $flag_pow) : ($flags & ~$flag_pow);
@ -117,7 +122,8 @@ class TL extends \danog\MadelineProto\Tools
if (!is_bool($value)) { if (!is_bool($value)) {
throw new Exception("serialize_param: given value isn't a boolean"); throw new Exception("serialize_param: given value isn't a boolean");
} }
return $this->serialize_param('bool'.($value ? "True" : "False"));
return $this->serialize_param('bool'.($value ? 'True' : 'False'));
break; break;
case 'int': case 'int':
if (!is_numeric($value)) { if (!is_numeric($value)) {
@ -180,6 +186,7 @@ class TL extends \danog\MadelineProto\Tools
if ($tl_elem === false) { if ($tl_elem === false) {
throw new Exception('Could not serialize type: '.$type); throw new Exception('Could not serialize type: '.$type);
} }
return \danog\PHP\Struct::pack('<i', $tl_elem['id']); return \danog\PHP\Struct::pack('<i', $tl_elem['id']);
break; break;
} }

View File

@ -23,7 +23,7 @@ class TLConstructor
public function add($json_dict, $mtproto) public function add($json_dict, $mtproto)
{ {
$this->id[$this->key] = (int) $json_dict['id']; $this->id[$this->key] = (int) $json_dict['id'];
$this->predicate[$this->key] = (string)((($mtproto && $json_dict['predicate'] == 'message') ? 'MT' : '').$json_dict['predicate']); $this->predicate[$this->key] = (string) ((($mtproto && $json_dict['predicate'] == 'message') ? 'MT' : '').$json_dict['predicate']);
$this->type[$this->key] = $json_dict['type']; $this->type[$this->key] = $json_dict['type'];
$this->params[$this->key] = $json_dict['params']; $this->params[$this->key] = $json_dict['params'];
foreach ($this->params[$this->key] as &$param) { foreach ($this->params[$this->key] as &$param) {