mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 22:15:30 +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);
|
||||
case 'linux':
|
||||
// Ubuntu / Debian.
|
||||
if(file_exists('/etc/timezone')){
|
||||
$data = file_get_contents('/etc/timezone');
|
||||
if($data !== false){
|
||||
return trim($data);
|
||||
}
|
||||
$data = @file_get_contents('/etc/timezone');
|
||||
if($data !== false){
|
||||
return trim($data);
|
||||
}
|
||||
|
||||
|
||||
// RHEL / CentOS
|
||||
if(file_exists('/etc/sysconfig/clock')){
|
||||
$data = parse_ini_file('/etc/sysconfig/clock');
|
||||
if($data !== false and isset($data['ZONE']) and is_string($data['ZONE'])){
|
||||
return trim($data['ZONE']);
|
||||
}
|
||||
$data = @parse_ini_file('/etc/sysconfig/clock');
|
||||
if($data !== false and isset($data['ZONE']) and is_string($data['ZONE'])){
|
||||
return trim($data['ZONE']);
|
||||
}
|
||||
|
||||
//Portable method for incompatible linux distributions.
|
||||
@ -175,12 +172,10 @@ abstract class Timezone{
|
||||
|
||||
return self::parseOffset($offset);
|
||||
case 'mac':
|
||||
if(is_link('/etc/localtime')){
|
||||
$filename = readlink('/etc/localtime');
|
||||
if(strpos($filename, '/usr/share/zoneinfo/') === 0){
|
||||
$timezone = substr($filename, 20);
|
||||
return trim($timezone);
|
||||
}
|
||||
$filename = @readlink('/etc/localtime');
|
||||
if($filename !== false and strpos($filename, '/usr/share/zoneinfo/') === 0){
|
||||
$timezone = substr($filename, 20);
|
||||
return trim($timezone);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -48,6 +48,12 @@ parameters:
|
||||
count: 1
|
||||
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
|
||||
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