mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 22:45:28 +00:00
Timezone: use false checks instead of file existing for static analysis
This commit is contained in:
parent
83c40f4502
commit
5c9419b55c
@ -150,19 +150,16 @@ abstract class Timezone{
|
|||||||
return self::parseOffset($offset);
|
return self::parseOffset($offset);
|
||||||
case 'linux':
|
case 'linux':
|
||||||
// Ubuntu / Debian.
|
// Ubuntu / Debian.
|
||||||
if(file_exists('/etc/timezone')){
|
$data = @file_get_contents('/etc/timezone');
|
||||||
$data = file_get_contents('/etc/timezone');
|
if($data !== false){
|
||||||
if($data !== false){
|
return trim($data);
|
||||||
return trim($data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// RHEL / CentOS
|
// RHEL / CentOS
|
||||||
if(file_exists('/etc/sysconfig/clock')){
|
$data = @parse_ini_file('/etc/sysconfig/clock');
|
||||||
$data = parse_ini_file('/etc/sysconfig/clock');
|
if($data !== false and isset($data['ZONE']) and is_string($data['ZONE'])){
|
||||||
if($data !== false and isset($data['ZONE']) and is_string($data['ZONE'])){
|
return trim($data['ZONE']);
|
||||||
return trim($data['ZONE']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Portable method for incompatible linux distributions.
|
//Portable method for incompatible linux distributions.
|
||||||
@ -175,12 +172,10 @@ abstract class Timezone{
|
|||||||
|
|
||||||
return self::parseOffset($offset);
|
return self::parseOffset($offset);
|
||||||
case 'mac':
|
case 'mac':
|
||||||
if(is_link('/etc/localtime')){
|
$filename = @readlink('/etc/localtime');
|
||||||
$filename = readlink('/etc/localtime');
|
if($filename !== false and strpos($filename, '/usr/share/zoneinfo/') === 0){
|
||||||
if(strpos($filename, '/usr/share/zoneinfo/') === 0){
|
$timezone = substr($filename, 20);
|
||||||
$timezone = substr($filename, 20);
|
return trim($timezone);
|
||||||
return trim($timezone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -48,6 +48,12 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/pocketmine/network/mcpe/protocol/DataPacket.php
|
path: ../../../src/pocketmine/network/mcpe/protocol/DataPacket.php
|
||||||
|
|
||||||
|
-
|
||||||
|
#readlink() can return false but phpstan doesn't know this
|
||||||
|
message: "#^Strict comparison using \\!\\=\\= between string and false will always evaluate to true\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: ../../../src/pocketmine/utils/Timezone.php
|
||||||
|
|
||||||
-
|
-
|
||||||
#phpstan doesn't understand that SplFixedArray may contain null
|
#phpstan doesn't understand that SplFixedArray may contain null
|
||||||
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotNull\\(\\) with int and string will always evaluate to true\\.$#"
|
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotNull\\(\\) with int and string will always evaluate to true\\.$#"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user