mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
and more typehints
This commit is contained in:
@ -64,7 +64,7 @@ class Utils{
|
||||
*
|
||||
* @return UUID
|
||||
*/
|
||||
public static function getMachineUniqueId($extra = ""){
|
||||
public static function getMachineUniqueId(string $extra = "") : UUID{
|
||||
if(self::$serverUniqueId !== null and $extra === ""){
|
||||
return self::$serverUniqueId;
|
||||
}
|
||||
@ -188,7 +188,7 @@ class Utils{
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getOS($recalculate = false){
|
||||
public static function getOS(bool $recalculate = false) : string{
|
||||
if(self::$os === null or $recalculate){
|
||||
$uname = php_uname("s");
|
||||
if(stripos($uname, "Darwin") !== false){
|
||||
@ -215,8 +215,10 @@ class Utils{
|
||||
return self::$os;
|
||||
}
|
||||
|
||||
|
||||
public static function getRealMemoryUsage(){
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public static function getRealMemoryUsage() : array{
|
||||
$stack = 0;
|
||||
$heap = 0;
|
||||
|
||||
@ -279,7 +281,11 @@ class Utils{
|
||||
return count(ThreadManager::getInstance()->getAll()) + 3; //RakLib + MainLogger + Main Thread
|
||||
}
|
||||
|
||||
public static function getCoreCount($recalculate = false){
|
||||
/**
|
||||
* @param bool $recalculate
|
||||
* @return int
|
||||
*/
|
||||
public static function getCoreCount(bool $recalculate = false) : int{
|
||||
static $processors = 0;
|
||||
|
||||
if($processors > 0 and !$recalculate){
|
||||
@ -321,7 +327,7 @@ class Utils{
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function hexdump($bin){
|
||||
public static function hexdump(string $bin) : string{
|
||||
$output = "";
|
||||
$bin = str_split($bin, 16);
|
||||
foreach($bin as $counter => $line){
|
||||
@ -337,11 +343,11 @@ class Utils{
|
||||
/**
|
||||
* Returns a string that can be printed, replaces non-printable characters
|
||||
*
|
||||
* @param $str
|
||||
* @param mixed $str
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function printable($str){
|
||||
public static function printable($str) : string{
|
||||
if(!is_string($str)){
|
||||
return gettype($str);
|
||||
}
|
||||
@ -476,7 +482,7 @@ class Utils{
|
||||
}
|
||||
}
|
||||
|
||||
public static function javaStringHash($string){
|
||||
public static function javaStringHash(string $string) : int{
|
||||
$hash = 0;
|
||||
for($i = 0, $len = strlen($string); $i < $len; $i++){
|
||||
$ord = ord($string{$i});
|
||||
|
Reference in New Issue
Block a user