fix(misc): phan

This commit is contained in:
2021-10-12 01:30:37 +09:00
parent e8a1d87919
commit eb1e1421ab
12 changed files with 858 additions and 867 deletions
+36 -30
View File
@@ -15,20 +15,34 @@ return [
// Note that the **only** effect of choosing `'5.6'` is to infer
// that functions removed in php 7.0 exist.
// (See `backward_compatibility_checks` for additional options)
"target_php_version" => '7.4',
"target_php_version" => '8.0',
'backward_compatibility_checks ' => true,
'minimum_severity'=>\Phan\Issue::SEVERITY_CRITICAL,
'minimum_severity' => \Phan\Issue::SEVERITY_NORMAL,
'file_list' => [
'f_config/config.php',
'hwe/_119_b.php',
'hwe/_119.php',
'hwe/a_bestGeneral.php',
'hwe/a_emperior.php',
'hwe/_admin1.php',
'hwe/_admin1_submit.php',
'hwe/_admin2.php',
'hwe/_admin2_submit.php',
'hwe/_admin4.php',
'hwe/_admin4_submit.php',
'hwe/_admin5.php',
'hwe/_admin5_submit.php',
'hwe/_admin7.php',
'hwe/_admin8.php',
'hwe/_admin_force_rehall.php',
'hwe/a_emperior_detail.php',
'hwe/a_emperior.php',
'hwe/a_genList.php',
'hwe/a_hallOfFame.php',
'hwe/a_history.php',
'hwe/a_kingdomList.php',
'hwe/a_npcList.php',
'hwe/api.php',
'hwe/a_status.php',
'hwe/a_traffic.php',
'hwe/a_vote.php',
@@ -41,13 +55,11 @@ return [
'hwe/b_dipcenter.php',
'hwe/b_diplomacy.php',
'hwe/b_genList.php',
'hwe/v_inheritPoint.php',
'hwe/b_myBossInfo.php',
'hwe/b_myCityInfo.php',
'hwe/b_myGenInfo.php',
'hwe/b_myKingdomInfo.php',
'hwe/b_myPage.php',
'hwe/b_npc_control.php',
'hwe/b_processing.php',
'hwe/b_tournament.php',
'hwe/b_troop.php',
@@ -55,7 +67,6 @@ return [
'hwe/c_dipcenter.php',
'hwe/c_tournament.php',
'hwe/c_vote.php',
'hwe/func.php',
'hwe/func_auction.php',
'hwe/func_command.php',
'hwe/func_converter.php',
@@ -64,16 +75,15 @@ return [
'hwe/func_legacy.php',
'hwe/func_map.php',
'hwe/func_message.php',
'hwe/func.php',
'hwe/func_process.php',
'hwe/func_string.php',
'hwe/func_template.php',
'hwe/func_time_event.php',
'hwe/func_tournament.php',
'hwe/index.php',
'hwe/install.php',
'hwe/install_db.php',
'hwe/join.php',
'hwe/join_post.php',
'hwe/install.php',
'hwe/j_adjust_icon.php',
'hwe/j_autoreset.php',
'hwe/j_basic_info.php',
@@ -92,8 +102,8 @@ return [
'hwe/j_general_log_old.php',
'hwe/j_general_set_permission.php',
'hwe/j_general_turn.php',
'hwe/j_getChiefTurn.php',
'hwe/j_get_basic_general_list.php',
'hwe/j_getChiefTurn.php',
'hwe/j_get_city_list.php',
'hwe/j_get_general_list.php',
'hwe/j_get_nation_general_list.php',
@@ -101,11 +111,12 @@ return [
'hwe/j_get_select_npc_token.php',
'hwe/j_get_select_pool.php',
'hwe/j_image_upload.php',
'hwe/j_install.php',
'hwe/j_install_db.php',
'hwe/j_install.php',
'hwe/j_load_scenarios.php',
'hwe/j_map.php',
'hwe/j_map_history.php',
'hwe/j_map.php',
'hwe/j_map_recent.php',
'hwe/j_msg_contact_list.php',
'hwe/j_msg_decide_opt.php',
'hwe/j_msg_delete.php',
@@ -123,26 +134,20 @@ return [
'hwe/j_set_npc_control.php',
'hwe/j_simulate_battle.php',
'hwe/j_troop.php',
'hwe/j_update_picked_general.php',
'hwe/j_vacation.php',
'hwe/lib.php',
'hwe/process_war.php',
'hwe/proc.php',
'hwe/readme.php',
'hwe/recent_map.php',
'hwe/select_general_from_pool.php',
'hwe/select_npc.php',
'hwe/t_board.php',
'hwe/t_diplomacy.php',
'hwe/_119.php',
'hwe/_119_b.php',
'hwe/_admin1.php',
'hwe/_admin1_submit.php',
'hwe/_admin2.php',
'hwe/_admin2_submit.php',
'hwe/_admin4.php',
'hwe/_admin4_submit.php',
'hwe/_admin5.php',
'hwe/_admin5_submit.php',
'hwe/_admin7.php',
'hwe/_admin8.php',
'hwe/_admin_force_rehall.php',
'hwe/v_board.php',
'hwe/v_inheritPoint.php',
'hwe/v_join.php',
'hwe/v_NPCControl.php',
],
// A list of directories that should be parsed for class and
@@ -153,9 +158,9 @@ return [
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
'hwe/d_setting',
'hwe/sammo',
'd_setting',
'hwe/d_setting',
'hwe/sammo',
'd_setting',
'src/sammo',
'src/kakao',
'vendor'
@@ -179,6 +184,7 @@ return [
'suppress_issue_types' => [
'PhanUnreferencedUseNormal',
'PhanTypeArraySuspiciousNullable',
],
// A list of plugin files to execute.
@@ -195,4 +201,4 @@ return [
'PregRegexCheckerPlugin',
'PrintfCheckerPlugin',
],
];
];
+1
View File
@@ -342,6 +342,7 @@ switch ($btn) {
}
break;
case "랜덤턴":
$turnterm = $gameStor->turnterm;
foreach ($genlist as $generalID) {
$turntime = getRandTurn($turnterm);
$db->update('general', [
@@ -17,6 +17,7 @@ class BuySpecificUnique extends \sammo\BaseAPI
{
public function validateArgs(): ?string
{
$availableItems = [];
foreach (GameConst::$allItems as $items) {
foreach ($items as $itemKey => $amount) {
if ($amount == 0) {
@@ -62,10 +62,10 @@ class ResetTurnTime extends \sammo\BaseAPI
$userLogger = new UserLogger($userID);
if($afterTurn >= 0){
$userLogger->push(sprintf("{$reqPoint} 포인트로 턴 시간을 바꾼 결과 %02d:%02d 뒤로 밀림", intdiv($afterTurn, 60), $afterTurn%60), "inheritPoint");
$userLogger->push(sprintf("{$reqPoint} 포인트로 턴 시간을 바꾼 결과 %02d:%02d 뒤로 밀림", intdiv(Util::toInt($afterTurn), 60), $afterTurn%60), "inheritPoint");
}
else{
$userLogger->push(sprintf("{$reqPoint} 포인트로 턴 시간을 바꾼 결과 %02d:%02d 앞으로 당김", intdiv(-$afterTurn, 60), (-$afterTurn)%60), "inheritPoint");
$userLogger->push(sprintf("{$reqPoint} 포인트로 턴 시간을 바꾼 결과 %02d:%02d 앞으로 당김", intdiv(Util::toInt(-$afterTurn), 60), (-$afterTurn)%60), "inheritPoint");
}
$userLogger->flush();
+5 -5
View File
@@ -3,9 +3,9 @@ namespace sammo;
class CityHelper{
//Just Helper
private static $list = null;
private static $listInv = null;
private static $listByNation = null;
private static ?array $list = null;
private static ?array $listInv = null;
private static ?array $listByNation = null;
private function __construct(){
@@ -25,7 +25,7 @@ class CityHelper{
'@phan-var array<int,mixed>|null $list';
'@phan-var array<string,mixed>|null $listInv';
'@phan-var array<int,mixed>|null $listByNation';
foreach (DB::db()->query('SELECT `city` as `id`, `name`, `level`, `nation` from city') as $city) {
$id = $city['id'];
$name = $city['name'];
@@ -83,5 +83,5 @@ class CityHelper{
return $city;
}
}
@@ -218,7 +218,7 @@ class che_물자원조 extends Command\NationCommand{
}
$josaRoSrc = JosaUtil::pick($nationName, '로');
$destNationLogger = new ActionLogger(0, $destChiefID, $year, $month);
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaRoSrc}부터 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원 받음");
$destNationStor = KVStorage::getStorage(DB::db(), $destNationID, 'nation_env');
+771 -789
View File
File diff suppressed because it is too large Load Diff
@@ -15,7 +15,7 @@ class che_도시치료 extends BaseGeneralTrigger{
/** @var \sammo\General $general */
$general = $this->object;
$logger = $general->getLogger();
if($general->getVar('injury') > 0){
$general->updateVar('injury', 0);
$general->activateSkill('pre.부상경감', 'pre.치료');
@@ -25,8 +25,8 @@ class che_도시치료 extends BaseGeneralTrigger{
$db = DB::db();
$patients = $db->queryAllLists(
'SELECT no,name,nation FROM general WHERE city=%i AND injury > 10 AND no != %i',
$general->getCityID(),
'SELECT no,name,nation FROM general WHERE city=%i AND injury > 10 AND no != %i',
$general->getCityID(),
$general->getID()
);
@@ -56,7 +56,7 @@ class che_도시치료 extends BaseGeneralTrigger{
return $env;
}
if(count($cureList) == 1){
$josaUl = JosaUtil::pick($curedPatientName, "");
$logger->pushGeneralActionLog("<C>의술</>을 펼쳐 도시의 장수 <Y>{$curedPatientName}</>{$josaUl} 치료합니다!", ActionLogger::PLAIN);
+8 -8
View File
@@ -86,7 +86,7 @@ class SpecialityHelper{
if($leadership > GameConst::$chiefStatMin){
$myCond |= self::STAT_LEADERSHIP;
}
if($strength >= $intel * 0.95 && $strength > GameConst::$chiefStatMin){
$myCond |= self::STAT_STRENGTH;
}
@@ -101,7 +101,7 @@ class SpecialityHelper{
}
if($strength < GameConst::$chiefStatMin){
$myCond |= self::STAT_NOT_STRENGTH;
}
}
if($intel < GameConst::$chiefStatMin){
$myCond |= self::STAT_NOT_INTEL;
}
@@ -118,7 +118,7 @@ class SpecialityHelper{
$myCond |= self::STAT_INTEL;
}
}
return $myCond;
}
@@ -179,7 +179,7 @@ class SpecialityHelper{
$specialObj = buildGeneralSpecialWarClass(GameConst::$defaultSpecialWar);
$result[GameConst::$defaultSpecialWar] = $specialObj;
}
foreach(GameConst::$availableSpecialWar as $specialID){
$specialObj = buildGeneralSpecialWarClass($specialID);
$result[$specialID] = $specialObj;
@@ -220,7 +220,7 @@ class SpecialityHelper{
if(in_array($specialID, $prevSpecials)){
continue;
}
if($weightType === static::WEIGHT_PERCENT){
$pAbs[$specialID] = $weight;
@@ -229,7 +229,7 @@ class SpecialityHelper{
$pRel[$specialID] = $weight;
}
}
if($pAbs){
if($pRel){
$pAbs[0] = max(0, 100 - array_sum($pAbs));
@@ -280,7 +280,7 @@ class SpecialityHelper{
if(in_array($specialID, $prevSpecials)){
continue;
}
if($cond & self::REQ_DEXTERITY){
$reqDex[$specialID] = $weight;
@@ -296,7 +296,7 @@ class SpecialityHelper{
if($reqDex){
return Util::choiceRandomUsingWeight($reqDex);
}
if($pAbs){
if($pRel){
$pAbs[0] = max(0, 100 - array_sum($pAbs));
+2 -2
View File
@@ -71,7 +71,7 @@ class APIHelper
[$lastModified, $etag] = $cacheResult;
if ($lastModified !== null) {
header("Last-Modified: " . gmdate("D, d M Y H:i:s", TimeUtil::DateTimeToSeconds($lastModified, true)) . " GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", Util::toInt(TimeUtil::DateTimeToSeconds($lastModified, true))) . " GMT");
}
if ($etag !== null) {
header("Etag: $etag");
@@ -97,7 +97,7 @@ class APIHelper
} catch (\Exception $e) {
Json::dieWithReason($e->getMessage());
} catch (mixed $e) {
Json::dieWithReason($e);
Json::dieWithReason(strval($e));
}
}
}
+1
View File
@@ -39,6 +39,7 @@ class Json
return json_decode($value);
}
/** @return never */
public static function die($value, $flag = self::NO_CACHE)
{
//NOTE: REST 형식에 맞게, ok(), fail()로 쪼개는게 낫지 않을까 생각해봄.
+26 -26
View File
@@ -156,7 +156,7 @@ class Util extends \utilphp\util
else{
$text = str_replace("_tK_{$key}_", $value, $text);
}
}
file_put_contents($destFilePath, $text);
@@ -182,7 +182,7 @@ class Util extends \utilphp\util
else{
$head[] = "class $newClassName extends $srcClassName";
}
$head[] = '{';
$head[] = '';
$head = join("\n", $head);
@@ -203,7 +203,7 @@ class Util extends \utilphp\util
}
$result = file_put_contents($destFilePath, $head.join("\n", $body).$tail, LOCK_EX);
assert($result);
return true;
}
@@ -281,12 +281,12 @@ class Util extends \utilphp\util
public static function convertArrayToDict($arr, $keyName)
{
$result = [];
foreach ($arr as $obj) {
$key = $obj[$keyName];
$result[$key] = $obj;
}
return $result;
}
@@ -309,7 +309,7 @@ class Util extends \utilphp\util
public static function convertDictToArray($dict, bool $withKey=true)
{
$result = [];
foreach($dict as $key=>$value){
if($withKey){
$result[] = [$key, $value];
@@ -318,7 +318,7 @@ class Util extends \utilphp\util
$result[] = $value;
}
}
return $result;
}
@@ -327,7 +327,7 @@ class Util extends \utilphp\util
foreach($dict as $dictKey=>$value){
$result[$dictKey] = $value[$key];
}
return $result;
}
@@ -354,7 +354,7 @@ class Util extends \utilphp\util
}
$idx = $key + 1;
}
return false;
}
@@ -368,20 +368,20 @@ class Util extends \utilphp\util
if ($dict === null) {
return null;
}
if (is_array($dict) && empty($dict)) {
return null;
}
if ($depth <= 0) {
return $dict;
}
foreach ($dict as $key=>$value) {
if ($value === null) {
unset($dict[$key]);
continue;
}
}
if (!Util::isDict($value)) {
continue;
}
@@ -393,7 +393,7 @@ class Util extends \utilphp\util
$dict[$key] = $newValue;
}
}
return $dict;
}
@@ -465,7 +465,7 @@ class Util extends \utilphp\util
return (float)$matches[1] / 100;
}
/**
* $min과 $max 사이의 값으로 교정
@@ -552,7 +552,7 @@ class Util extends \utilphp\util
/**
* 2중 배열에서 특정 키의 합
*
*
* @param array $array 배열. 1차원 배열 또는 2차원 배열
* @param int|string|null $key 2차원 배열에서 참조할 키.
* @return int|float 합계
@@ -570,14 +570,14 @@ class Util extends \utilphp\util
/**
* 특정 키를 가진 값으로 묶음
*
*
* @param array $array 배열. 1차원 배열 또는 2차원 배열
* @param int|string|null $key 2차원 배열에서 참조할 키.
* @return array
*/
public static function arrayGroupBy(array $array, $key, bool $preserveRowKey=false) {
$result = array();
if($preserveRowKey){
foreach($array as $rowKey=>$val) {
if(key_exists($key, $val)){
@@ -596,7 +596,7 @@ class Util extends \utilphp\util
}
}
}
return $result;
}
@@ -618,7 +618,7 @@ class Util extends \utilphp\util
*
* @param array $items 선택하고자 하는 배열
*
* @return int|float|string|object 선택된 value값.
* @return int|float|string|array|object 선택된 value값.
*/
public static function choiceRandom(array $items)
{
@@ -700,7 +700,7 @@ class Util extends \utilphp\util
else{
throw new \InvalidArgumentException('$lhs is not Traversable');
}
if($rhs instanceof \Traversable){
$rhsIter = new \IteratorIterator($rhs);
}
@@ -778,11 +778,11 @@ class Util extends \utilphp\util
/**
* Python 3의 range와 동일
* @param int $from
* @param null|int $to
* @param null|int $step
* @param int $from
* @param null|int $to
* @param null|int $step
* @return \Traversable
* @throws \InvalidArgumentException
* @throws \InvalidArgumentException
*/
public static function range(int $from, ?int $to=null, ?int $step=null):\Traversable{
if($to === null){
@@ -809,5 +809,5 @@ class Util extends \utilphp\util
}
}
}
};