mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
More nullable and void typehints
This commit is contained in:
@ -196,7 +196,7 @@ abstract class AsyncTask extends \Threaded{
|
||||
*
|
||||
* @param mixed $progress A value that can be safely serialize()'ed.
|
||||
*/
|
||||
public function publishProgress($progress){
|
||||
public function publishProgress($progress) : void{
|
||||
$this->progressUpdates[] = serialize($progress);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class AsyncWorker extends Worker{
|
||||
$this->memoryLimit = $memoryLimit;
|
||||
}
|
||||
|
||||
public function run(){
|
||||
public function run() : void{
|
||||
error_reporting(-1);
|
||||
|
||||
$this->registerClassLoader();
|
||||
@ -73,7 +73,7 @@ class AsyncWorker extends Worker{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
public function handleException(\Throwable $e){
|
||||
public function handleException(\Throwable $e) : void{
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class ClosureTask extends Task{
|
||||
return Utils::getNiceClosureName($this->closure);
|
||||
}
|
||||
|
||||
public function onRun(int $currentTick){
|
||||
public function onRun(int $currentTick) : void{
|
||||
($this->closure)($currentTick);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ abstract class Task{
|
||||
/**
|
||||
* @param TaskHandler|null $taskHandler
|
||||
*/
|
||||
final public function setHandler(?TaskHandler $taskHandler){
|
||||
final public function setHandler(?TaskHandler $taskHandler) : void{
|
||||
if($this->taskHandler === null or $taskHandler === null){
|
||||
$this->taskHandler = $taskHandler;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class TaskHandler{
|
||||
/**
|
||||
* @param int $ticks
|
||||
*/
|
||||
public function setNextRun(int $ticks){
|
||||
public function setNextRun(int $ticks) : void{
|
||||
$this->nextRun = $ticks;
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ class TaskHandler{
|
||||
return $this->period;
|
||||
}
|
||||
|
||||
public function cancel(){
|
||||
public function cancel() : void{
|
||||
try{
|
||||
if(!$this->isCancelled()){
|
||||
$this->task->onCancel();
|
||||
@ -145,7 +145,7 @@ class TaskHandler{
|
||||
}
|
||||
}
|
||||
|
||||
public function remove(){
|
||||
public function remove() : void{
|
||||
$this->cancelled = true;
|
||||
$this->task->setHandler(null);
|
||||
}
|
||||
@ -153,7 +153,7 @@ class TaskHandler{
|
||||
/**
|
||||
* @param int $currentTick
|
||||
*/
|
||||
public function run(int $currentTick){
|
||||
public function run(int $currentTick) : void{
|
||||
$this->timings->startTiming();
|
||||
try{
|
||||
$this->task->onRun($currentTick);
|
||||
|
@ -65,7 +65,7 @@ class TaskScheduler{
|
||||
*
|
||||
* @return TaskHandler
|
||||
*/
|
||||
public function scheduleTask(Task $task){
|
||||
public function scheduleTask(Task $task) : TaskHandler{
|
||||
return $this->addTask($task, -1, -1);
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ class TaskScheduler{
|
||||
*
|
||||
* @return TaskHandler
|
||||
*/
|
||||
public function scheduleDelayedTask(Task $task, int $delay){
|
||||
public function scheduleDelayedTask(Task $task, int $delay) : TaskHandler{
|
||||
return $this->addTask($task, $delay, -1);
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ class TaskScheduler{
|
||||
*
|
||||
* @return TaskHandler
|
||||
*/
|
||||
public function scheduleRepeatingTask(Task $task, int $period){
|
||||
public function scheduleRepeatingTask(Task $task, int $period) : TaskHandler{
|
||||
return $this->addTask($task, -1, $period);
|
||||
}
|
||||
|
||||
@ -96,14 +96,14 @@ class TaskScheduler{
|
||||
*
|
||||
* @return TaskHandler
|
||||
*/
|
||||
public function scheduleDelayedRepeatingTask(Task $task, int $delay, int $period){
|
||||
public function scheduleDelayedRepeatingTask(Task $task, int $delay, int $period) : TaskHandler{
|
||||
return $this->addTask($task, $delay, $period);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $taskId
|
||||
*/
|
||||
public function cancelTask(int $taskId){
|
||||
public function cancelTask(int $taskId) : void{
|
||||
if(isset($this->tasks[$taskId])){
|
||||
try{
|
||||
$this->tasks[$taskId]->cancel();
|
||||
@ -113,7 +113,7 @@ class TaskScheduler{
|
||||
}
|
||||
}
|
||||
|
||||
public function cancelAllTasks(){
|
||||
public function cancelAllTasks() : void{
|
||||
foreach($this->tasks as $id => $task){
|
||||
$this->cancelTask($id);
|
||||
}
|
||||
@ -142,7 +142,7 @@ class TaskScheduler{
|
||||
*
|
||||
* @throws \InvalidStateException
|
||||
*/
|
||||
private function addTask(Task $task, int $delay, int $period){
|
||||
private function addTask(Task $task, int $delay, int $period) : TaskHandler{
|
||||
if(!$this->enabled){
|
||||
throw new \InvalidStateException("Tried to schedule task to disabled scheduler");
|
||||
}
|
||||
@ -186,7 +186,7 @@ class TaskScheduler{
|
||||
/**
|
||||
* @param int $currentTick
|
||||
*/
|
||||
public function mainThreadHeartbeat(int $currentTick){
|
||||
public function mainThreadHeartbeat(int $currentTick) : void{
|
||||
$this->currentTick = $currentTick;
|
||||
while($this->isReady($this->currentTick)){
|
||||
/** @var TaskHandler $task */
|
||||
|
Reference in New Issue
Block a user