Commit 3dc041af authored by luhongguang's avatar luhongguang

update: 处理冲突

parents 4a77886f 9963de73
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 1:44 下午
*/
namespace App\Models\wx\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class WxGroupChat extends MysqlBase
{
const TABLE_NAME = 'wx_group_chat';
const CONFIG_INDEX = 'goods';
const PRIMARY_KEY = 'id';
public static function getRecords($where, $columns = []): array
{
if (empty($columns)) {
$columns = '*';
}
return (array)self::select($columns, $where);
}
public static function updateRecord($colums, $where)
{
return self::update($colums, $where);
}
public static function save($data, $where = [])
{
if (empty($where)) {
return self::insert($data);
}
return self::update($data, $where);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 1:45 下午
*/
namespace App\Models\wx\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class WxGroupChatUser extends MysqlBase
{
const TABLE_NAME = 'wx_group_chat_user';
const CONFIG_INDEX = 'goods';
const PRIMARY_KEY = 'id';
const STATUS_LEAVE = 0; // 状态: 退出群聊
const STATUS_NORMAL = 1; // 状态:正常
public static function getRecords($where, $columns = []): array
{
if (empty($columns)) {
$columns = '*';
}
return (array)self::select($columns, $where);
}
public static function updateRecord($columns, $where)
{
return self::update($columns, $where);
}
public static function save($data, $where = [])
{
if (empty($where)) {
return self::insert($data);
}
return self::update($data, $where);
}
}
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/9/27 8:18 下午
*/
use App\Base\Job;
use App\Services\wx\GroupChatService;
class WxgroupchatController extends Job
{
public function indexAction()
{
(new GroupChatService)->process();
}
}
\ No newline at end of file
......@@ -26,6 +26,7 @@ use App\Models\goods\mysql\LifeAccountShopNum;
use App\Models\goods\mysql\Ota;
use App\Models\goods\mysql\PaySuccessGoodsCallbackRecord;
use App\Models\goods\mysql\ErshouGoodsSku;
use App\Models\goods\mysql\PindanGoodsSku;
use App\Models\goods\mysql\PindanGoodsSnapshot;
use App\Models\goods\mysql\Shop;
use App\Models\marketing\mysql\Distributor;
......@@ -218,4 +219,35 @@ class ErshouGoodsService
GoodsService::addGoodsSkuPicRecord($skuId, $skuData);
return $skuId;
}
/**
* 二手商品商品详情
* @param $params
* @return array
* @throws GoodsException
*/
public static function ershouGoodsInfo($params)
{
$data = [];
$sku = ErshouGoodsSku::get("*", ["goods_sku_id" => $params["goods_sku_id"]]);
if (empty($sku)) {
throw new GoodsException(["cus" => 15]);
}
$data["goods_info"] = $sku;
$data["goods_info"]["original_price"] = empty($sku["original_price"]) ? '' : (string)($sku["original_price"] / 100);
$data["goods_info"]["price"] = $sku["price"] / 100;
$data["goods_info"]["desc_pic_url_list"] = [];
if (!empty($sku["desc_pic_url"])) {
$ksyun = GoodsService::getUrlList($sku["desc_pic_url"]);
$data["goods_info"]["desc_pic_url_list"] = $ksyun;
$strList = explode(",", $sku["desc_pic_url"]);
$shareStr = $strList[0];
$shareRes = Ks3Api::picEncryptUrl($shareStr, 500, 400);
$shareUrl = empty($shareRes["response"]["data"]["url"]) ? "" : $shareRes["response"]["data"]["url"];
$data["goods_info"]["share_url"] = $shareUrl;
}
return $data;
}
}
\ No newline at end of file
......@@ -1127,16 +1127,16 @@ class GoodsService
{
$goodsSukParams = GoodsSkuId::getGoodsSkuIdParams($params["goods_sku_id"]);
if (!empty($goodsSukParams)) {
if (isset($goodsSukParams["table_tag"]) && ($goodsSukParams["table_tag"] == GoodsSkuId::TABLE_TAG_PINDAN
|| $goodsSukParams["category_1_id"] == "00")) {
if (isset($goodsSukParams["table_tag"]) && ($goodsSukParams["table_tag"] == GoodsSkuId::TABLE_TAG_PINDAN)) {
return MarketingPindanGoodsService::pindanGoodsInfo($params);
} elseif(isset($goodsSukParams["table_tag"]) && ($goodsSukParams["table_tag"] == GoodsSkuId::TABLE_TAG_ERSHOU)) {
return ErshouGoodsService::ershouGoodsInfo($params);
} else {
return self::generalGoodsInfo($params);
}
} else {
throw new GoodsException(["cus" => 41]);
}
}
/**
......
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 10:57 上午
*/
namespace App\Services\wx;
use Api\PhpUtils\EasyWechat\AppConfig;
use Exception;
use EasyWeChat\Factory;
use Api\PhpUtils\Log\JobLog;
use App\Models\wx\mysql\WxGroupChat;
use App\Models\wx\mysql\WxGroupChatUser;
class GroupChatService
{
public $wxApp;
public $pageSize = 100;
public $ownerUserIds = [];
public $departmentId; // 部门id
/**
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
*/
public function __construct()
{
$this->wxApp = Factory::work(AppConfig::getCorpConfig());
$this->loadConfig();
}
/**
* Notes: 处理微信群
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 7:36 下午
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function process()
{
$nextCursor = ''; // 下一页游标,首次为空,请求接口会返回
while (true) {
$result = $this->getGroupChatList($nextCursor);
if (empty($result['group_chat_list'])) {
break;
}
$groupChatList = $result['group_chat_list'];
$existChatIds = $this->getWxGroupChatIds(array_column($groupChatList, 'chat_id'));
foreach ($groupChatList as $group) {
try {
$groupChat = $this->getGroupChatDetail($group['chat_id']);
$chatInfo = $this->getFormatGroupChat($group, $groupChat);
$this->processGroupChat($existChatIds, $chatInfo);
if (!empty($groupChat['group_chat']['member_list'])) {
$this->processGroupChatUser($group['chat_id'], $groupChat['group_chat']['member_list']);
}
$this->loggerInfo("处理成功:chat_id={$group['chat_id']},name={$chatInfo['name']},memberCount=" . count($groupChat['group_chat']['member_list']));
} catch (Exception $e) {
$this->loggerError("处理失败:chat_id={$group['chat_id']},msg=" . $e->getMessage() . ',code=' . $e->getCode() . ',line=' . $e->getLine());
}
}
if (empty($result['next_cursor'])) {
break;
}
$nextCursor = $result['next_cursor'];
}
}
/**
* Notes: 处理群
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 3:04 下午
* @param $existChatIds
* @param $groupChat
*/
private function processGroupChat($existChatIds, $groupChat)
{
$where = [];
if (isset($existChatIds[$groupChat['chat_id']])) {
$where = ['chat_id' => $groupChat['chat_id']];
}
WxGroupChat::save($groupChat, $where);
}
/**
* Notes: 处理群成员
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 3:19 下午
* @param $chatId
* @param $memberList
*/
private function processGroupChatUser($chatId, $memberList)
{
$insertMember = [];
$existUserIds = $this->getWxGroupChatUserIds($chatId, array_column($memberList, 'userid'));
// 重置将该群成员状态
WxGroupChatUser::updateRecord(
['status' => WxGroupChatUser::STATUS_LEAVE],
['chat_id' => $chatId, 'status' => WxGroupChatUser::STATUS_NORMAL]
);
foreach ($memberList as $member) {
$member = $this->getFormatGroupChatUser($chatId, $member);
if (isset($existUserIds[$member['user_id']])) {
WxGroupChatUser::save($member, ['chat_id' => $member['chat_id'], 'user_id' => $member['user_id']]);
} else {
$insertMember[] = $member;
}
}
if (!empty($insertMember)) {
WxGroupChatUser::save($insertMember);
}
}
/**
* Notes: 获取组装群组成员数据
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 3:20 下午
* @param $chatId
* @param $member
* @return array
*/
private function getFormatGroupChatUser($chatId, $member): array
{
return [
'chat_id' => $chatId,
'user_id' => $member['userid'],
'name' => $member['name'] ?? '',
'status' => WxGroupChatUser::STATUS_NORMAL,
'type' => $member['type'],
'join_time' => $member['join_time'],
'join_scene' => $member['join_scene'],
'invitor_user_id' => !empty($member['invitor']['user_id']) ? $member['invitor']['user_id'] : '',
'group_nickname' => $member['group_nickname'] ?? ''
];
}
/**
* Notes: 获取组装群组数据
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 3:10 下午
* @param $group
* @param $groupDetail
* @return array
*/
private function getFormatGroupChat($group, $groupDetail): array
{
$groupChatInfo = $groupDetail['group_chat'];
return [
'chat_id' => $groupChatInfo['chat_id'],
'name' => $groupChatInfo['name'],
'notice' => $groupChatInfo['notice'] ?? '',
'owner' => $groupChatInfo['owner'] ?? '',
'status' => $group['status'],
'chat_create_time' => $groupChatInfo['create_time'],
];
}
/**
* Notes: 获取群id
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 3:03 下午
* @param $chatIds
* @return array
*/
private function getWxGroupChatIds($chatIds): array
{
$chatList = WxGroupChat::getRecords(['chat_id' => $chatIds], ['chat_id']);
return !empty($chatList) ? array_column($chatList, null, 'chat_id') : [];
}
/**
* Notes: 获取群成员id
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 3:03 下午
* @param $chatId
* @param $userIds
* @return array
*/
private function getWxGroupChatUserIds($chatId, $userIds): array
{
$userList = WxGroupChatUser::getRecords(['chat_id' => $chatId, 'user_id' => $userIds], ['user_id']);
return !empty($userList) ? array_column($userList, null, 'user_id') : [];
}
/**
* Notes: 获取部门下成员
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 7:35 下午
* @return array
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
*/
private function getGroupChatOwnerList(): array
{
if (empty($this->departmentId)) {
return [];
}
return (array)$this->wxApp->user->getDepartmentUsers($this->departmentId, true);
}
/**
* Notes: 获取群详情
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 7:35 下午
* @param $chatId
* @return array
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
private function getGroupChatDetail($chatId): array
{
return (array)$this->wxApp->external_contact->getGroupChat($chatId, 1);
}
/**
* Notes: 获取群列表
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 7:36 下午
* @param string $nextCursor
* @return array
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
private function getGroupChatList(string $nextCursor = ''): array
{
$params = [
'limit' => $this->pageSize
];
// 群主过滤
if (!empty($this->ownerUserIds)) {
$params['owner_filter']['userid_list'] = $this->ownerUserIds;
}
if (!empty($nextCursor)) {
$params['cursor'] = $nextCursor;
}
return (array)$this->wxApp->external_contact->getGroupChats($params);
}
/**
* Notes: 加载配置
* User: pengfei@yidian-inc.com
* Date: 2021/9/28 7:36 下午
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
*/
private function loadConfig()
{
$this->departmentId = config('wechat', 'corp.secondary_market_department_id');
$result = $this->getGroupChatOwnerList();
$this->ownerUserIds = array_column($result['userlist'], 'userid');
}
/**
* Notes: 记录 info 日志
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:10 下午
* @param $log
*/
private function loggerInfo($log)
{
JobLog::getInstance()->info('colonel_distributor_order', $log)->output();
}
/**
* Notes: 记录 error 日志
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:10 下午
* @param $log
*/
private function loggerError($log)
{
JobLog::getInstance()->error('colonel_distributor_order', $log, null, 'bp-server@yidian-inc.com')->output();
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@
"php": "7.2.*",
"ext-json": "*",
"api/php_services":"1.0.16",
"api/php_utils":"1.0.18",
"api/php_utils":"1.0.21",
"ext-openssl": "*"
},
"minimum-stability": "dev",
......
This diff is collapsed.
......@@ -21,7 +21,7 @@ idgen.key = "5cfdb867e96374c7883b31d6928cc4cb"
wechat.appid = "wx4e0d92499185fb74";
wechat.secret = "731bcf2f7ebb1ebddb677618c2008b25";
wechat.appid.merchant-pub-pin = "wx4e0d92499185fb74"
wechat.secret.merchant-pub-pin = "731bcf2f7ebb1ebddb677618c2008b25"
......
......@@ -7,6 +7,7 @@ class GoodsSkuId
{
const TABLE_TAG_GENERAL = "000";//普通表 goods_sku 商品
const TABLE_TAG_PINDAN = "001";//接龙表 pindan_goods_sku 商品
const TABLE_TAG_ERSHOU = "002";//二手商品表 ershou_goods_sku 商品
/**
* 生成加密后的 sku_id
......
......@@ -229,6 +229,106 @@ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFOU3D4aULZuJ3IyRGmPhwn5g
zIcDvT2EEZMJ+ePgi0Oax/P3z25m5758okGs1lrS93vDWO7lbsgQn5mnuKuqmuj6
M3BP/vOildi+3oTZcjQTV2deebIrhW4p96DvTqQ7ixVAEi4of3XoITA00J8hfNy9
jDprGYGJ5yeTuRRHlQIDAQAB
-----END PUBLIC KEY-----';
/**
* 商户系统配送员小程序 SERVER端私钥与客户端公钥
*/
const MERCHANT_PUB_DELIVERER_PRIVATE_KEY_STR = '-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAM0f2QpMH7WZRVfY
ObD8Z8gUfLPnx9+B7PXxDCLnFbjz+tDKGHmF5r9K7BLRqiIWz4R6czbjxINQiH88
kRwXMXC6X0AOf9rV0kDJErN2d+lHkOuxMWDbPhYYBsUbUWqUfspZOeohB6UHTYeY
a82GOfBDpWdG4WLgUn4PrIHVfM4XAgMBAAECgYEAk7DRofNrhWKFJhm+eCtUQiBW
JWbGZ6xxxCc5uMuvvUqWFczdUGpT2PoF/grON9s6sUVFPYlDjdTnYs1mIdalNh2P
puYlvYdluA78uNDBpOEINR5RYOJbWJFAno2qzi19kUhbxNlfDsfEo/y9i+vyz/PU
xM/Q48DYsGYVcHVJtHECQQD1CAlJrWYWLkUmk9ENKmwam/JKd8Uz1r0HW2LPaV2B
EeKLK9hoTSK3KC4nkIkANFazi5Z1UHi3ztIlRvBV+qNZAkEA1k5+PIPsGk438tP/
E1v3JxS4yLUQ5ly3Aq1DHFub8pDzr8E7DNjeJZJnMngO9ol6CfKLYMWZ8qDtrnAl
BEz+7wJBAO4spJKISP3wdej8r6yjercWtJnr97Te25kGHHLN0US/dLygntcrez4b
gVmV5YVcWpZlbZeU4/KOx7fST5TTbukCQAdyILavirN7Rjxcmz8r8dFcyfLHP7gR
PpaMOImysR9jY+QWXZvbqRQ7GvTI8RQlwKS51ZfeJbQlXTyzTsXweucCQFkjMlaY
dh8zRYwQ9rmHOMYMC5yZCpXuy7uJCd4r7E2f9QNF9yWGxDLm7lfRyBFXqYCzcD7p
DHGH8yiUHYbGVbo=
-----END PRIVATE KEY-----';
const MERCHANT_PUB_DELIVERER_PUBLIC_KEY_STR = '-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCf7Wy+LXurjF13cEUStvkfNOim
UkZmOjYiarYb612Htmlo8UybeAc1FhBe7IbqlRNev1kOfWBAfbtFjOKwuSVnmzNI
59Kvzzeg2hUj9z6rneuTw2qz3OdhrxXXA4wP7Ed6RyMPfIupwo4XDd8lCotH+ACJ
Kurbi/FSMWuJ/b4ZMwIDAQAB
-----END PUBLIC KEY-----';
/**
* 商户系统配送员小程序-测试 SERVER端私钥与客户端公钥
*/
const TEST_MERCHANT_PUB_DELIVERER_PRIVATE_KEY_STR = '-----BEGIN PRIVATE KEY-----
MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBANZ/GQ5zzKBmTMno
wlkg3OBU55z39vnNuKGf/DyrdS39tWBEKzZCPdigu/xlcnbIChD8WczkHMSFexhN
3kjGqHCUNHL5Tm50/XjmBIgEm7wKls6qLyEMiThrJo9jvzttkHzI1R2AUpG5l6a4
0sDpnn2ksKoLniAsjDmKCeESiLlJAgMBAAECgYEAm/XmHiAM1UQM6XKYfX3rnCGg
Fv4lUhVG/h35pZN1rG8hBlIKqXUYyv50MV0CEWP6Dceu88+ZKzty+YUE7x2jMoOG
J7XAvrayz0gDRaoPyhdUa0bBTSy8C53Vbxl1+iNj5A2+Cac9ovcNXbevl/+xLjvh
bq171Jj5J1FcdrGypgECQQDs5f5RsQ4Kqzul4/SFTi7W74q9BYV+HbmENO5ZK/WZ
xShvx4mM6OieNCLn/f8bIdV1Ddpg6nTMr3Pnl+m6ppFRAkEA58qwPp3NzEgxdZQX
u/V9APJxGdtYOE5wxg9ScKSS28b93ei6MdIr/lrqRTALaSNLeez6WZwgrebIzSqv
utrqeQJBAJFGoeV7DL9iLtwWpRcy0OqiT5SHVEv48pGu3BP3L1AzZg7WcPXmxvBt
zJI0Y0NCRmLYMfmJDkOPvSZjNMRv7WECQQCrjYdeALuFW1VH2aCrW2j2X3m4EnC7
08qBvGtetV+ATEouiIXuQ8iNy8oiBQoc+aNuDSfJVNWW//1UZCiF2mq5AkBMWcUF
9y7N06BE7GPqj7kLoHcSnhC05jJent058hpulAKWkLiiuOF6NqFsoWB86xyNmckt
3Db3EWDzVlc1v2io
-----END PRIVATE KEY-----';
const TEST_MERCHANT_PUB_DELIVERER_PUBLIC_KEY_STR = '-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCi2r9ZrCNbO6ZKjSu771CzYHXm
xsGfVHVSPwpw2AyOWJWEWBuGAc+ovlpORwSqnU1StPa92t7c4lt3P96httWM6iE0
sWCBGxzzwcsO4novU+Omo/bcgJw5y9EX7V8rkk/lYbGxZbBhcq9C5xyhdi8Qb1WZ
yexmKxL97vSWL8f4uwIDAQAB
-----END PUBLIC KEY-----';
/**
* 商户系统二手小程序 SERVER端私钥与客户端公钥
*/
const MERCHANT_PUB_IDLE_PRIVATE_KEY_STR = '-----BEGIN PRIVATE KEY-----
MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKB0bRSmYGZnQhWN
KJB57NSBGQHcj3XJ/VwmUZEX10IG8OWqONYDyNc12XmWqz9xrfqETt4J6yk0uPN1
uDT0Cfs28aFSxHJ2tA6XZZ33/5lIbYZ21vSWe5Oo4GRErdWK+ED7Ms/il7Hp8sCm
VFaEjYkdiqrGTOhCm3AqeXj7aV+hAgMBAAECgYAW5EVjutDqCzVMadUtt5doQfrV
XyhAf87bxMPCVYpqax8XRQ/SyLtwqMgcJrjL1mYh5Zpy5ytbt5/jbBoZw+9gY+9j
OEcGUMNHKyPzjR1VUzYZKQ8ukc58YMjHaKjNt0dAs7cIwMzcXiNwZYB45az8gQNk
XI4HausgaIffjdG+AQJBANWSrrZZEcyV6J7j9lFLh7ML1LG4cfzpqg2+oBd8UU6y
rYs/fgG15CCEl2uQnOBil6qHGuyz2JlrqxvySyw1e3ECQQDAVGb727pBs+rDsBJn
GoLrpLWuVHVSMIuaqYJtCXooUBcbaMQOZcvz0cDxJOl/NVevXJAgD//POr10X2vc
My8xAkB0yhecQ6zGEZv5d3N1FTaJpIiU/uXmheimR33IGgVkYbUhFoFTciHj3l3n
RldjJMcHS4ZftiFWFFinmaGd9UkhAkA8VL2RV9XPcm68P+kl6o0S+jH7o4bB53SD
aZT+OzDUoHr/IBgQJCKcMzoA6wFL5CHDYpfbVul5ygVQEfa1tmChAkBY2pd+w0FN
3HSZ+wZ9/q/tiBkWoZpsEcOckAwW5f2MVXq32FZpEctP3P5VYMGek/SJGxiXzYuO
VCe3uFNhexw1
-----END PRIVATE KEY-----';
const MERCHANT_PUB_IDLE_PUBLIC_KEY_STR = '-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCuXeAKaEjreNXXxx9WsXIcNNP3
lzHv24lnWe3RKz/qvN+gO6I9j53+v+W0eHmz42E+Lo5rbR35rt/eCxkf1ahypqVH
xQPpUsaG6qouf+4ElMOw3Jn/6EUFA9Zg2b5YT3uPNYe5XQo8WKdiX6QibPrqDFMm
3HFp6G/reDxTYxODZwIDAQAB
-----END PUBLIC KEY-----';
/**
* 商户系统二手小程序-测试 SERVER端私钥与客户端公钥
*/
const TEST_MERCHANT_PUB_IDLE_PRIVATE_KEY_STR = '-----BEGIN PRIVATE KEY-----
MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJnSpR48UvoBlSP4
z+YVSGONzpWGFsceGw5j2Il7kTXgC0nEOQ+6UHcLeov2nnY66oT6LdbdtLt4bxKG
uJcCY3z2yq4gCDJM99aGhc9CqmcCqtLTg2KU+CQUtskglikfOZHkYGs2AiPkHpz+
ZaIMhASp5QcXMh2i/9gAG6+49o0fAgMBAAECgYASQ00xYs4jOq7fX3ongh1fHIYL
gKkRqQRjV/1sjUw3TktozbBMqr1E9QrutTApL2OKuD1bBmWf4HOninE+FJ2FGI7+
SJmaWug5X4q+I6KtlQwvXbh9nWr63Z6NeA+tk2/ymK4czwnjTRSil4cpyOIL/j4I
u7D54MlTnvIwwfLBCQJBAMzOoeV2i8auhpr5Ki9SFbj/FSkOgLW8R6q2GwMeI/zt
OjR3IwJBPfYAwYBii0jJXneJ0AIxQVAJpE5Ck/TnuTUCQQDARZX/SSOQK6BnHtU6
zIP2vGhsYLQC8cJnIGS5+O/PgMCNxRuuvwL7gmEx9Cy1MUsE/EPCASvBCmO4gA5e
54uDAkAFEzm/zeg4zCpZvMLm2Ungg7Gqisl1t2yvNkQFF8IcimRe2HTtoWA/sFUb
MVXyP8sveyLEayQLL7H6nnu8HeHhAkA2kMkD3RbZqHfqLAbpm/brhAbCkyMjHsdE
Cx5q5Onx4qFC2qiDjDPletfonFo/xdB7hrgYC8sGCtPIHZd2eZHPAkAKKsmhMbqP
YBU7o/pyCdFBad4ageW4Nyb+q1Svs6gGSGoufn3X+AlhIt9zuXKy6366UVGvfg/x
r80efjK0Awsf
-----END PRIVATE KEY-----';
const TEST_MERCHANT_PUB_IDLE_PUBLIC_KEY_STR = '-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDkHed5g0yBpdyZZVEwe84cm3iM
2tlqPGEevEJN0Aufp3uu6RmPGCP2SP0O0pmLo4eIHD/RgH/CIq1ddHe8jUuS1Xnw
I3tfsHhnZl3udcK/00/q6eEXLgzhnhSG2p0A3qee2LF6ll7Z2zSUkpP++NOuM3mf
Hr8Q7se66z2xizgFnwIDAQAB
-----END PUBLIC KEY-----';
/**
* TEST SERVER端私钥与客户端公钥
......@@ -293,6 +393,22 @@ mnRjVUtXBgEF0A9xt2QVNMQovtjJ2rkg43gVByDKbOsUqbJYjA12IpALMdECHCMl
'pub_key' => self::TEST_MERCHANT_PUB_PIN_PUBLIC_KEY_STR,
'pri_key' => self::TEST_MERCHANT_PUB_PIN_PRIVATE_KEY_STR,
],
'merchant-pub-deliverer' => [
'pub_key' => self::MERCHANT_PUB_DELIVERER_PUBLIC_KEY_STR,
'pri_key' => self::MERCHANT_PUB_DELIVERER_PRIVATE_KEY_STR,
],
'test-merchant-pub-deliverer' => [
'pub_key' => self::TEST_MERCHANT_PUB_DELIVERER_PUBLIC_KEY_STR,
'pri_key' => self::TEST_MERCHANT_PUB_DELIVERER_PRIVATE_KEY_STR,
],
'merchant-pub-idle' => [
'pub_key' => self::MERCHANT_PUB_IDLE_PUBLIC_KEY_STR,
'pri_key' => self::MERCHANT_PUB_IDLE_PRIVATE_KEY_STR,
],
'test-merchant-pub-idle' => [
'pub_key' => self::TEST_MERCHANT_PUB_IDLE_PUBLIC_KEY_STR,
'pri_key' => self::TEST_MERCHANT_PUB_IDLE_PRIVATE_KEY_STR,
],
'test' => [
'pub_key' => self::TEST_PUBLIC_KEY_STR,
'pri_key' => self::TEST_PRIVATE_KEY_STR,
......
<?php
namespace Api\PhpUtils\EasyWechat;
class AppConfig
{
public static function getCorpConfig(array $config = []): array
{
$default = [
'corp_id' => config('wechat', 'corp.id'),
'secret' => config('wechat', 'corp.secret'),
];
return array_merge($default,$config);
}
}
\ No newline at end of file
......@@ -42,30 +42,75 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
/** @var ?string */
private $vendorDir;
// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var string[]
* @psalm-var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var bool[]
* @psalm-var array<string, bool>
*/
private $missingClasses = array();
/** @var ?string */
private $apcuPrefix;
/**
* @var self[]
*/
private static $registeredLoaders = array();
/**
* @param ?string $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}
/**
* @return string[]
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
......@@ -75,28 +120,47 @@ class ClassLoader
return array();
}
/**
* @return array[]
* @psalm-return array<string, array<int, string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return string[] Array of classname => path
* @psalm-var array<string, string>
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
*
* @return void
*/
public function addClassMap(array $classMap)
{
......@@ -111,9 +175,11 @@ class ClassLoader
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
......@@ -156,11 +222,13 @@ class ClassLoader
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
......@@ -204,8 +272,10 @@ class ClassLoader
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
......@@ -220,10 +290,12 @@ class ClassLoader
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
......@@ -243,6 +315,8 @@ class ClassLoader
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
......@@ -265,6 +339,8 @@ class ClassLoader
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
......@@ -285,6 +361,8 @@ class ClassLoader
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
......@@ -305,6 +383,8 @@ class ClassLoader
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
......@@ -324,6 +404,8 @@ class ClassLoader
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
......@@ -401,6 +483,11 @@ class ClassLoader
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
......@@ -472,6 +559,10 @@ class ClassLoader
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{
......
This diff is collapsed.
......@@ -53,6 +53,7 @@ return array(
'Api\\PhpUtils\\Common\\IP' => $vendorDir . '/api/php_utils/src/Common/IP.php',
'Api\\PhpUtils\\Common\\Rsa' => $vendorDir . '/api/php_utils/src/Common/Rsa.php',
'Api\\PhpUtils\\Common\\TimeOut' => $vendorDir . '/api/php_utils/src/Common/TimeOut.php',
'Api\\PhpUtils\\EasyWechat\\AppConfig' => $vendorDir . '/api/php_utils/src/EasyWechat/AppConfig.php',
'Api\\PhpUtils\\Elastic\\ElasticUtil' => $vendorDir . '/api/php_utils/src/Elastic/ElasticUtil.php',
'Api\\PhpUtils\\Elastic\\Manager\\DocumentManager' => $vendorDir . '/api/php_utils/src/Elastic/Manager/DocumentManager.php',
'Api\\PhpUtils\\Elastic\\Manager\\IndexManager' => $vendorDir . '/api/php_utils/src/Elastic/Manager/IndexManager.php',
......@@ -106,6 +107,7 @@ return array(
'App\\Models\\demo\\mongo\\User' => $baseDir . '/application/models/demo/mongo/User.php',
'App\\Models\\demo\\mysql\\User' => $baseDir . '/application/models/demo/mysql/User.php',
'App\\Models\\goods\\mysql\\Category' => $baseDir . '/application/models/goods/mysql/Category.php',
'App\\Models\\goods\\mysql\\ErshouGoodsSku' => $baseDir . '/application/models/goods/mysql/ErshouGoodsSku.php',
'App\\Models\\goods\\mysql\\GoodsOperationRecord' => $baseDir . '/application/models/goods/mysql/GoodsOperationRecord.php',
'App\\Models\\goods\\mysql\\GoodsRefundRecord' => $baseDir . '/application/models/goods/mysql/GoodsRefundRecord.php',
'App\\Models\\goods\\mysql\\GoodsSku' => $baseDir . '/application/models/goods/mysql/GoodsSku.php',
......@@ -121,6 +123,7 @@ return array(
'App\\Models\\goods\\mysql\\PindanGoodsSnapshot' => $baseDir . '/application/models/goods/mysql/PindanGoodsSnapshot.php',
'App\\Models\\goods\\mysql\\Shop' => $baseDir . '/application/models/goods/mysql/Shop.php',
'App\\Models\\goods\\mysql\\Tcc' => $baseDir . '/application/models/goods/mysql/Tcc.php',
'App\\Models\\marketing\\mysql\\BusinessCircle' => $baseDir . '/application/models/marketing/mysql/BusinessCircle.php',
'App\\Models\\marketing\\mysql\\ColonelDistributorColonel' => $baseDir . '/application/models/marketing/mysql/ColonelDistributorColonel.php',
'App\\Models\\marketing\\mysql\\ColonelDistributorColonelApply' => $baseDir . '/application/models/marketing/mysql/ColonelDistributorColonelApply.php',
'App\\Models\\marketing\\mysql\\ColonelDistributorConfig' => $baseDir . '/application/models/marketing/mysql/ColonelDistributorConfig.php',
......@@ -134,11 +137,14 @@ return array(
'App\\Models\\marketing\\mysql\\MarketingPindan' => $baseDir . '/application/models/marketing/mysql/MarketingPindan.php',
'App\\Models\\marketing\\mysql\\MarketingTakePlace' => $baseDir . '/application/models/marketing/mysql/MarketingTakePlace.php',
'App\\Models\\marketing\\mysql\\QyqGroupleader' => $baseDir . '/application/models/marketing/mysql/QyqGroupleader.php',
'App\\Models\\marketing\\mysql\\Tag' => $baseDir . '/application/models/marketing/mysql/Tag.php',
'App\\Models\\marketing\\mysql\\TakePlace' => $baseDir . '/application/models/marketing/mysql/TakePlace.php',
'App\\Models\\shop\\mysql\\Shop' => $baseDir . '/application/models/shop/mysql/Shop.php',
'App\\Models\\shop\\mysql\\SubShop' => $baseDir . '/application/models/shop/mysql/SubShop.php',
'App\\Models\\tmp\\mysql\\QyqTicketData' => $baseDir . '/application/models/tmp/mysql/QyqTicketData.php',
'App\\Models\\user\\mysql\\UserWechatBind' => $baseDir . '/application/models/user/mysql/UserWechatBind.php',
'App\\Models\\wx\\mysql\\WxGroupChat' => $baseDir . '/application/models/wx/mysql/WxGroupChat.php',
'App\\Models\\wx\\mysql\\WxGroupChatUser' => $baseDir . '/application/models/wx/mysql/WxGroupChatUser.php',
'App\\Plugins\\Hook' => $baseDir . '/application/plugins/Hook.php',
'App\\Services\\common\\CommonService' => $baseDir . '/application/services/common/CommonService.php',
'App\\Services\\common\\KafkaService' => $baseDir . '/application/services/common/KafkaService.php',
......@@ -147,10 +153,12 @@ return array(
'App\\Services\\demo\\MysqlService' => $baseDir . '/application/services/demo/MysqlService.php',
'App\\Services\\goods\\CategoryService' => $baseDir . '/application/services/goods/CategoryService.php',
'App\\Services\\goods\\ElasticGoodService' => $baseDir . '/application/services/goods/ElasticGoodService.php',
'App\\Services\\goods\\ErshouGoodsService' => $baseDir . '/application/services/goods/ErshouGoodsService.php',
'App\\Services\\goods\\GoodsService' => $baseDir . '/application/services/goods/GoodsService.php',
'App\\Services\\goods\\GoodsSnapshotsService' => $baseDir . '/application/services/goods/GoodsSnapshotsService.php',
'App\\Services\\goods\\MarketingPindanGoodsService' => $baseDir . '/application/services/goods/MarketingPindanGoodsService.php',
'App\\Services\\goods\\OtaService' => $baseDir . '/application/services/goods/OtaService.php',
'App\\Services\\marketing\\BusinessCircleService' => $baseDir . '/application/services/marketing/BusinessCircleService.php',
'App\\Services\\marketing\\ColonelService' => $baseDir . '/application/services/marketing/ColonelService.php',
'App\\Services\\marketing\\DistributionService' => $baseDir . '/application/services/marketing/DistributionService.php',
'App\\Services\\marketing\\DistributorService' => $baseDir . '/application/services/marketing/DistributorService.php',
......@@ -159,6 +167,7 @@ return array(
'App\\Services\\marketing\\MarketingService' => $baseDir . '/application/services/marketing/MarketingService.php',
'App\\Services\\marketing\\PindanActivityColonelConfigService' => $baseDir . '/application/services/marketing/PindanActivityColonelConfigService.php',
'App\\Services\\marketing\\PindanActivityInviteOrderService' => $baseDir . '/application/services/marketing/PindanActivityInviteOrderService.php',
'App\\Services\\marketing\\TagService' => $baseDir . '/application/services/marketing/TagService.php',
'App\\Services\\marketing\\TakePlaceService' => $baseDir . '/application/services/marketing/TakePlaceService.php',
'App\\Services\\shop\\ShopService' => $baseDir . '/application/services/shop/ShopService.php',
'App\\Services\\tcc\\Tcc2Service' => $baseDir . '/application/services/tcc/Tcc2Service.php',
......@@ -167,6 +176,7 @@ return array(
'App\\Services\\user\\Weixin\\ErrorCode' => $baseDir . '/application/services/user/Weixin/ErrorCode.php',
'App\\Services\\user\\Weixin\\Weixin' => $baseDir . '/application/services/user/Weixin/Weixin.php',
'App\\Services\\user\\Weixin\\WxBizDataCrypt' => $baseDir . '/application/services/user/Weixin/WxBizDataCrypt.php',
'App\\Services\\wx\\GroupChatService' => $baseDir . '/application/services/wx/GroupChatService.php',
'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'BaconQrCode\\Common\\BitArray' => $vendorDir . '/bacon/bacon-qr-code/src/Common/BitArray.php',
'BaconQrCode\\Common\\BitMatrix' => $vendorDir . '/bacon/bacon-qr-code/src/Common/BitMatrix.php',
......
......@@ -375,6 +375,7 @@ class ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e
'Api\\PhpUtils\\Common\\IP' => __DIR__ . '/..' . '/api/php_utils/src/Common/IP.php',
'Api\\PhpUtils\\Common\\Rsa' => __DIR__ . '/..' . '/api/php_utils/src/Common/Rsa.php',
'Api\\PhpUtils\\Common\\TimeOut' => __DIR__ . '/..' . '/api/php_utils/src/Common/TimeOut.php',
'Api\\PhpUtils\\EasyWechat\\AppConfig' => __DIR__ . '/..' . '/api/php_utils/src/EasyWechat/AppConfig.php',
'Api\\PhpUtils\\Elastic\\ElasticUtil' => __DIR__ . '/..' . '/api/php_utils/src/Elastic/ElasticUtil.php',
'Api\\PhpUtils\\Elastic\\Manager\\DocumentManager' => __DIR__ . '/..' . '/api/php_utils/src/Elastic/Manager/DocumentManager.php',
'Api\\PhpUtils\\Elastic\\Manager\\IndexManager' => __DIR__ . '/..' . '/api/php_utils/src/Elastic/Manager/IndexManager.php',
......@@ -428,6 +429,7 @@ class ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e
'App\\Models\\demo\\mongo\\User' => __DIR__ . '/../..' . '/application/models/demo/mongo/User.php',
'App\\Models\\demo\\mysql\\User' => __DIR__ . '/../..' . '/application/models/demo/mysql/User.php',
'App\\Models\\goods\\mysql\\Category' => __DIR__ . '/../..' . '/application/models/goods/mysql/Category.php',
'App\\Models\\goods\\mysql\\ErshouGoodsSku' => __DIR__ . '/../..' . '/application/models/goods/mysql/ErshouGoodsSku.php',
'App\\Models\\goods\\mysql\\GoodsOperationRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsOperationRecord.php',
'App\\Models\\goods\\mysql\\GoodsRefundRecord' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsRefundRecord.php',
'App\\Models\\goods\\mysql\\GoodsSku' => __DIR__ . '/../..' . '/application/models/goods/mysql/GoodsSku.php',
......@@ -443,6 +445,7 @@ class ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e
'App\\Models\\goods\\mysql\\PindanGoodsSnapshot' => __DIR__ . '/../..' . '/application/models/goods/mysql/PindanGoodsSnapshot.php',
'App\\Models\\goods\\mysql\\Shop' => __DIR__ . '/../..' . '/application/models/goods/mysql/Shop.php',
'App\\Models\\goods\\mysql\\Tcc' => __DIR__ . '/../..' . '/application/models/goods/mysql/Tcc.php',
'App\\Models\\marketing\\mysql\\BusinessCircle' => __DIR__ . '/../..' . '/application/models/marketing/mysql/BusinessCircle.php',
'App\\Models\\marketing\\mysql\\ColonelDistributorColonel' => __DIR__ . '/../..' . '/application/models/marketing/mysql/ColonelDistributorColonel.php',
'App\\Models\\marketing\\mysql\\ColonelDistributorColonelApply' => __DIR__ . '/../..' . '/application/models/marketing/mysql/ColonelDistributorColonelApply.php',
'App\\Models\\marketing\\mysql\\ColonelDistributorConfig' => __DIR__ . '/../..' . '/application/models/marketing/mysql/ColonelDistributorConfig.php',
......@@ -456,11 +459,14 @@ class ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e
'App\\Models\\marketing\\mysql\\MarketingPindan' => __DIR__ . '/../..' . '/application/models/marketing/mysql/MarketingPindan.php',
'App\\Models\\marketing\\mysql\\MarketingTakePlace' => __DIR__ . '/../..' . '/application/models/marketing/mysql/MarketingTakePlace.php',
'App\\Models\\marketing\\mysql\\QyqGroupleader' => __DIR__ . '/../..' . '/application/models/marketing/mysql/QyqGroupleader.php',
'App\\Models\\marketing\\mysql\\Tag' => __DIR__ . '/../..' . '/application/models/marketing/mysql/Tag.php',
'App\\Models\\marketing\\mysql\\TakePlace' => __DIR__ . '/../..' . '/application/models/marketing/mysql/TakePlace.php',
'App\\Models\\shop\\mysql\\Shop' => __DIR__ . '/../..' . '/application/models/shop/mysql/Shop.php',
'App\\Models\\shop\\mysql\\SubShop' => __DIR__ . '/../..' . '/application/models/shop/mysql/SubShop.php',
'App\\Models\\tmp\\mysql\\QyqTicketData' => __DIR__ . '/../..' . '/application/models/tmp/mysql/QyqTicketData.php',
'App\\Models\\user\\mysql\\UserWechatBind' => __DIR__ . '/../..' . '/application/models/user/mysql/UserWechatBind.php',
'App\\Models\\wx\\mysql\\WxGroupChat' => __DIR__ . '/../..' . '/application/models/wx/mysql/WxGroupChat.php',
'App\\Models\\wx\\mysql\\WxGroupChatUser' => __DIR__ . '/../..' . '/application/models/wx/mysql/WxGroupChatUser.php',
'App\\Plugins\\Hook' => __DIR__ . '/../..' . '/application/plugins/Hook.php',
'App\\Services\\common\\CommonService' => __DIR__ . '/../..' . '/application/services/common/CommonService.php',
'App\\Services\\common\\KafkaService' => __DIR__ . '/../..' . '/application/services/common/KafkaService.php',
......@@ -469,10 +475,12 @@ class ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e
'App\\Services\\demo\\MysqlService' => __DIR__ . '/../..' . '/application/services/demo/MysqlService.php',
'App\\Services\\goods\\CategoryService' => __DIR__ . '/../..' . '/application/services/goods/CategoryService.php',
'App\\Services\\goods\\ElasticGoodService' => __DIR__ . '/../..' . '/application/services/goods/ElasticGoodService.php',
'App\\Services\\goods\\ErshouGoodsService' => __DIR__ . '/../..' . '/application/services/goods/ErshouGoodsService.php',
'App\\Services\\goods\\GoodsService' => __DIR__ . '/../..' . '/application/services/goods/GoodsService.php',
'App\\Services\\goods\\GoodsSnapshotsService' => __DIR__ . '/../..' . '/application/services/goods/GoodsSnapshotsService.php',
'App\\Services\\goods\\MarketingPindanGoodsService' => __DIR__ . '/../..' . '/application/services/goods/MarketingPindanGoodsService.php',
'App\\Services\\goods\\OtaService' => __DIR__ . '/../..' . '/application/services/goods/OtaService.php',
'App\\Services\\marketing\\BusinessCircleService' => __DIR__ . '/../..' . '/application/services/marketing/BusinessCircleService.php',
'App\\Services\\marketing\\ColonelService' => __DIR__ . '/../..' . '/application/services/marketing/ColonelService.php',
'App\\Services\\marketing\\DistributionService' => __DIR__ . '/../..' . '/application/services/marketing/DistributionService.php',
'App\\Services\\marketing\\DistributorService' => __DIR__ . '/../..' . '/application/services/marketing/DistributorService.php',
......@@ -481,6 +489,7 @@ class ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e
'App\\Services\\marketing\\MarketingService' => __DIR__ . '/../..' . '/application/services/marketing/MarketingService.php',
'App\\Services\\marketing\\PindanActivityColonelConfigService' => __DIR__ . '/../..' . '/application/services/marketing/PindanActivityColonelConfigService.php',
'App\\Services\\marketing\\PindanActivityInviteOrderService' => __DIR__ . '/../..' . '/application/services/marketing/PindanActivityInviteOrderService.php',
'App\\Services\\marketing\\TagService' => __DIR__ . '/../..' . '/application/services/marketing/TagService.php',
'App\\Services\\marketing\\TakePlaceService' => __DIR__ . '/../..' . '/application/services/marketing/TakePlaceService.php',
'App\\Services\\shop\\ShopService' => __DIR__ . '/../..' . '/application/services/shop/ShopService.php',
'App\\Services\\tcc\\Tcc2Service' => __DIR__ . '/../..' . '/application/services/tcc/Tcc2Service.php',
......@@ -489,6 +498,7 @@ class ComposerStaticInite9c1cf708c572b30ccbaa1adb865583e
'App\\Services\\user\\Weixin\\ErrorCode' => __DIR__ . '/../..' . '/application/services/user/Weixin/ErrorCode.php',
'App\\Services\\user\\Weixin\\Weixin' => __DIR__ . '/../..' . '/application/services/user/Weixin/Weixin.php',
'App\\Services\\user\\Weixin\\WxBizDataCrypt' => __DIR__ . '/../..' . '/application/services/user/Weixin/WxBizDataCrypt.php',
'App\\Services\\wx\\GroupChatService' => __DIR__ . '/../..' . '/application/services/wx/GroupChatService.php',
'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php',
'BaconQrCode\\Common\\BitArray' => __DIR__ . '/..' . '/bacon/bacon-qr-code/src/Common/BitArray.php',
'BaconQrCode\\Common\\BitMatrix' => __DIR__ . '/..' . '/bacon/bacon-qr-code/src/Common/BitMatrix.php',
......
This diff is collapsed.
<?php return array(
'root' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '40f8b230881d7a86438dc069837b93af2d6b8b73',
'reference' => 'ebb9b15da4e0c73c85b3d5032eaba6f705e925ed',
'name' => 'yidian/yaf_demo',
'dev' => true,
),
......@@ -20,12 +20,12 @@
'dev_requirement' => false,
),
'api/php_utils' => array(
'pretty_version' => 'v1.0.18',
'version' => '1.0.18.0',
'pretty_version' => 'v1.0.21',
'version' => '1.0.21.0',
'type' => 'library',
'install_path' => __DIR__ . '/../api/php_utils',
'aliases' => array(),
'reference' => '33b06adcf6eae99ada39b67c9fb28802a17cb528',
'reference' => '82fc4f6fb8db04525404f8c8d8da0969dd911a9f',
'dev_requirement' => false,
),
'bacon/bacon-qr-code' => array(
......@@ -110,9 +110,9 @@
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/promises',
'aliases' => array(
0 => '1.4.x-dev',
0 => '1.5.x-dev',
),
'reference' => 'c1dd809c8f51a477701052f4b9e5b4bb5c1061aa',
'reference' => '136a635e2b4a49b9d79e9c8fee267ffb257fdba0',
'dev_requirement' => false,
),
'guzzlehttp/psr7' => array(
......@@ -121,7 +121,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/psr7',
'aliases' => array(),
'reference' => '9d006741ba865a45adccfac45d8e1053086a5a3f',
'reference' => '1afdd860a2566ed3c2b0b4a3de6e23434a79ec85',
'dev_requirement' => false,
),
'khanamiryan/qrcode-detector-decoder' => array(
......@@ -150,7 +150,7 @@
'aliases' => array(
0 => '2.x-dev',
),
'reference' => '437e7a1c50044b92773b361af77620efb76fff59',
'reference' => 'd1c28292689764504cbaab2beec8ddd0a54bcc1c',
'dev_requirement' => false,
),
'myclabs/php-enum' => array(
......@@ -177,7 +177,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../overtrue/wechat',
'aliases' => array(),
'reference' => '00f72fb0113ad1aa47bcf350c3dd4c3af1cd1f54',
'reference' => '0907070e17e4420c4ea73e6daac492ac74add9b9',
'dev_requirement' => false,
),
'perftools/php-profiler' => array(
......@@ -279,7 +279,7 @@
'aliases' => array(
0 => '1.0.x-dev',
),
'reference' => '5a7b96b1dda5d957e01bc1bfe77dcca09c5a7474',
'reference' => '66e27efc65ddef47d3008c243a235ab9359b5754',
'dev_requirement' => false,
),
'psr/simple-cache-implementation' => array(
......@@ -312,7 +312,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/cache',
'aliases' => array(),
'reference' => '772bc130c5ed31bd5616c4806145b73b07b8c149',
'reference' => 'ccf2fb68a8ac525c2f00dcf81b79237b569dbc87',
'dev_requirement' => false,
),
'symfony/cache-contracts' => array(
......@@ -331,13 +331,11 @@
),
),
'symfony/deprecation-contracts' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'pretty_version' => '2.5.x-dev',
'version' => '2.5.9999999.9999999-dev',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(
0 => '2.5.x-dev',
),
'aliases' => array(),
'reference' => '6f981ee24cf69ee7ce9736146d1c57c2780598a8',
'dev_requirement' => false,
),
......@@ -371,7 +369,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/http-foundation',
'aliases' => array(),
'reference' => '65808acd52ee65add91353cde5cb432021a9ca43',
'reference' => '2561c6bf1835db30b129788ba1143bea1f49849c',
'dev_requirement' => false,
),
'symfony/options-resolver' => array(
......@@ -464,7 +462,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/property-info',
'aliases' => array(),
'reference' => '903f3f3f6a360bc4739f8390e5031acc70d9cd9f',
'reference' => '505502817d5caafbfca3efb25ae720122d9ffdcd',
'dev_requirement' => false,
),
'symfony/psr-http-message-bridge' => array(
......@@ -475,7 +473,7 @@
'aliases' => array(
0 => '2.1.x-dev',
),
'reference' => 'd558dcde0b4f6a808f66702abd3c1617572f621b',
'reference' => '824711c9099e7c6808041e1144eaeac5285e4a67',
'dev_requirement' => false,
),
'symfony/service-contracts' => array(
......@@ -506,12 +504,12 @@
'dev_requirement' => false,
),
'yidian/yaf_demo' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '40f8b230881d7a86438dc069837b93af2d6b8b73',
'reference' => 'ebb9b15da4e0c73c85b3d5032eaba6f705e925ed',
'dev_requirement' => false,
),
),
......
# CHANGELOG
## 1.5.0 - 2021-10-07
### Changed
- Call handler when waiting on fulfilled/rejected Promise
### Fixed
- Fix manually settle promises generated with Utils::task
## 1.4.1 - 2021-02-18
### Fixed
- Fixed `each_limit` skipping promises and failing
## 1.4.0 - 2020-09-30
......
......@@ -48,7 +48,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
"dev-master": "1.5-dev"
}
},
"config": {
......
......@@ -12,6 +12,12 @@ class FulfilledPromise implements PromiseInterface
{
private $value;
/** @var Promise|null */
private $promise;
/** @var callable|null */
private $onFulfilled;
public function __construct($value)
{
if (is_object($value) && method_exists($value, 'then')) {
......@@ -32,18 +38,14 @@ class FulfilledPromise implements PromiseInterface
return $this;
}
$this->onFulfilled = $onFulfilled;
$queue = Utils::queue();
$p = new Promise([$queue, 'run']);
$p = $this->promise = new Promise([$queue, 'run']);
$value = $this->value;
$queue->add(static function () use ($p, $value, $onFulfilled) {
if (Is::pending($p)) {
try {
$p->resolve($onFulfilled($value));
} catch (\Throwable $e) {
$p->reject($e);
} catch (\Exception $e) {
$p->reject($e);
}
self::callHandler($p, $value, $onFulfilled);
}
});
......@@ -57,6 +59,11 @@ class FulfilledPromise implements PromiseInterface
public function wait($unwrap = true, $defaultDelivery = null)
{
// Don't run the queue to avoid deadlocks, instead directly resolve the promise.
if ($this->promise && Is::pending($this->promise)) {
self::callHandler($this->promise, $this->value, $this->onFulfilled);
}
return $unwrap ? $this->value : null;
}
......@@ -81,4 +88,15 @@ class FulfilledPromise implements PromiseInterface
{
// pass
}
private static function callHandler(Promise $promise, $value, callable $handler)
{
try {
$promise->resolve($handler($value));
} catch (\Throwable $e) {
$promise->reject($e);
} catch (\Exception $e) {
$promise->reject($e);
}
}
}
......@@ -12,6 +12,12 @@ class RejectedPromise implements PromiseInterface
{
private $reason;
/** @var Promise|null */
private $promise;
/** @var callable|null */
private $onRejected;
public function __construct($reason)
{
if (is_object($reason) && method_exists($reason, 'then')) {
......@@ -32,21 +38,14 @@ class RejectedPromise implements PromiseInterface
return $this;
}
$this->onRejected = $onRejected;
$queue = Utils::queue();
$reason = $this->reason;
$p = new Promise([$queue, 'run']);
$p = $this->promise = new Promise([$queue, 'run']);
$queue->add(static function () use ($p, $reason, $onRejected) {
if (Is::pending($p)) {
try {
// Return a resolved promise if onRejected does not throw.
$p->resolve($onRejected($reason));
} catch (\Throwable $e) {
// onRejected threw, so return a rejected promise.
$p->reject($e);
} catch (\Exception $e) {
// onRejected threw, so return a rejected promise.
$p->reject($e);
}
self::callHandler($p, $reason, $onRejected);
}
});
......@@ -64,6 +63,11 @@ class RejectedPromise implements PromiseInterface
throw Create::exceptionFor($this->reason);
}
// Don't run the queue to avoid deadlocks, instead directly reject the promise.
if ($this->promise && Is::pending($this->promise)) {
self::callHandler($this->promise, $this->reason, $this->onRejected);
}
return null;
}
......@@ -88,4 +92,15 @@ class RejectedPromise implements PromiseInterface
{
// pass
}
private static function callHandler(Promise $promise, $reason, callable $handler)
{
try {
$promise->resolve($handler($reason));
} catch (\Throwable $e) {
$promise->reject($e);
} catch (\Exception $e) {
$promise->reject($e);
}
}
}
......@@ -48,7 +48,9 @@ final class Utils
$promise = new Promise([$queue, 'run']);
$queue->add(function () use ($task, $promise) {
try {
$promise->resolve($task());
if (Is::pending($promise)) {
$promise->resolve($task());
}
} catch (\Throwable $e) {
$promise->reject($e);
} catch (\Exception $e) {
......
......@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## Unreleased
## 1.8.3 - 2021-10-05
### Fixed
- Return `null` in caching stream size if remote size is `null`
## 1.8.2 - 2021-04-26
### Fixed
......
......@@ -36,7 +36,13 @@ class CachingStream implements StreamInterface
public function getSize()
{
return max($this->stream->getSize(), $this->remoteStream->getSize());
$remoteSize = $this->remoteStream->getSize();
if (null === $remoteSize) {
return null;
}
return max($this->stream->getSize(), $remoteSize);
}
public function rewind()
......
### 2.3.5 (2021-10-01)
* Fixed regression in StreamHandler since 2.3.3 on systems with the memory_limit set to >=20GB (#1592)
### 2.3.4 (2021-09-15)
* Fixed support for psr/log 3.x (#1589)
......
......@@ -22,7 +22,7 @@
"elasticsearch/elasticsearch": "^7",
"mongodb/mongodb": "^1.8",
"graylog2/gelf-php": "^1.4.2",
"php-amqplib/php-amqplib": "~2.4",
"php-amqplib/php-amqplib": "~2.4 || ^3",
"php-console/php-console": "^3.1.3",
"phpspec/prophecy": "^1.6.1",
"phpunit/phpunit": "^8.5",
......@@ -68,8 +68,8 @@
"phpstan": "vendor/bin/phpstan analyse"
},
"config": {
"lock": false,
"sort-packages": true,
"platform-check": false
},
"lock": false
}
}
......@@ -26,9 +26,11 @@ use Monolog\Utils;
class StreamHandler extends AbstractProcessingHandler
{
/** @const int */
protected const MAX_CHUNK_SIZE = 100 * 1024 * 1024;
protected const MAX_CHUNK_SIZE = 2147483647;
/** @const int 10MB */
protected const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024;
/** @var int */
protected $streamChunkSize = self::MAX_CHUNK_SIZE;
protected $streamChunkSize;
/** @var resource|null */
protected $stream;
/** @var ?string */
......@@ -55,13 +57,15 @@ class StreamHandler extends AbstractProcessingHandler
if (($phpMemoryLimit = Utils::expandIniShorthandBytes(ini_get('memory_limit'))) !== false) {
if ($phpMemoryLimit > 0) {
// use max 10% of allowed memory for the chunk size
$this->streamChunkSize = max((int) ($phpMemoryLimit / 10), 10*1024);
// use max 10% of allowed memory for the chunk size, and at least 100KB
$this->streamChunkSize = min(static::MAX_CHUNK_SIZE, max((int) ($phpMemoryLimit / 10), 100 * 1024));
} else {
// memory is unlimited, set to the default 10MB
$this->streamChunkSize = static::DEFAULT_CHUNK_SIZE;
}
// else memory is unlimited, keep the buffer to the default 100MB
} else {
// no memory limit information, use a conservative 10MB
$this->streamChunkSize = 10*10*1024;
// no memory limit information, set to the default 10MB
$this->streamChunkSize = static::DEFAULT_CHUNK_SIZE;
}
if (is_resource($stream)) {
......
......@@ -164,10 +164,11 @@ class Client extends BaseClient
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getGroupChat(string $chatId)
public function getGroupChat(string $chatId, int $needName = 0)
{
$params = [
'chat_id' => $chatId,
'need_name' => $needName,
];
return $this->httpPostJson('cgi-bin/externalcontact/groupchat/get', $params);
......
......@@ -6,7 +6,7 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"require": {
......
......@@ -12,10 +12,9 @@
namespace Symfony\Component\Cache\Adapter;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Exception as DBALException;
use Doctrine\DBAL\Exception\TableNotFoundException;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Schema;
......@@ -110,7 +109,6 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
*
* @throws \PDOException When the table already exists
* @throws DBALException When the table already exists
* @throws Exception When the table already exists
* @throws \DomainException When an unsupported PDO driver is used
*/
public function createTable()
......@@ -123,7 +121,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
$this->addTableToSchema($schema);
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
if (method_exists($conn, 'executeStatement')) {
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
$conn->executeStatement($sql);
} else {
$conn->exec($sql);
......@@ -158,7 +156,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
throw new \DomainException(sprintf('Creating the cache table is currently not implemented for PDO driver "%s".', $this->driver));
}
if (method_exists($conn, 'executeStatement')) {
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
$conn->executeStatement($sql);
} else {
$conn->exec($sql);
......@@ -307,7 +305,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
}
try {
if (method_exists($conn, 'executeStatement')) {
if ($conn instanceof Connection && method_exists($conn, 'executeStatement')) {
$conn->executeStatement($sql);
} else {
$conn->exec($sql);
......@@ -437,7 +435,7 @@ class PdoAdapter extends AbstractAdapter implements PruneableInterface
if (null === $driver && !(\is_object($result) ? $result->rowCount() : $stmt->rowCount())) {
try {
$insertStmt->execute();
} catch (DBALException | Exception $e) {
} catch (DBALException $e) {
} catch (\PDOException $e) {
// A concurrent write won, let it be
}
......
......@@ -34,7 +34,7 @@
"require-dev": {
"cache/integration-tests": "dev-master",
"doctrine/cache": "^1.6|^2.0",
"doctrine/dbal": "^2.10|^3.0",
"doctrine/dbal": "^2.13|^3.0",
"predis/predis": "^1.1",
"psr/simple-cache": "^1.0",
"symfony/config": "^4.4|^5.0|^6.0",
......@@ -45,7 +45,7 @@
"symfony/var-dumper": "^4.4|^5.0|^6.0"
},
"conflict": {
"doctrine/dbal": "<2.10",
"doctrine/dbal": "<2.13",
"symfony/dependency-injection": "<4.4",
"symfony/http-kernel": "<4.4",
"symfony/var-dumper": "<4.4"
......
......@@ -138,7 +138,7 @@ class Response
*
* The list of codes is complete according to the
* {@link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml Hypertext Transfer Protocol (HTTP) Status Code Registry}
* (last updated 2016-03-01).
* (last updated 2021-10-01).
*
* Unless otherwise noted, the status code is defined in RFC2616.
*
......@@ -180,14 +180,14 @@ class Response
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Payload Too Large',
413 => 'Content Too Large', // RFC-ietf-httpbis-semantics
414 => 'URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Range Not Satisfiable',
417 => 'Expectation Failed',
418 => 'I\'m a teapot', // RFC2324
421 => 'Misdirected Request', // RFC7540
422 => 'Unprocessable Entity', // RFC4918
422 => 'Unprocessable Content', // RFC-ietf-httpbis-semantics
423 => 'Locked', // RFC4918
424 => 'Failed Dependency', // RFC4918
425 => 'Too Early', // RFC-ietf-httpbis-replay-04
......@@ -1048,10 +1048,10 @@ class Response
$ret = [];
foreach ($vary as $item) {
$ret = array_merge($ret, preg_split('/[\s,]+/', $item));
$ret[] = preg_split('/[\s,]+/', $item);
}
return $ret;
return array_merge([], ...$ret);
}
/**
......@@ -1078,8 +1078,6 @@ class Response
* If the Response is not modified, it sets the status code to 304 and
* removes the actual content by calling the setNotModified() method.
*
* @return bool
*
* @final
*/
public function isNotModified(Request $request): bool
......
......@@ -196,7 +196,7 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */
foreach ($docBlock->getTagsByName('param') as $tag) {
if ($tag && null !== $tag->getType()) {
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
$types[] = $this->phpDocTypeHelper->getTypes($tag->getType());
}
}
......@@ -204,7 +204,7 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
return null;
}
return $types;
return array_merge([], ...$types);
}
private function getDocBlockFromConstructor(string $class, string $property): ?DocBlock
......
......@@ -364,14 +364,14 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
return $mutator;
}
$errors = array_merge($errors, $adderAndRemoverErrors);
$errors[] = $adderAndRemoverErrors;
foreach ($this->mutatorPrefixes as $mutatorPrefix) {
$methodName = $mutatorPrefix.$camelized;
[$accessible, $methodAccessibleErrors] = $this->isMethodAccessible($reflClass, $methodName, 1);
if (!$accessible) {
$errors = array_merge($errors, $methodAccessibleErrors);
$errors[] = $methodAccessibleErrors;
continue;
}
......@@ -392,7 +392,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, $getsetter, $this->getWriteVisiblityForMethod($method), $method->isStatic());
}
$errors = array_merge($errors, $methodAccessibleErrors);
$errors[] = $methodAccessibleErrors;
}
if ($reflClass->hasProperty($property) && ($reflClass->getProperty($property)->getModifiers() & $this->propertyReflectionFlags)) {
......@@ -407,7 +407,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_PROPERTY, $property, PropertyWriteInfo::VISIBILITY_PUBLIC, false);
}
$errors = array_merge($errors, $methodAccessibleErrors);
$errors[] = $methodAccessibleErrors;
}
if ($allowMagicCall) {
......@@ -416,21 +416,21 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
return new PropertyWriteInfo(PropertyWriteInfo::TYPE_METHOD, 'set'.$camelized, PropertyWriteInfo::VISIBILITY_PUBLIC, false);
}
$errors = array_merge($errors, $methodAccessibleErrors);
$errors[] = $methodAccessibleErrors;
}
if (!$allowAdderRemover && null !== $adderAccessName && null !== $removerAccessName) {
$errors[] = sprintf(
$errors[] = [sprintf(
'The property "%s" in class "%s" can be defined with the methods "%s()" but '.
'the new value must be an array or an instance of \Traversable',
$property,
$reflClass->getName(),
implode('()", "', [$adderAccessName, $removerAccessName])
);
)];
}
$noneProperty = new PropertyWriteInfo();
$noneProperty->setErrors($errors);
$noneProperty->setErrors(array_merge([], ...$errors));
return $noneProperty;
}
......@@ -727,20 +727,21 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
[$addMethodFound, $addMethodAccessibleErrors] = $this->isMethodAccessible($reflClass, $addMethod, 1);
[$removeMethodFound, $removeMethodAccessibleErrors] = $this->isMethodAccessible($reflClass, $removeMethod, 1);
$errors = array_merge($errors, $addMethodAccessibleErrors, $removeMethodAccessibleErrors);
$errors[] = $addMethodAccessibleErrors;
$errors[] = $removeMethodAccessibleErrors;
if ($addMethodFound && $removeMethodFound) {
return [$addMethod, $removeMethod, []];
}
if ($addMethodFound && !$removeMethodFound) {
$errors[] = sprintf('The add method "%s" in class "%s" was found, but the corresponding remove method "%s" was not found', $addMethod, $reflClass->getName(), $removeMethod);
$errors[] = [sprintf('The add method "%s" in class "%s" was found, but the corresponding remove method "%s" was not found', $addMethod, $reflClass->getName(), $removeMethod)];
} elseif (!$addMethodFound && $removeMethodFound) {
$errors[] = sprintf('The remove method "%s" in class "%s" was found, but the corresponding add method "%s" was not found', $removeMethod, $reflClass->getName(), $addMethod);
$errors[] = [sprintf('The remove method "%s" in class "%s" was found, but the corresponding add method "%s" was not found', $removeMethod, $reflClass->getName(), $addMethod)];
}
}
return [null, null, $errors];
return [null, null, array_merge([], ...$errors)];
}
/**
......
......@@ -19,6 +19,7 @@ jobs:
deprecations: max[self]=0
- php: '8.0'
deps: highest
deprecations: max[indirect]=5
steps:
- name: Checkout code
......
......@@ -29,39 +29,49 @@ class Message implements MessageInterface
{
$this->version = $version;
$this->headers = $headers;
$this->body = null === $body ? new Stream() : $body;
$this->body = $body ?? new Stream();
}
public function getProtocolVersion()
public function getProtocolVersion(): string
{
return $this->version;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withProtocolVersion($version)
{
throw new \BadMethodCallException('Not implemented.');
}
public function getHeaders()
public function getHeaders(): array
{
return $this->headers;
}
public function hasHeader($name)
public function hasHeader($name): bool
{
return isset($this->headers[$name]);
}
public function getHeader($name)
public function getHeader($name): array
{
return $this->hasHeader($name) ? $this->headers[$name] : [];
}
public function getHeaderLine($name)
public function getHeaderLine($name): string
{
return $this->hasHeader($name) ? implode(',', $this->headers[$name]) : '';
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withHeader($name, $value)
{
$this->headers[$name] = (array) $value;
......@@ -69,11 +79,21 @@ class Message implements MessageInterface
return $this;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withAddedHeader($name, $value)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withoutHeader($name)
{
unset($this->headers[$name]);
......@@ -81,11 +101,16 @@ class Message implements MessageInterface
return $this;
}
public function getBody()
public function getBody(): StreamInterface
{
return $this->body;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withBody(StreamInterface $body)
{
throw new \BadMethodCallException('Not implemented.');
......
......@@ -28,17 +28,20 @@ class Response extends Message implements ResponseInterface
$this->statusCode = $statusCode;
}
public function getStatusCode()
public function getStatusCode(): int
{
return $this->statusCode;
}
/**
* @return static
*/
public function withStatus($code, $reasonPhrase = '')
{
throw new \BadMethodCallException('Not implemented.');
}
public function getReasonPhrase()
public function getReasonPhrase(): string
{
throw new \BadMethodCallException('Not implemented.');
}
......
......@@ -45,95 +45,156 @@ class ServerRequest extends Message implements ServerRequestInterface
$this->attributes = $attributes;
}
public function getRequestTarget()
public function getRequestTarget(): string
{
return $this->requestTarget;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withRequestTarget($requestTarget)
{
throw new \BadMethodCallException('Not implemented.');
}
public function getMethod()
public function getMethod(): string
{
return $this->method;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withMethod($method)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return UriInterface
*/
public function getUri()
{
return $this->uri;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withUri(UriInterface $uri, $preserveHost = false)
{
throw new \BadMethodCallException('Not implemented.');
}
public function getServerParams()
public function getServerParams(): array
{
return $this->server;
}
public function getCookieParams()
public function getCookieParams(): array
{
return $this->cookies;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withCookieParams(array $cookies)
{
throw new \BadMethodCallException('Not implemented.');
}
public function getQueryParams()
public function getQueryParams(): array
{
return $this->query;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withQueryParams(array $query)
{
throw new \BadMethodCallException('Not implemented.');
}
public function getUploadedFiles()
public function getUploadedFiles(): array
{
return $this->uploadedFiles;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withUploadedFiles(array $uploadedFiles)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return array|object|null
*/
public function getParsedBody()
{
return $this->data;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withParsedBody($data)
{
throw new \BadMethodCallException('Not implemented.');
}
public function getAttributes()
public function getAttributes(): array
{
return $this->attributes;
}
/**
* {@inheritdoc}
*
* @return mixed
*/
public function getAttribute($name, $default = null)
{
return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
return $this->attributes[$name] ?? $default;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withAttribute($name, $value)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withoutAttribute($name)
{
throw new \BadMethodCallException('Not implemented.');
......
......@@ -26,12 +26,12 @@ class Stream implements StreamInterface
$this->stringContent = $stringContent;
}
public function __toString()
public function __toString(): string
{
return $this->stringContent;
}
public function close()
public function close(): void
{
}
......@@ -40,61 +40,69 @@ class Stream implements StreamInterface
return fopen('data://text/plain,'.$this->stringContent, 'r');
}
public function getSize()
public function getSize(): ?int
{
return null;
}
public function tell()
public function tell(): int
{
return 0;
}
public function eof()
public function eof(): bool
{
return $this->eof;
}
public function isSeekable()
public function isSeekable(): bool
{
return true;
}
public function seek($offset, $whence = \SEEK_SET)
public function seek($offset, $whence = \SEEK_SET): void
{
}
public function rewind()
public function rewind(): void
{
$this->eof = false;
}
public function isWritable()
public function isWritable(): bool
{
return false;
}
public function write($string)
public function write($string): int
{
return \strlen($string);
}
public function isReadable()
public function isReadable(): bool
{
return true;
}
public function read($length)
public function read($length): string
{
$this->eof = true;
return $this->stringContent;
}
public function getContents()
public function getContents(): string
{
return $this->stringContent;
}
/**
* {@inheritdoc}
*
* @return mixed
*/
public function getMetadata($key = null)
{
return null;
}
}
......@@ -33,32 +33,32 @@ class UploadedFile implements UploadedFileInterface
$this->clientMediaType = $clientMediaType;
}
public function getStream()
public function getStream(): Stream
{
return new Stream(file_get_contents($this->filePath));
}
public function moveTo($targetPath)
public function moveTo($targetPath): void
{
rename($this->filePath, $targetPath);
}
public function getSize()
public function getSize(): ?int
{
return $this->size;
}
public function getError()
public function getError(): int
{
return $this->error;
}
public function getClientFilename()
public function getClientFilename(): ?string
{
return $this->clientFileName;
}
public function getClientMediaType()
public function getClientMediaType(): ?string
{
return $this->clientMediaType;
}
......
......@@ -27,26 +27,26 @@ class Uri implements UriInterface
private $fragment = '';
private $uriString;
public function __construct($uri = '')
public function __construct(string $uri = '')
{
$parts = parse_url($uri);
$this->scheme = isset($parts['scheme']) ? $parts['scheme'] : '';
$this->userInfo = isset($parts['user']) ? $parts['user'] : '';
$this->host = isset($parts['host']) ? $parts['host'] : '';
$this->port = isset($parts['port']) ? $parts['port'] : null;
$this->path = isset($parts['path']) ? $parts['path'] : '';
$this->query = isset($parts['query']) ? $parts['query'] : '';
$this->fragment = isset($parts['fragment']) ? $parts['fragment'] : '';
$this->scheme = $parts['scheme'] ?? '';
$this->userInfo = $parts['user'] ?? '';
$this->host = $parts['host'] ?? '';
$this->port = $parts['port'] ?? null;
$this->path = $parts['path'] ?? '';
$this->query = $parts['query'] ?? '';
$this->fragment = $parts['fragment'] ?? '';
$this->uriString = $uri;
}
public function getScheme()
public function getScheme(): string
{
return $this->scheme;
}
public function getAuthority()
public function getAuthority(): string
{
if (empty($this->host)) {
return '';
......@@ -63,72 +63,107 @@ class Uri implements UriInterface
return $authority;
}
public function getUserInfo()
public function getUserInfo(): string
{
return $this->userInfo;
}
public function getHost()
public function getHost(): string
{
return $this->host;
}
public function getPort()
public function getPort(): ?int
{
return $this->port;
}
public function getPath()
public function getPath(): string
{
return $this->path;
}
public function getQuery()
public function getQuery(): string
{
return $this->query;
}
public function getFragment()
public function getFragment(): string
{
return $this->fragment;
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withScheme($scheme)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withUserInfo($user, $password = null)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withHost($host)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withPort($port)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withPath($path)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withQuery($query)
{
throw new \BadMethodCallException('Not implemented.');
}
/**
* {@inheritdoc}
*
* @return static
*/
public function withFragment($fragment)
{
throw new \BadMethodCallException('Not implemented.');
}
public function __toString()
public function __toString(): string
{
return $this->uriString;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment