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:
Dylan K. Taylor 2018-11-03 16:56:24 +00:00
parent d257d36e55
commit 9caf62778c
4 changed files with 5 additions and 7 deletions

View File

@ -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){

View File

@ -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){

View File

@ -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){

View File

@ -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{