mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-07 18:41:47 +00:00
Modernize private property declarations in src/timings
This commit is contained in:
parent
9de88aa734
commit
1d5430937f
@ -34,8 +34,7 @@ use function dechex;
|
|||||||
abstract class Timings{
|
abstract class Timings{
|
||||||
public const INCLUDED_BY_OTHER_TIMINGS_PREFIX = "** ";
|
public const INCLUDED_BY_OTHER_TIMINGS_PREFIX = "** ";
|
||||||
|
|
||||||
/** @var bool */
|
private static bool $initialized = false;
|
||||||
private static $initialized = false;
|
|
||||||
|
|
||||||
/** @var TimingsHandler */
|
/** @var TimingsHandler */
|
||||||
public static $fullTick;
|
public static $fullTick;
|
||||||
|
@ -29,10 +29,8 @@ use function count;
|
|||||||
use function hrtime;
|
use function hrtime;
|
||||||
|
|
||||||
class TimingsHandler{
|
class TimingsHandler{
|
||||||
/** @var bool */
|
private static bool $enabled = false;
|
||||||
private static $enabled = false;
|
private static int $timingStart = 0;
|
||||||
/** @var int */
|
|
||||||
private static $timingStart = 0;
|
|
||||||
|
|
||||||
/** @return string[] */
|
/** @return string[] */
|
||||||
public static function printTimings() : array{
|
public static function printTimings() : array{
|
||||||
@ -99,21 +97,13 @@ class TimingsHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var string */
|
private ?TimingsRecord $record = null;
|
||||||
private $name;
|
private int $timingDepth = 0;
|
||||||
/** @var TimingsHandler|null */
|
|
||||||
private $parent = null;
|
|
||||||
|
|
||||||
/** @var TimingsRecord|null */
|
public function __construct(
|
||||||
private $record = null;
|
private string $name,
|
||||||
|
private ?TimingsHandler $parent = null
|
||||||
/** @var int */
|
){}
|
||||||
private $timingDepth = 0;
|
|
||||||
|
|
||||||
public function __construct(string $name, ?TimingsHandler $parent = null){
|
|
||||||
$this->name = $name;
|
|
||||||
$this->parent = $parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName() : string{ return $this->name; }
|
public function getName() : string{ return $this->name; }
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ final class TimingsRecord{
|
|||||||
* @var self[]
|
* @var self[]
|
||||||
* @phpstan-var array<int, self>
|
* @phpstan-var array<int, self>
|
||||||
*/
|
*/
|
||||||
private static $records = [];
|
private static array $records = [];
|
||||||
|
|
||||||
public static function clearRecords() : void{
|
public static function clearRecords() : void{
|
||||||
foreach(self::$records as $record){
|
foreach(self::$records as $record){
|
||||||
@ -71,26 +71,18 @@ final class TimingsRecord{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var TimingsHandler */
|
private int $count = 0;
|
||||||
private $handler;
|
private int $curCount = 0;
|
||||||
|
private int $start = 0;
|
||||||
|
private int $totalTime = 0;
|
||||||
|
private int $curTickTotal = 0;
|
||||||
|
private int $violations = 0;
|
||||||
|
|
||||||
/** @var int */
|
public function __construct(
|
||||||
private $count = 0;
|
|
||||||
/** @var int */
|
|
||||||
private $curCount = 0;
|
|
||||||
/** @var int */
|
|
||||||
private $start = 0;
|
|
||||||
/** @var int */
|
|
||||||
private $totalTime = 0;
|
|
||||||
/** @var int */
|
|
||||||
private $curTickTotal = 0;
|
|
||||||
/** @var int */
|
|
||||||
private $violations = 0;
|
|
||||||
|
|
||||||
public function __construct(TimingsHandler $handler){
|
|
||||||
self::$records[spl_object_id($this)] = $this;
|
|
||||||
//I'm not the biggest fan of this cycle, but it seems to be the most effective way to avoid leaking anything.
|
//I'm not the biggest fan of this cycle, but it seems to be the most effective way to avoid leaking anything.
|
||||||
$this->handler = $handler;
|
private TimingsHandler $handler
|
||||||
|
){
|
||||||
|
self::$records[spl_object_id($this)] = $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() : string{ return $this->handler->getName(); }
|
public function getName() : string{ return $this->handler->getName(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user