fix(misc): phan

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