Modernize property type declarations

This commit is contained in:
Dylan K. Taylor
2022-06-04 18:16:32 +01:00
parent 23695fb900
commit 083a35f970
114 changed files with 431 additions and 863 deletions

View File

@ -42,9 +42,6 @@ use const PTHREADS_INHERIT_INI;
class AsyncPool{
private const WORKER_START_OPTIONS = PTHREADS_INHERIT_INI;
/** @var int */
protected $size;
/**
* @var \SplQueue[]|AsyncTask[][]
* @phpstan-var array<int, \SplQueue<AsyncTask>>
@ -69,14 +66,12 @@ class AsyncPool{
private array $workerStartHooks = [];
public function __construct(
int $size,
protected int $size,
private int $workerMemoryLimit,
private \ClassLoader $classLoader,
private \ThreadedLogger $logger,
private SleeperHandler $eventLoop
){
$this->size = $size;
}
){}
/**
* Returns the maximum size of the pool. Note that there may be less active workers than this number.

View File

@ -59,8 +59,7 @@ abstract class AsyncTask extends \Threaded{
/** @var AsyncWorker|null $worker */
public $worker = null;
/** @var \Threaded */
public $progressUpdates;
public \Threaded $progressUpdates;
private string|int|bool|null|float $result = null;
private bool $serialized = false;

View File

@ -27,34 +27,24 @@ use pocketmine\timings\Timings;
use pocketmine\timings\TimingsHandler;
class TaskHandler{
protected int $nextRun;
/** @var Task */
protected $task;
/** @var int */
protected $delay;
/** @var int */
protected $period;
/** @var int */
protected $nextRun;
/** @var bool */
protected $cancelled = false;
protected bool $cancelled = false;
private TimingsHandler $timings;
private string $taskName;
private string $ownerName;
public function __construct(Task $task, int $delay = -1, int $period = -1, ?string $ownerName = null){
public function __construct(
protected Task $task,
protected int $delay = -1,
protected int $period = -1,
?string $ownerName = null
){
if($task->getHandler() !== null){
throw new \InvalidArgumentException("Cannot assign multiple handlers to the same task");
}
$this->task = $task;
$this->delay = $delay;
$this->period = $period;
$this->taskName = $task->getName();
$this->ownerName = $ownerName ?? "Unknown";
$this->timings = Timings::getScheduledTaskTimings($this, $period);

View File

@ -33,20 +33,16 @@ use pocketmine\utils\ReversePriorityQueue;
class TaskScheduler{
private bool $enabled = true;
/**
* @var ReversePriorityQueue
* @phpstan-var ReversePriorityQueue<int, TaskHandler>
*/
protected $queue;
/** @phpstan-var ReversePriorityQueue<int, TaskHandler> */
protected ReversePriorityQueue $queue;
/**
* @var ObjectSet|TaskHandler[]
* @phpstan-var ObjectSet<TaskHandler>
*/
protected $tasks;
protected ObjectSet $tasks;
/** @var int */
protected $currentTick = 0;
protected int $currentTick = 0;
public function __construct(
private ?string $owner = null