AsyncTask: fix another phpstan level 7 error about wrong types

this should really be a dedicated type, but everything done with pthreads sucks.
This commit is contained in:
Dylan K. Taylor 2020-04-15 12:42:18 +01:00
parent 8020912448
commit 88b216a17b

View File

@ -25,6 +25,7 @@ namespace pocketmine\scheduler;
use pocketmine\Collectable;
use pocketmine\Server;
use pocketmine\utils\AssumptionFailedError;
use function is_scalar;
use function serialize;
use function unserialize;
@ -97,7 +98,11 @@ abstract class AsyncTask extends Collectable{
* @return mixed
*/
public function getResult(){
return $this->serialized ? unserialize($this->result) : $this->result;
if($this->serialized){
if(!is_string($this->result)) throw new AssumptionFailedError("Result expected to be a serialized string");
return unserialize($this->result);
}
return $this->result;
}
/**