Modernize private property declarations in src/timings

This commit is contained in:
Dylan K. Taylor 2022-05-17 21:54:45 +01:00
parent 9de88aa734
commit 1d5430937f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 20 additions and 39 deletions

View File

@ -34,8 +34,7 @@ use function dechex;
abstract class Timings{
public const INCLUDED_BY_OTHER_TIMINGS_PREFIX = "** ";
/** @var bool */
private static $initialized = false;
private static bool $initialized = false;
/** @var TimingsHandler */
public static $fullTick;

View File

@ -29,10 +29,8 @@ use function count;
use function hrtime;
class TimingsHandler{
/** @var bool */
private static $enabled = false;
/** @var int */
private static $timingStart = 0;
private static bool $enabled = false;
private static int $timingStart = 0;
/** @return string[] */
public static function printTimings() : array{
@ -99,21 +97,13 @@ class TimingsHandler{
}
}
/** @var string */
private $name;
/** @var TimingsHandler|null */
private $parent = null;
private ?TimingsRecord $record = null;
private int $timingDepth = 0;
/** @var TimingsRecord|null */
private $record = null;
/** @var int */
private $timingDepth = 0;
public function __construct(string $name, ?TimingsHandler $parent = null){
$this->name = $name;
$this->parent = $parent;
}
public function __construct(
private string $name,
private ?TimingsHandler $parent = null
){}
public function getName() : string{ return $this->name; }

View File

@ -36,7 +36,7 @@ final class TimingsRecord{
* @var self[]
* @phpstan-var array<int, self>
*/
private static $records = [];
private static array $records = [];
public static function clearRecords() : void{
foreach(self::$records as $record){
@ -71,26 +71,18 @@ final class TimingsRecord{
}
}
/** @var TimingsHandler */
private $handler;
private int $count = 0;
private int $curCount = 0;
private int $start = 0;
private int $totalTime = 0;
private int $curTickTotal = 0;
private int $violations = 0;
/** @var int */
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;
public function __construct(
//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(); }