From 43997b911703e154e8f147d93f2dad7bca890c81 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Mon, 9 May 2022 01:25:12 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20phan=20=EB=A9=94=EC=8B=9C=EC=A7=80?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EC=88=98=EC=A0=95=20-=20array?= =?UTF-8?q?=EC=97=90=20+=3D=EB=A5=BC=20phan=20=EC=95=8C=EC=95=84=EB=93=A3?= =?UTF-8?q?=EA=B8=B0=20=EC=89=BD=EA=B2=8C=20array=5Fmerge=EB=A1=9C=20-=20U?= =?UTF-8?q?til::array=5Fget=EC=9D=B4=20=EB=8D=94=20=EC=9D=B4=EC=83=81=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=EC=97=86=EC=9C=BC=EB=AF=80=EB=A1=9C=20null?= =?UTF-8?q?=20coalescing=20-=20array=EB=A1=9C=20tuple=EB=A5=98=EB=A5=BC=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8A=94=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=EC=97=90=20index=EB=A5=BC=20=ED=8F=AC=ED=95=A8=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD=20=20=20-=20php=20intel?= =?UTF-8?q?ephense=EC=97=90=EA=B2=8C=EB=8A=94=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EB=AC=B4=ED=9A=A8=20-=20getPost=20=EC=9D=BC=EB=B6=80=20?= =?UTF-8?q?=EA=B0=92=EC=97=90=20int=20=EC=A7=80=EC=A0=95=20-=20=EC=95=84?= =?UTF-8?q?=EC=9D=B4=ED=85=9C=EC=97=90=20id=20property=EB=A5=BC=20?= =?UTF-8?q?=EC=97=86=EC=95=B4=EC=9C=BC=EB=AF=80=EB=A1=9C=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0=20-=20enum?= =?UTF-8?q?=EC=9D=80=20array=20key=EB=A1=9C=20=EC=82=AC=EC=9A=A9=ED=95=A0?= =?UTF-8?q?=20=EC=88=98=20=EC=97=86=EC=9C=BC=EB=AF=80=EB=A1=9C=20\Ds\Map?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20-=20KakaoKey=20PhanRe?= =?UTF-8?q?defineClass=20=EC=97=90=EB=9F=AC=20=EC=9A=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/a_emperior_detail.php | 4 +- hwe/a_hallOfFame.php | 8 ++- hwe/func.php | 7 ++- hwe/func_map.php | 10 +-- hwe/func_tournament.php | 7 ++- hwe/j_select_npc.php | 1 + hwe/lib.php | 2 +- hwe/sammo/API/Global/GetConst.php | 1 + hwe/sammo/BaseItem.php | 4 -- hwe/sammo/BaseStatItem.php | 3 +- hwe/sammo/Betting.php | 8 ++- hwe/sammo/Command/General/che_징병.php | 6 +- hwe/sammo/Command/General/che_출병.php | 2 + hwe/sammo/Event/Action/RaiseInvader.php | 2 +- hwe/sammo/General.php | 4 +- hwe/sammo/GeneralAI.php | 30 ++++----- hwe/sammo/GeneralTrigger/che_도시치료.php | 6 ++ hwe/sammo/InheritancePointManager.php | 11 ++-- hwe/sammo/Scenario.php | 6 +- hwe/sammo/Scenario/Nation.php | 26 ++++---- src/kakao/Kakao_REST_API_Helper.php | 76 ++++++++++++----------- 21 files changed, 121 insertions(+), 103 deletions(-) diff --git a/hwe/a_emperior_detail.php b/hwe/a_emperior_detail.php index b0c059df..cba4f4d9 100644 --- a/hwe/a_emperior_detail.php +++ b/hwe/a_emperior_detail.php @@ -173,7 +173,7 @@ $serverID = $emperior['server_id'] ?? ($emperior['serverID'] ?? null); if (!$nation['nation'] ?? null) { continue; } - $nation += Json::decode($nation['data']); + $nation = array_merge(Json::decode($nation['data']), $nation); /** @var array $nation */ $nation['typeName'] = getNationType($nation['type']); @@ -201,7 +201,7 @@ $serverID = $emperior['server_id'] ?? ($emperior['serverID'] ?? null); } if (key_exists('aux', $nation) && !is_array($nation['aux'])) { - $nation += Json::decode($nation['aux']); + $nation = array_merge(Json::decode($nation['aux']), $nation); } echo $templates->render('oldNation', $nation); diff --git a/hwe/a_hallOfFame.php b/hwe/a_hallOfFame.php index 2de3968c..15f48b1f 100644 --- a/hwe/a_hallOfFame.php +++ b/hwe/a_hallOfFame.php @@ -110,7 +110,8 @@ if ($scenarioIdx && key_exists($scenarioIdx, $scenarioList[$seasonIdx] ?? [])) { $hallResult = array_map(function ($general) use ($typeValue, $ownerNameList) { $aux = Json::decode($general['aux']); - $general += $aux; + /** @var array $general */ + $general = array_merge($aux, $general); if (key_exists($general['owner'], $ownerNameList)) { $general['ownerName'] = $ownerNameList[$general['owner']]; @@ -118,10 +119,11 @@ if ($scenarioIdx && key_exists($scenarioIdx, $scenarioList[$seasonIdx] ?? [])) { if (!key_exists('bgColor', $general)) { if (!key_exists('color', $general)) { - $general['bgColor'] = GameConst::$basecolor4; + $color = GameConst::$basecolor4; } else { - $general['bgColor'] = $general['color']; + $color = $general['color']; } + $general['bgColor'] = $color; } if (!key_exists('fgColor', $general)) { diff --git a/hwe/func.php b/hwe/func.php index c72fcb7c..79f88d20 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -882,9 +882,9 @@ function generalInfo2(General $generalObj) "; } -function getOnlineNum() +function getOnlineNum(): int { - return KVStorage::getStorage(DB::db(), 'game_env')->online; + return KVStorage::getStorage(DB::db(), 'game_env')->getValue('online') ?? 0; } function onlinegen(General $general) @@ -1075,6 +1075,7 @@ function updateTraffic() $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); $admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']); + /** @var array{year:int,month:int,refresh:int,maxonline:int,maxrefresh:int} $admin */ //최다갱신자 $user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1'); @@ -2248,7 +2249,7 @@ function calcCityDistance(int $from, int $to, ?array $linkNationList): ?int * @param $from 기준 도시 코드 * @param $to 대상 도시 코드 * @param $linkNationList 경로에 해당하는 국가 리스트 - * @return array $dist=>[cityID, $nation] 배열 가장 앞이 가장 가까움 + * @return array $dist=>[cityID, $nation] 배열 가장 앞이 가장 가까움 */ function searchDistanceListToDest(int $from, int $to, array $linkNationList) { diff --git a/hwe/func_map.php b/hwe/func_map.php index 0c8f3214..225502cb 100644 --- a/hwe/func_map.php +++ b/hwe/func_map.php @@ -8,11 +8,11 @@ class MapRequest{ public $neutralView; public $showMe; function __construct($obj){ - $this->serverID = Util::array_get($obj['serverID'], null); - $this->year = Util::array_get($obj['year']); - $this->month = Util::array_get($obj['month']); - $this->aux = Util::array_get($obj['aux'],[]); - $this->neutralView = Util::array_get($obj['neutralView'], false); + $this->serverID = $obj['serverID'] ?? null; + $this->year = $obj['year'] ?? null; + $this->month = $obj['month'] ?? null; + $this->aux = $obj['aux'] ?? []; + $this->neutralView = $obj['neutralView'] ?? false; $this->showMe = $obj['showMe']; } } diff --git a/hwe/func_tournament.php b/hwe/func_tournament.php index e70eff95..5c4d9ecb 100644 --- a/hwe/func_tournament.php +++ b/hwe/func_tournament.php @@ -256,7 +256,7 @@ function getTournament(int $tnmt) ][$tnmt] ?? "TOURNAMENT_TYPE_ERR_{$tnmt}"; } -function printRow($k, $npc, $name, $abil, $tgame, $win, $draw, $lose, $gd, $gl, $prmt) +function printRow(int $k, int $npc, string $name, $abil, $tgame, $win, $draw, $lose, $gd, $gl, $prmt) { $k += 1; if ($prmt > 0) { @@ -588,7 +588,10 @@ function fillLowGenAll($tnmt_type) //7 8강 //8 4강 //9 결승 -function getTwo($tournament, $phase) +/** + * @return array{0:int,1:int} + */ +function getTwo(int $tournament, int $phase): array { $cand = []; switch ($tournament) { diff --git a/hwe/j_select_npc.php b/hwe/j_select_npc.php index e810f1dc..e77ebda4 100644 --- a/hwe/j_select_npc.php +++ b/hwe/j_select_npc.php @@ -6,6 +6,7 @@ include "func.php"; WebUtil::requireAJAX(); +/** @var int|null */ $pick = Util::getPost('pick', 'int'); if(!$pick){ diff --git a/hwe/lib.php b/hwe/lib.php index c276da27..776f7afb 100644 --- a/hwe/lib.php +++ b/hwe/lib.php @@ -18,7 +18,7 @@ $loader->addClassMap((function () { //디버그용 매크로 -ini_set("session.cache_expire", 10080); // minutes +ini_set("session.cache_expire", "10080"); // minutes ob_start(); diff --git a/hwe/sammo/API/Global/GetConst.php b/hwe/sammo/API/Global/GetConst.php index 72f6cd2c..00c98057 100644 --- a/hwe/sammo/API/Global/GetConst.php +++ b/hwe/sammo/API/Global/GetConst.php @@ -191,6 +191,7 @@ class GetConst extends \sammo\BaseAPI public function genConstData() { + /** @var array */ $gameConstKeys = [ 'nationType' => [ '\sammo\buildNationTypeClass', diff --git a/hwe/sammo/BaseItem.php b/hwe/sammo/BaseItem.php index e03988ea..16959a66 100644 --- a/hwe/sammo/BaseItem.php +++ b/hwe/sammo/BaseItem.php @@ -15,10 +15,6 @@ class BaseItem implements iAction{ protected $buyable = false; protected $reqSecu = 0; - function getID(){ - return $this->id; - } - function getRawName(){ return $this->rawName; } diff --git a/hwe/sammo/BaseStatItem.php b/hwe/sammo/BaseStatItem.php index f808ecae..aa0bb65b 100644 --- a/hwe/sammo/BaseStatItem.php +++ b/hwe/sammo/BaseStatItem.php @@ -12,7 +12,7 @@ class BaseStatItem extends BaseItem{ protected $rawName = '노기'; protected $consumable = false; protected $buyable = true; - + protected const ITEM_TYPE = [ '명마'=>['통솔', 'leadership'], '무기'=>['무력', 'strength'], @@ -27,7 +27,6 @@ class BaseStatItem extends BaseItem{ $this->rawName = $nameTokens[$tokenLen-1]; [$this->statNick, $this->statType] = static::ITEM_TYPE[$nameTokens[$tokenLen-3]]; - $this->id = $this->statValue; $this->name = sprintf('%s(+%d)',$this->rawName, $this->statValue); $this->info = sprintf('%s +%d', $this->statNick, $this->statValue); } diff --git a/hwe/sammo/Betting.php b/hwe/sammo/Betting.php index a56c55c3..0cf8c44a 100644 --- a/hwe/sammo/Betting.php +++ b/hwe/sammo/Betting.php @@ -2,6 +2,7 @@ namespace sammo; +use Ds\Map; use sammo\DTO\BettingInfo; use sammo\DTO\BettingItem; use sammo\Enums\RankColumn; @@ -346,12 +347,13 @@ class Betting $db = DB::db(); if ($this->info->reqInheritancePoint) { - /** @var UserLogger[] */ - $loggers = []; + /** @var Map */ + $loggers = new Map(); foreach ($rewardList as $rewardItem) { if ($rewardItem['userID'] === null) { continue; } + /** @var int */ $userID = $rewardItem['userID']; $amount = $rewardItem['amount']; @@ -373,7 +375,7 @@ class Betting $partialText = "베팅 부분 당첨({$matchPoint}/{$selectCnt})"; } - if (key_exists($userID, $loggers)) { + if ($loggers->hasKey($userID)) { $userLogger = $loggers[$userID]; } else { $userLogger = new UserLogger($userID); diff --git a/hwe/sammo/Command/General/che_징병.php b/hwe/sammo/Command/General/che_징병.php index b548d778..b2d56703 100644 --- a/hwe/sammo/Command/General/che_징병.php +++ b/hwe/sammo/Command/General/che_징병.php @@ -15,8 +15,7 @@ use function \sammo\getTechAbil; use function sammo\getTechLevel; use \sammo\Constraint\ConstraintHelper; - - +use sammo\MustNotBeReachedException; class che_징병 extends Command\GeneralCommand { @@ -98,6 +97,9 @@ class che_징병 extends Command\GeneralCommand $maxCrew = $leadership * 100; $reqCrewType = GameUnitConst::byID($this->arg['crewType']); + if($reqCrewType === null){ + throw new MustNotBeReachedException(); + } if ($reqCrewType->id == $currCrewType->id) { $maxCrew -= $general->getVar('crew'); } diff --git a/hwe/sammo/Command/General/che_출병.php b/hwe/sammo/Command/General/che_출병.php index ed11f24f..ccfa306b 100644 --- a/hwe/sammo/Command/General/che_출병.php +++ b/hwe/sammo/Command/General/che_출병.php @@ -158,6 +158,8 @@ class che_출병 extends Command\GeneralCommand $candidateCities = []; + $currDist = 999; + $minDist = Util::array_first_key($distanceList); do { //1: 최단 거리 도시 중 공격 대상이 있는가 확인 diff --git a/hwe/sammo/Event/Action/RaiseInvader.php b/hwe/sammo/Event/Action/RaiseInvader.php index c7252f0c..a4849868 100644 --- a/hwe/sammo/Event/Action/RaiseInvader.php +++ b/hwe/sammo/Event/Action/RaiseInvader.php @@ -165,7 +165,7 @@ class RaiseInvader extends \sammo\Event\Action ->setNPCType(9) ->setStat(Util::toInt($specAvg * 1.8), Util::toInt($specAvg * 1.8), Util::toInt($specAvg * 1.2)) ->setAffinity(999) - ->setExpDed($exp * 1.2, null) + ->setExpDed(Util::toInt($exp * 1.2), null) ->setGoldRice(99999, 99999); $ruler->build($env); diff --git a/hwe/sammo/General.php b/hwe/sammo/General.php index 8e935b34..91adbcdb 100644 --- a/hwe/sammo/General.php +++ b/hwe/sammo/General.php @@ -415,7 +415,7 @@ class General implements iAction * @param bool $withStatAdjust 능력치간 보정 사용 여부 * @param bool $useFloor 내림 사용 여부, false시 float 값을 반환할 수도 있음 * - * @return int|float 계산된 능력치 + * @return float 계산된 능력치 */ protected function getStatValue(string $statName, $withInjury = true, $withIActionObj = true, $withStatAdjust = true, $useFloor = true): float @@ -1130,7 +1130,7 @@ class General implements iAction /** * @param ?int[] $generalIDList - * @param null|string|RankColumn[] $column + * @param null|array $column * @param int $constructMode * @return \sammo\General[] * @throws MustNotBeReachedException diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php index 8f42d2bf..e666b61b 100644 --- a/hwe/sammo/GeneralAI.php +++ b/hwe/sammo/GeneralAI.php @@ -11,12 +11,9 @@ class GeneralAI { /** @var General */ protected $general; - /** @var array */ - protected $city; - /** @var array */ - protected $nation; - /** @var int */ - protected $genType; + protected array $city; + protected array $nation; + protected int $genType; /** @var AutorunGeneralPolicy */ protected $generalPolicy; @@ -90,13 +87,12 @@ class GeneralAI $this->env = $gameStor->getAll(true); $this->baseDevelCost = $this->env['develcost'] * 12; $this->general = $general; - if ($general->getRawCity() === null) { + $city = $general->getRawCity(); + if ($city === null) { $city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID()); $general->setRawCity($city); - $this->city = $city; - } else { - $this->city = $general->getRawCity(); } + $this->city = $city; $this->nation = $db->queryFirstRow( 'SELECT nation,name,color,capital,capset,gennum,gold,rice,bill,rate,rate_tmp,scout,war,strategic_cmd_limit,surlimit,tech,power,level,chief_set,type,aux FROM nation WHERE nation = %i', @@ -866,7 +862,7 @@ class GeneralAI $userGenerals = $this->userCivilGenerals; if (in_array($this->dipState, [self::d평화, self::d선포])) { - $userGenerals += $this->userWarGenerals; + $userGenerals = array_merge($this->userWarGenerals, $userGenerals); } $generalCandidates = []; @@ -1142,7 +1138,7 @@ class GeneralAI $npcGenerals = $this->npcCivilGenerals; if (in_array($this->dipState, [self::d평화, self::d선포])) { - $npcGenerals += $this->npcWarGenerals; + $npcGenerals = array_merge($this->npcWarGenerals, $npcGenerals); } $generalCandidates = []; @@ -3826,16 +3822,23 @@ class GeneralAI $picked = false; + + /** @var General|null */ + $randGeneral = null; foreach (Util::range(5) as $idx) { /** @var General */ if ($this->npcWarGenerals) { + /** @var General */ $randGeneral = Util::choiceRandom($this->npcWarGenerals); } else if ($this->npcCivilGenerals) { + /** @var General */ $randGeneral = Util::choiceRandom($this->npcCivilGenerals); } else if ($this->userWarGenerals) { + /** @var General */ $randGeneral = Util::choiceRandom($this->userWarGenerals); } else if ($this->userCivilGenerals) { + /** @var General */ $randGeneral = Util::choiceRandom($this->userCivilGenerals); } else { break; @@ -3863,11 +3866,10 @@ class GeneralAI break; } - if (!$picked || !$randGeneral) { + if (!$picked || $randGeneral === null) { continue; } - /** @var General $randGeneral */ $randGeneral->setVar('officer_level', $chiefLevel); $randGeneral->setVar('officer_city', 0); $randGeneral->applyDB($db); diff --git a/hwe/sammo/GeneralTrigger/che_도시치료.php b/hwe/sammo/GeneralTrigger/che_도시치료.php index 956942b5..025b5352 100644 --- a/hwe/sammo/GeneralTrigger/che_도시치료.php +++ b/hwe/sammo/GeneralTrigger/che_도시치료.php @@ -24,6 +24,7 @@ class che_도시치료 extends BaseGeneralTrigger{ $db = DB::db(); + /** @var array{int,string,string}[] $patients */ $patients = $db->queryAllLists( 'SELECT no,name,nation FROM general WHERE city=%i AND injury > 10 AND no != %i', $general->getCityID(), @@ -39,6 +40,7 @@ class che_도시치료 extends BaseGeneralTrigger{ $cureList = []; + /** @var string|null */ $curedPatientName = null; foreach($patients as [$patientID, $patientName, $patientNationID]){ if (!Util::randBool(0.5)) { @@ -56,6 +58,10 @@ class che_도시치료 extends BaseGeneralTrigger{ return $env; } + if($curedPatientName === null){ + throw new \sammo\MustNotBeReachedException(); + } + if(count($cureList) == 1){ $josaUl = JosaUtil::pick($curedPatientName, "을"); diff --git a/hwe/sammo/InheritancePointManager.php b/hwe/sammo/InheritancePointManager.php index 716405e5..80647e22 100644 --- a/hwe/sammo/InheritancePointManager.php +++ b/hwe/sammo/InheritancePointManager.php @@ -285,14 +285,13 @@ class InheritancePointManager } //FIXME: 굳이 merge, apply, clean 3단계를 거쳐야 할 이유가 없음 - /** @var array[InheritanceKey]float */ - $rebirthDegraded = [ - InheritanceKey::dex => 0.5, - ]; + /** @var Map */ + $rebirthDegraded = new Map(); + $rebirthDegraded[InheritanceKey::dex] = 0.5; $inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}"); $totalPoint = 0; - /** @var array[InheritanceKey][float, string|float] */ + /** @var array */ $allPoints = $inheritStor->getAll(); if (!$allPoints || count($allPoints) == 0) { //비었으므로 리셋 안함 @@ -309,7 +308,7 @@ class InheritancePointManager foreach ($allPoints as $rKey => [$value,]) { $key = InheritanceKey::from($rKey); - if ($isRebirth && key_exists($key, $rebirthDegraded)) { + if ($isRebirth && $rebirthDegraded->hasKey($key)) { $value *= $rebirthDegraded[$key]; } $keyText = $this->getInheritancePointType($key)->info; diff --git a/hwe/sammo/Scenario.php b/hwe/sammo/Scenario.php index 00578c40..48268e16 100644 --- a/hwe/sammo/Scenario.php +++ b/hwe/sammo/Scenario.php @@ -375,9 +375,9 @@ class Scenario{ 'npcNeutral_cnt'=>count($this->getNPCneutral()), 'nation'=>array_map(function($nation) use ($nationGeneralCnt, $nationGeneralExCnt, $nationGeneralNeutralCnt){ $brief = $nation->getBrief(); - $brief['generals'] = Util::array_get($nationGeneralCnt[$nation->getID()], 0); - $brief['generalsEx'] = Util::array_get($nationGeneralExCnt[$nation->getID()], 0); - $brief['generalsNeutral'] = Util::array_get($nationGeneralNeutralCnt[$nation->getID()], 0); + $brief['generals'] = $nationGeneralCnt[$nation->getID()] ?? 0; + $brief['generalsEx'] = $nationGeneralExCnt[$nation->getID()] ?? 0; + $brief['generalsNeutral'] = $nationGeneralNeutralCnt[$nation->getID()] ?? 0; return $brief; },$this->getNation()) diff --git a/hwe/sammo/Scenario/Nation.php b/hwe/sammo/Scenario/Nation.php index 4ddfc83a..b6f74c76 100644 --- a/hwe/sammo/Scenario/Nation.php +++ b/hwe/sammo/Scenario/Nation.php @@ -25,15 +25,15 @@ class Nation{ private $generals = []; public function __construct( - int $id = null, - string $name = '국가', - string $color = '#000000', - int $gold = 0, - int $rice = 2000, - string $infoText = '국가 설명', - int $tech = 0, - ?string $type = null, - int $nationLevel = 0, + int $id = null, + string $name = '국가', + string $color = '#000000', + int $gold = 0, + int $rice = 2000, + string $infoText = '국가 설명', + int $tech = 0, + ?string $type = null, + int $nationLevel = 0, array $cities = [] ){ $this->id = $id; @@ -47,7 +47,7 @@ class Nation{ $this->nationLevel = $nationLevel; $this->cities = $cities; - if(count($cities)){ + if(count($this->cities)){ $this->capital = $this->cities[0]; } } @@ -75,7 +75,7 @@ class Nation{ else{ $capital = 0; } - + if($this->type === null){ $type = Util::choiceRandom(GameConst::$availableNationType); } @@ -126,7 +126,7 @@ class Nation{ $nationStor->scout_msg = $this->infoText; - + $diplomacy = []; foreach($otherNations as $nation){ $diplomacy[] = [ @@ -143,7 +143,7 @@ class Nation{ if(count($diplomacy) > 0){ $db->insert('diplomacy', $diplomacy); } - + } public function addGeneral(GeneralBuilder $general){ diff --git a/src/kakao/Kakao_REST_API_Helper.php b/src/kakao/Kakao_REST_API_Helper.php index bd32a89f..ed2b09d5 100644 --- a/src/kakao/Kakao_REST_API_Helper.php +++ b/src/kakao/Kakao_REST_API_Helper.php @@ -1,14 +1,16 @@ AUTHORIZATION_CODE = $authorization_code; $params = [ - 'grant_type'=>'authorization_code', - 'client_id'=>$this->REST_KEY, - 'redirect_uri'=>$this->REDIRECT_URI, - 'code'=>$this->AUTHORIZATION_CODE - ]; + 'grant_type' => 'authorization_code', + 'client_id' => $this->REST_KEY, + 'redirect_uri' => $this->REDIRECT_URI, + 'code' => $this->AUTHORIZATION_CODE + ]; $result = $this->_create_or_refresh_access_token($params); - + return $result; } public function refresh_access_token($refresh_token) { $params = [ - 'grant_type'=>'refresh_token', - 'client_id'=>$this->REST_KEY, - 'refresh_token'=>$refresh_token - ]; + 'grant_type' => 'refresh_token', + 'client_id' => $this->REST_KEY, + 'refresh_token' => $refresh_token + ]; $result = $this->_create_or_refresh_access_token($params); - + return $result; } @@ -212,11 +214,11 @@ class Kakao_REST_API_Helper public function meWithEmail() { $params = [ - 'property_keys'=>'['. - '"id",'. - '"kakao_account.has_email","kakao_account.email",'. - '"kakao_account.is_email_valid","kakao_account.is_email_verified"'. - ']' + 'property_keys' => '[' . + '"id",' . + '"kakao_account.has_email","kakao_account.email",' . + '"kakao_account.is_email_valid","kakao_account.is_email_verified"' . + ']' ]; return $this->request(User_Management_Path::$ME); } @@ -257,8 +259,8 @@ class Kakao_REST_API_Helper public function talk_to_me_default($req) { $params = [ - 'template_object' => json_encode($req) - ]; + 'template_object' => json_encode($req) + ]; return $this->request(Talk_Path::$TALK_TO_ME_DEFAULT, $params, 'POST'); } @@ -269,7 +271,7 @@ class Kakao_REST_API_Helper private $REST_KEY = KakaoKey::REST_KEY; // 디벨로퍼스의 앱 설정에서 확인할 수 있습니다. - private $REDIRECT_URI = KakaoKey::REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri - private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code - private $REFRESH_TOKEN = ''; + private $REDIRECT_URI = KakaoKey::REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri + private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code + private $REFRESH_TOKEN = ''; }