mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
AsyncTask: remove $serialize parameter from setResult()
Whether serialization is necessary can be determined automatically based on the type of variable.
This commit is contained in:
parent
d257d36e55
commit
9caf62778c
@ -60,7 +60,7 @@ class ChunkRequestTask extends AsyncTask{
|
||||
$batch->setCompressionLevel($this->compressionLevel);
|
||||
$batch->encode();
|
||||
|
||||
$this->setResult($batch->buffer, false);
|
||||
$this->setResult($batch->buffer);
|
||||
}
|
||||
|
||||
public function onCompletion(Server $server){
|
||||
|
@ -51,7 +51,7 @@ class CompressBatchedTask extends AsyncTask{
|
||||
$batch->setCompressionLevel($this->level);
|
||||
$batch->encode();
|
||||
|
||||
$this->setResult($batch->buffer, false);
|
||||
$this->setResult($batch->buffer);
|
||||
}
|
||||
|
||||
public function onCompletion(Server $server){
|
||||
|
@ -107,11 +107,9 @@ abstract class AsyncTask extends Collectable{
|
||||
|
||||
/**
|
||||
* @param mixed $result
|
||||
* @param bool $serialize
|
||||
*/
|
||||
public function setResult($result, bool $serialize = true){
|
||||
$this->result = $serialize ? serialize($result) : $result;
|
||||
$this->serialized = $serialize;
|
||||
public function setResult($result){
|
||||
$this->result = ($this->serialized = !is_scalar($result)) ? serialize($result) : $result;
|
||||
}
|
||||
|
||||
public function setTaskId(int $taskId){
|
||||
|
@ -59,7 +59,7 @@ class UpdateCheckTask extends AsyncTask{
|
||||
isset($response["download_url"])
|
||||
){
|
||||
$response["details_url"] = $response["details_url"] ?? null;
|
||||
$this->setResult($response, true);
|
||||
$this->setResult($response);
|
||||
}elseif(isset($response["error"])){
|
||||
$this->error = $response["error"];
|
||||
}else{
|
||||
|
Loading…
x
Reference in New Issue
Block a user