Commit a57f9d4e authored by suntengda's avatar suntengda

add 拼单小程序活动列表新版接口

parent 40f8b230
<?php
use Api\PhpUtils\Log\FileLog;
use App\Base\Base;
use App\Services\marketing\MarketingService;
use App\Exception\custom\MarketingException;
......@@ -8,8 +7,6 @@ use App\Services\marketing\MarketingGoodsService;
use \Validate\MarketingGoodsRateValidate;
use \Validate\MarketingOnlineStatusValidate;
use \Validate\MarketingInfoValidate;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingPindan;
use Api\PhpUtils\Redis\RedisUtil;
class MarketingController extends Base
......@@ -165,104 +162,47 @@ class MarketingController extends Base
*/
public function tuancan_listAction()
{
$this->params['marketing_type'] = Marketing::MARKETING_TYPE_PINDAN;//1分销 2团购 3秒杀 4团餐
$this->params['online_status'] = Marketing::ONLINE_STATUS_QIDONG;//状态 , 1启用,2关闭,3 到期
$this->params['from'] = 1;//1 小程序前台 默认0 后台
//正在进行中的 按结束时间正序
$this->params['sort_field'] = 'end_time';
$this->params['sort_type'] = 'asc';
$this->params['need_buy_num'] = false;
$this->params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS;//1 未开始,2进行中,3已结束
$list['doing'] = MarketingService::marketingList($this->params)['result'];
$list['doing'] = $list['doing'] ? array_column($list['doing'], null, 'marketing_id') : [];
$marketingIdsDoing = array_keys($list['doing']);
//当天即将开始的 按开始时间正序
$this->params['page'] = 1;
$this->params['sort_field'] = 'start_time';
$this->params['sort_type'] = 'asc';
$this->params['need_buy_num'] = false;
$this->params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_START_TODAY;//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list['prepare'] = MarketingService::marketingList($this->params)['result'];
$list['prepare'] = $list['prepare'] ? array_column((array)$list['prepare'], null, 'marketing_id') : [];
$marketingIdsPrepare = array_keys($list['prepare']);
$marketingIds = array_merge($marketingIdsDoing, $marketingIdsPrepare);
$list = $this->_fillSkuAndOrderInfo($marketingIds,$list);
//已结束的 按结束时间倒序
$list['end'] = $this->getTuanCanEndList();
$page = $this->params['page'] ?? 1;
$pageSize = $this->params['page_size'] ?? 20;
$list = MarketingService::getPindanActiveAndReadyList($page,$pageSize);
$list['end'] = MarketingService::getPindanEndList($page,$pageSize);
$list['life_account_id'] = MarketingService::getPublicLifeAccountId();
$this->success(['result' => $list]);
}
private function getTuanCanEndList(){
try{
$redis = RedisUtil::getInstance('cache',['serializer'=>'none']);
$key = "tuancan_end_list_in_".date('Ymd');
$list['end'] = $redis->get($key);
if(empty($list['end'])) {
$this->params['page'] = 1;
$this->params['page_size'] = 10;
$this->params['sort_field'] = 'end_time';
$this->params['sort_type'] = 'desc';
$this->params['need_buy_num'] = false;
$this->params['online_status'] = [Marketing::ONLINE_STATUS_QIDONG, Marketing::ONLINE_STATUS_GUANBI, Marketing::ONLINE_STATUS_DAOQI];//状态 , 1启用,2关闭,3 到期
$this->params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_FINISHED;//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list['end'] = MarketingService::marketingList($this->params)['result'];
$list['end'] = $list['end'] ? array_column($list['end'], null, 'marketing_id') : [];
$marketingIdsEnd = array_keys($list['end']);
$list = $this->_fillSkuAndOrderInfo($marketingIdsEnd,$list);
$redis->set($key,json_encode($list['end']),['ex'=>86400]);//已结束列表 缓存一天
}else {
$list['end'] = json_decode($list['end'], true);
}
}catch (Exception $e) {
FileLog::error("获取团餐已结束列表异常", $e->getMessage(), '', 'suntengda@yidian-inc.com');
}
return $list['end'] ?? [];
/**
* 正在进行中的活动简单信息列表
*/
public function pindan_active_basic_listAction()
{
$limit = $this->params['limit'] ?? 1;
$list = MarketingService::pindanActiveBasicList($limit,true);
$this->success(['result' => $list]);
}
/**
* 给列表填充sku和订单相关信息
* @param $marketingIds
* @param $list
* @return mixed
* @throws \App\Exception\custom\InterfaceException
*/
private function _fillSkuAndOrderInfo($marketingIds,$list) {
//获取活动的sku列表
$skuList = MarketingService::getGoodsSkuListByMarketingIds($marketingIds);
//获取活动支付用户列表
$orderUser = MarketingService::getMarketingOrderUser(['marketing_id' => $marketingIds]);
//获取活动支付用户数
$buyNum = MarketingService::getHaveBuyGoodsUserCount(['marketing_id' => $marketingIds]);
//组合sku和order信息
foreach ($list as &$listPart) {
foreach ($listPart as $marketingId => &$value) {
$value['sku_list'] = $skuList[$marketingId] ?? [];
$value['order_user'] = $orderUser[$marketingId] ?? [];
$value['participate_number'] = $buyNum[$marketingId] ?? 0;
}
unset($value);
$listPart = array_values($listPart);
}
unset($listPart);
return $list;
public function pindan_active_and_ready_listAction()
{
$list = MarketingService::getPindanActiveAndReadyList();
$this->success(['result' => $list]);
}
/**
*
* @throws Exception
*/
public function pindan_end_listAction()
{
$limit = $this->params['limit'] ?? 5;
$useCache = $this->params['use_cache'] ?? true;
$list = MarketingService::getPindanEndList(1,$limit,$useCache);
$this->success(['result' => $list]);
}
/**
* 切换活动状态
......
......@@ -24,6 +24,8 @@ use App\Services\common\KafkaService;
use App\Services\goods\GoodsService;
use Daemon\Goods;
use App\Exception\custom\GoodsException;
use Api\PhpUtils\Redis\RedisUtil;
use Api\PhpUtils\Log\FileLog;
class MarketingService
{
......@@ -279,13 +281,13 @@ class MarketingService
$page = ($params['page'] - 1) * $limit;
//排序规则
$sortField = $params['sort_field'] ?? 'update_time';
$sortType = isset($params['sort_type']) ? strtoupper($params['sort_type']) : 'desc';
$sortType = isset($params['sort_type']) ? strtoupper($params['sort_type']) : 'DESC';
//验证sort合法性
if(!in_array($params['sort_field'],['create_time','update_time','end_time','start_time'])) {
if(!in_array($sortField,['create_time','update_time','end_time','start_time'])) {
$sortField = 'update_time';
}
if(!in_array($params['sort_type'],['asc','desc'])) {
if(!in_array($sortType,['ASC','DESC'])) {
$sortType = 'DESC';
}
......@@ -297,29 +299,13 @@ class MarketingService
$where['online_status'] = $params['online_status'];
}
$now = date("Y-m-d H:i:s");
if ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_NO_START) {
$where["start_time[>]"] = $now;
} elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS) {
$where["start_time[<=]"] = $now;
$where["end_time[>=]"] = $now;
} elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_FINISHED) {
$where["end_time[<]"] = $now;
//七日内结束的活动
if (!empty($params['from']) && $params['from'] == 1) {
$beforeSevenDay = date("Y-m-d H:i:s", strtotime("-7 day"));
$where["end_time[>]"] = $beforeSevenDay;
}
} elseif ($params["activity_status"] == MarketingPindan::ACTIVITY_STATUS_START_TODAY) {//今日上新-未开始
$where["start_time[>]"] = $now;
$where["start_time[<=]"] = date("Y-m-d 00:00:00",strtotime('+1 days'));
$where["end_time[>=]"] = $now;
}
$where += self::getStartEndTimeFilter($params['activity_status'],$params['from']);
$where['life_account_id'] = self::getPublicLifeAccountId();
$where['ORDER'] = [$sortField => $sortType];
$where['LIMIT'] = [$page, $limit];
$list = Marketing::select(["marketing_id", "marketing_name", "start_time", "end_time",
"online_status", "update_time", "create_time"]
, $where);
......@@ -385,6 +371,175 @@ class MarketingService
return ['result' => $lists,'count' => $count];
}
private static function getStartEndTimeFilter($activityStatus,$from='') {
$where = [];
$now = date("Y-m-d H:i:s");
if ($activityStatus == MarketingPindan::ACTIVITY_STATUS_NO_START) {
$where["start_time[>]"] = $now;
} elseif ($activityStatus == MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS) {
$where["start_time[<=]"] = $now;
$where["end_time[>=]"] = $now;
} elseif ($activityStatus == MarketingPindan::ACTIVITY_STATUS_FINISHED) {
$where["end_time[<]"] = $now;
//七日内结束的活动
if ($from == 1) {
$beforeSevenDay = date("Y-m-d H:i:s", strtotime("-7 day"));
$where["end_time[>]"] = $beforeSevenDay;
}
} elseif ($activityStatus == MarketingPindan::ACTIVITY_STATUS_START_TODAY) {//今日上新-未开始
$where["start_time[>]"] = $now;
$where["start_time[<=]"] = date("Y-m-d 00:00:00",strtotime('+1 days'));
$where["end_time[>=]"] = $now;
}
return $where;
}
/**
* 正在进行中的活动简单信息列表
* @param int $limit
* @param bool $needSkuList
* @return \Api\PhpUtils\Mysql\MysqlBase
* @throws InterfaceException
*/
public static function pindanActiveBasicList($limit=2,$needSkuList=true)
{
$where["marketing_type"] = Marketing::MARKETING_TYPE_PINDAN;
$where['online_status'] = Marketing::ONLINE_STATUS_QIDONG;
$where += self::getStartEndTimeFilter(MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS);
$where['life_account_id'] = self::getPublicLifeAccountId();
$where['ORDER'] = ['end_time' => 'ASC','marketing_id'=>'ASC'];
$where['LIMIT'] = [0, $limit];
$list = Marketing::select(['marketing_id', 'marketing_name','start_time','end_time'], $where);
if(empty($list)) {
return [];
}
//获取活动sku列表
if($needSkuList) {
$list = array_column($list,null,'marketing_id');
$skuList = self::getGoodsSkuListByMarketingIds(array_keys($list));
foreach ($list as $marketingId => &$value) {
$value['sku_list'] = $skuList[$marketingId] ?? [];
}
unset($value);
$list = array_slice($list,0);
}
return $list;
}
/**
* 获取进行中和当天即将开始的活动列表
* @param int $page
* @param int $pageSize
* @return mixed
* @throws InterfaceException
*/
public static function getPindanActiveAndReadyList($page=1,$pageSize=50)
{
$params['page'] = $page;
$params['page_size'] = $pageSize;
$params['marketing_type'] = Marketing::MARKETING_TYPE_PINDAN;//1分销 2团购 3秒杀 4团餐
$params['online_status'] = Marketing::ONLINE_STATUS_QIDONG;//状态 , 1启用,2关闭,3 到期
$params['from'] = 1;//1 小程序前台 默认0 后台
//正在进行中的 按结束时间正序
$params['sort_field'] = 'end_time';
$params['sort_type'] = 'asc';
$params['need_buy_num'] = false;
$params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_IN_PROGRESS;//1 未开始,2进行中,3已结束
$list['doing'] = self::marketingList($params)['result'];
$list['doing'] = $list['doing'] ? array_column($list['doing'], null, 'marketing_id') : [];
$marketingIdsDoing = array_keys($list['doing']);
//当天即将开始的 按开始时间正序
$params['page'] = 1;
$params['sort_field'] = 'start_time';
$params['sort_type'] = 'asc';
$params['need_buy_num'] = false;
$params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_START_TODAY;//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list['prepare'] = self::marketingList($params)['result'];
$list['prepare'] = $list['prepare'] ? array_column((array)$list['prepare'], null, 'marketing_id') : [];
$marketingIdsPrepare = array_keys($list['prepare']);
$marketingIds = array_merge($marketingIdsDoing, $marketingIdsPrepare);
return self::_fillSkuAndOrderInfo($marketingIds,$list);
}
/**
* 获取已结束的
* @param int $page
* @param int $pageSize
* @return array|mixed
*/
public static function getPindanEndList($page=1,$pageSize=10,$useCache=true){
try{
$redis = RedisUtil::getInstance('cache',['serializer'=>'none']);
$key = "tuancan_end_list_".$page.'_'.$pageSize.'_'.date('Ymd');
// $list['end'] = $useCache ? $redis->get($key) : [];
if(empty($list['end'])) {
//已结束的 按结束时间倒序
$params['page'] = $page;
$params['page_size'] = $pageSize;
$params['marketing_type'] = Marketing::MARKETING_TYPE_PINDAN;//1分销 2团购 3秒杀 4团餐
$params['from'] = 1;//1 小程序前台 默认0 后台
$params['sort_field'] = 'end_time';
$params['sort_type'] = 'desc';
$params['need_buy_num'] = false;
$params['online_status'] = [Marketing::ONLINE_STATUS_QIDONG, Marketing::ONLINE_STATUS_GUANBI, Marketing::ONLINE_STATUS_DAOQI];//状态 , 1启用,2关闭,3 到期
$params['activity_status'] = MarketingPindan::ACTIVITY_STATUS_FINISHED;//1 未开始,2进行中,3已结束, 4当日上新(即将开始)
$list['end'] = MarketingService::marketingList($params)['result'];
$list['end'] = $list['end'] ? array_column($list['end'], null, 'marketing_id') : [];
$marketingIdsEnd = array_keys($list['end']);
$list = self::_fillSkuAndOrderInfo($marketingIdsEnd,$list);
$redis->set($key,json_encode($list['end']),['ex'=>86400]);//已结束列表 缓存一天
}else {
$list['end'] = json_decode($list['end'], true);
}
}catch (\Exception $e) {
FileLog::error("获取团餐已结束列表异常", $e->getMessage(), $e, 'suntengda@yidian-inc.com');
}
return $list['end'] ?? [];
}
/**
* 给列表填充sku和订单相关信息
* @param $marketingIds
* @param $list
* @return mixed
* @throws \App\Exception\custom\InterfaceException
*/
private static function _fillSkuAndOrderInfo($marketingIds,$list) {
//获取活动的sku列表
$skuList = self::getGoodsSkuListByMarketingIds($marketingIds);
//获取活动支付用户列表
$orderUser = self::getMarketingOrderUser(['marketing_id' => $marketingIds]);
//获取活动支付用户数
$buyNum = self::getHaveBuyGoodsUserCount(['marketing_id' => $marketingIds]);
//组合sku和order信息
foreach ($list as &$listPart) {
foreach ($listPart as $marketingId => &$value) {
$value['sku_list'] = $skuList[$marketingId] ?? [];
$value['order_user'] = $orderUser[$marketingId] ?? [];
$value['participate_number'] = $buyNum[$marketingId] ?? 0;
}
unset($value);
$listPart = array_values($listPart);
}
unset($listPart);
return $list;
}
/**
* 创建活动
* @param $params
......@@ -1203,12 +1358,13 @@ class MarketingService
}
/**
* 获取多个活动的商品列表
* 获取多个活动的商品列表
* @param $marketingIds
* @param bool $needSoldNum
* @return array
* @throws InterfaceException
*/
public static function getGoodsSkuListByMarketingIds($marketingIds)
public static function getGoodsSkuListByMarketingIds($marketingIds,$needSoldNum=true)
{
$marketingGoodsList = MarketingGoods::marketingGoodsList(['marketing_id' => $marketingIds, "ORDER" => ["id" => "ASC"]]);
......@@ -1222,7 +1378,7 @@ class MarketingService
$list = [];
if (!empty($goodsSkuList)) {
//活动sku购买数量
$soldNum = self::getHaveBuyGoodsStatistics(["marketing_id" => $marketingIds]);
$needSoldNum && $soldNum = self::getHaveBuyGoodsStatistics(["marketing_id" => $marketingIds]);
//保持排序
foreach ($marketingGoodsList as $key => $value) {
......
......@@ -6,7 +6,7 @@
"require": {
"php": "7.2.*",
"ext-json": "*",
"api/php_services":"1.0.15",
"api/php_services":"1.0.16",
"api/php_utils":"1.0.17",
"ext-openssl": "*"
},
......
......@@ -4,15 +4,15 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b64691cd0b568f54f381382cdb77553b",
"content-hash": "a6ce79abff3778226d347be8c1ba2b8b",
"packages": [
{
"name": "api/php_services",
"version": "1.0.15",
"version": "1.0.16",
"source": {
"type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_services.git",
"reference": "590b209014d0ccb8de96dd4cb243eeee41cae47d"
"reference": "ea80bdaefe875350b425b0aee11f59bf45d7258d"
},
"require": {
"endroid/qr-code": "^3.9",
......@@ -26,7 +26,7 @@
}
},
"description": "bp api php_services",
"time": "2021-09-14T06:43:42+00:00"
"time": "2021-09-15T02:17:53+00:00"
},
{
"name": "api/php_utils",
......@@ -67,13 +67,7 @@
"type": "zip",
"url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/f73543ac4e1def05f1a70bcd1525c8a157a1ad09",
"reference": "f73543ac4e1def05f1a70bcd1525c8a157a1ad09",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"dasprid/enum": "^1.0.3",
......@@ -126,13 +120,7 @@
"type": "zip",
"url": "https://api.github.com/repos/DASPRiD/Enum/zipball/5abf82f213618696dda8e3bf6f64dd042d8542b2",
"reference": "5abf82f213618696dda8e3bf6f64dd042d8542b2",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require-dev": {
"phpunit/phpunit": "^7 | ^8 | ^9",
......@@ -179,13 +167,7 @@
"type": "zip",
"url": "https://api.github.com/repos/elastic/elasticsearch-php/zipball/8d08050fef9d89004702b1428b8c1f7f4f6162cf",
"reference": "8d08050fef9d89004702b1428b8c1f7f4f6162cf",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"ext-json": ">=1.3.7",
......@@ -254,13 +236,7 @@
"type": "zip",
"url": "https://api.github.com/repos/endroid/qr-code/zipball/9cdd4f5d609bfc8811ca4a62b4d23eb16976242f",
"reference": "9cdd4f5d609bfc8811ca4a62b4d23eb16976242f",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"bacon/bacon-qr-code": "^2.0",
......@@ -335,13 +311,7 @@
"type": "zip",
"url": "https://api.github.com/repos/ezimuel/guzzlestreams/zipball/abe3791d231167f14eb80d413420d1eab91163a8",
"reference": "abe3791d231167f14eb80d413420d1eab91163a8",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=5.4.0"
......@@ -395,13 +365,7 @@
"type": "zip",
"url": "https://api.github.com/repos/ezimuel/ringphp/zipball/0b78f89d8e0bb9e380046c31adfa40347e9f663b",
"reference": "0b78f89d8e0bb9e380046c31adfa40347e9f663b",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"ezimuel/guzzlestreams": "^3.0.1",
......@@ -456,13 +420,7 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699",
"reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"guzzlehttp/promises": "^1.0",
......@@ -531,13 +489,7 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/c1dd809c8f51a477701052f4b9e5b4bb5c1061aa",
"reference": "c1dd809c8f51a477701052f4b9e5b4bb5c1061aa",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=5.5"
......@@ -622,13 +574,7 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/9d006741ba865a45adccfac45d8e1053086a5a3f",
"reference": "9d006741ba865a45adccfac45d8e1053086a5a3f",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=5.4.0",
......@@ -724,13 +670,7 @@
"type": "zip",
"url": "https://api.github.com/repos/khanamiryan/php-qrcode-detector-decoder/zipball/04fdd58d86a387065f707dc6d3cc304c719910c1",
"reference": "04fdd58d86a387065f707dc6d3cc304c719910c1",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=5.6"
......@@ -785,13 +725,7 @@
"type": "zip",
"url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/18fca8cc8d0c2cc07f76605760d20632bb3dab96",
"reference": "18fca8cc8d0c2cc07f76605760d20632bb3dab96",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"ext-hash": "*",
......@@ -855,13 +789,7 @@
"type": "zip",
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/d178027d1e679832db9f38248fcc7200647dc2b7",
"reference": "d178027d1e679832db9f38248fcc7200647dc2b7",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"ext-json": "*",
......@@ -921,13 +849,7 @@
"type": "zip",
"url": "https://api.github.com/repos/perftools/php-profiler/zipball/794c435f615ab9ca4347e386b4d8c6524fe9e3ae",
"reference": "794c435f615ab9ca4347e386b4d8c6524fe9e3ae",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"ext-json": "*",
......@@ -989,13 +911,7 @@
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/efd67d1dc14a7ef4fc4e518e7dee91c271d524e4",
"reference": "efd67d1dc14a7ef4fc4e518e7dee91c271d524e4",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=5.3.0"
......@@ -1049,13 +965,7 @@
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=5.3.0"
......@@ -1105,13 +1015,7 @@
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=5.6"
......@@ -1155,13 +1059,7 @@
"type": "zip",
"url": "https://api.github.com/repos/reactphp/promise/zipball/a9752a861e21c0fe0b380c9f9e55beddc0ed7d31",
"reference": "a9752a861e21c0fe0b380c9f9e55beddc0ed7d31",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=5.4.0"
......@@ -1221,13 +1119,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.1"
......@@ -1295,13 +1187,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/cd63dbab0428a47f8576e4e58148aeae2e32e91c",
"reference": "cd63dbab0428a47f8576e4e58148aeae2e32e91c",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.2.5",
......@@ -1364,19 +1250,13 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
"reference": "f24ae462b1d60c333df104f0b81ec7d0e12f6e9f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce",
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f24ae462b1d60c333df104f0b81ec7d0e12f6e9f",
"reference": "f24ae462b1d60c333df104f0b81ec7d0e12f6e9f",
"shasum": ""
},
"require": {
"php": ">=7.1"
......@@ -1426,7 +1306,7 @@
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
"source": "https://github.com/symfony/polyfill-ctype/tree/main"
},
"funding": [
{
......@@ -1442,7 +1322,7 @@
"type": "tidelift"
}
],
"time": "2021-02-19T12:13:01+00:00"
"time": "2021-09-14T14:02:44+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
......@@ -1456,13 +1336,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535",
"reference": "16880ba9c5ebe3642d1995ab866db29270b36535",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.1"
......@@ -1544,13 +1418,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8",
"reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.1"
......@@ -1635,13 +1503,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/344e456152e22a1bce3048c6c311059ea14bde47",
"reference": "344e456152e22a1bce3048c6c311059ea14bde47",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.1"
......@@ -1722,13 +1584,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/cc5db0e22b3cb4111010e48785a97f670b350ca5",
"reference": "cc5db0e22b3cb4111010e48785a97f670b350ca5",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.1"
......@@ -1808,13 +1664,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9",
"reference": "57b712b08eddb97c762a8caa32c84e037892d2e9",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.1"
......@@ -1898,13 +1748,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/bd3efa2a2d856d167dde8e7b883c65119064b7f5",
"reference": "bd3efa2a2d856d167dde8e7b883c65119064b7f5",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.2.5",
......@@ -1985,13 +1829,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-info/zipball/903f3f3f6a360bc4739f8390e5031acc70d9cd9f",
"reference": "903f3f3f6a360bc4739f8390e5031acc70d9cd9f",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.2.5",
......@@ -2081,13 +1919,7 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/fa2c5cc3f7dac23d87429652fe0daf28d65cbd5b",
"reference": "fa2c5cc3f7dac23d87429652fe0daf28d65cbd5b",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"shasum": ""
},
"require": {
"php": ">=7.2.5",
......
......@@ -180,4 +180,61 @@ class Ks3Api
list($msec, $sec) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
}
/**
* 批量获取图片
* @param $imageIds image_id 数组
* @param int $widthSize
* @param int $highSize
* @param float|int $expirationTime
* @return array
*/
public static function concurrencyPicEncryptUrl($imageIds, $widthSize = 0, $highSize = 0, $expirationTime = 60 * 60 * 24 * 365)
{
$url = self::BASE_GEN_URL . self::PATH_PIC_ENCRYPT_URL;
$timestamp = self::msectime();
$extend = [];
$extend["expiration_time"] = $expirationTime;
if (!empty($widthSize) && !empty($highSize)) {
$extend["query"] = "type=thumbnail_" . $widthSize . "x" . $highSize;
}
$extendJsonStr = json_encode($extend);
$params = [];
$urls = [];
foreach ($imageIds as $imageId) {
$md5Str = $extendJsonStr . "&" . $imageId . "&" . self::AUDIT_ID . "&" . $timestamp . "&" . self::KSYUN_SK;
$signature = self::KSYUN_AK . ":" . md5($md5Str);
$contentType = 'multipart/form-data';
$param = [
"image_id" => $imageId,
"auth_id" => self::AUDIT_ID,
"timestamp" => $timestamp,
"signature" => $signature,
"content_type" => $contentType,
"extend" => $extendJsonStr,
];
$params[$imageId] = $param;
$urls[$imageId] = $url;
}
$data = [];
if (!empty($urls)) {
$begin = microtime(true);
$encryptRes = HttpUtil::concurrencyPost($urls, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
$resCode = $encryptRes["response"]['code'] === 0 ? 200 : $encryptRes["response"]['code'];
MonUtil::proxyMon($url, $resCode, 'ks3api', $totalTime);
if (!empty($encryptRes)) {
foreach ($encryptRes as $imageId => $item) {
if (!empty($item["response"]["data"]["url"])) {
$data[$imageId] = $item["response"]["data"]["url"];
}
}
}
}
return $data;
}
}
\ No newline at end of file
......@@ -8,18 +8,18 @@ $baseDir = dirname($vendorDir);
return array(
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => $vendorDir . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'e69f7f6ee287b969198c3c9d6777bd38' => $vendorDir . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'a9ed0d27b5a698798a89181429f162c5' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/Common/customFunctions.php',
'8592c7b0947d8a0965a9e8c3d16f9c24' => $vendorDir . '/elasticsearch/elasticsearch/src/autoload.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'3a37ebac017bc098e9a86b35401e7a68' => $vendorDir . '/mongodb/mongodb/src/functions.php',
'8592c7b0947d8a0965a9e8c3d16f9c24' => $vendorDir . '/elasticsearch/elasticsearch/src/autoload.php',
);
......@@ -9,20 +9,20 @@ class ComposerStaticInit147d97defc074a277015f080b27e01c6
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
'8825ede83f2f289127722d4e842cf7e8' => __DIR__ . '/..' . '/symfony/polyfill-intl-grapheme/bootstrap.php',
'e69f7f6ee287b969198c3c9d6777bd38' => __DIR__ . '/..' . '/symfony/polyfill-intl-normalizer/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'a9ed0d27b5a698798a89181429f162c5' => __DIR__ . '/..' . '/khanamiryan/qrcode-detector-decoder/lib/Common/customFunctions.php',
'8592c7b0947d8a0965a9e8c3d16f9c24' => __DIR__ . '/..' . '/elasticsearch/elasticsearch/src/autoload.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'3a37ebac017bc098e9a86b35401e7a68' => __DIR__ . '/..' . '/mongodb/mongodb/src/functions.php',
'8592c7b0947d8a0965a9e8c3d16f9c24' => __DIR__ . '/..' . '/elasticsearch/elasticsearch/src/autoload.php',
);
public static $prefixLengthsPsr4 = array (
......
......@@ -2,19 +2,19 @@
"packages": [
{
"name": "api/php_services",
"version": "1.0.15",
"version_normalized": "1.0.15.0",
"version": "1.0.16",
"version_normalized": "1.0.16.0",
"source": {
"type": "git",
"url": "https://git.yidian-inc.com:8021/bp/php_services.git",
"reference": "590b209014d0ccb8de96dd4cb243eeee41cae47d"
"reference": "ea80bdaefe875350b425b0aee11f59bf45d7258d"
},
"require": {
"endroid/qr-code": "^3.9",
"perftools/php-profiler": "^0.18.0",
"php": "7.2.*"
},
"time": "2021-09-14T06:43:42+00:00",
"time": "2021-09-15T02:17:53+00:00",
"type": "library",
"installation-source": "source",
"autoload": {
......@@ -1422,19 +1422,13 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
"reference": "f24ae462b1d60c333df104f0b81ec7d0e12f6e9f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce",
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f24ae462b1d60c333df104f0b81ec7d0e12f6e9f",
"reference": "f24ae462b1d60c333df104f0b81ec7d0e12f6e9f",
"shasum": ""
},
"require": {
"php": ">=7.1"
......@@ -1442,7 +1436,7 @@
"suggest": {
"ext-ctype": "For best performance"
},
"time": "2021-02-19T12:13:01+00:00",
"time": "2021-09-14T14:02:44+00:00",
"default-branch": true,
"type": "library",
"extra": {
......@@ -1486,7 +1480,7 @@
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
"source": "https://github.com/symfony/polyfill-ctype/tree/main"
},
"funding": [
{
......
......@@ -5,18 +5,18 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '2af24ef59d9888a3a8c64df2ea4efd62c8a675a1',
'reference' => '40f8b230881d7a86438dc069837b93af2d6b8b73',
'name' => 'yidian/yaf_demo',
'dev' => true,
),
'versions' => array(
'api/php_services' => array(
'pretty_version' => '1.0.15',
'version' => '1.0.15.0',
'pretty_version' => '1.0.16',
'version' => '1.0.16.0',
'type' => 'library',
'install_path' => __DIR__ . '/../api/php_services',
'aliases' => array(),
'reference' => '590b209014d0ccb8de96dd4cb243eeee41cae47d',
'reference' => 'ea80bdaefe875350b425b0aee11f59bf45d7258d',
'dev_requirement' => false,
),
'api/php_utils' => array(
......@@ -223,7 +223,7 @@
'aliases' => array(
0 => '1.23.x-dev',
),
'reference' => '46cd95797e9df938fdd2b03693b5fca5e64b01ce',
'reference' => 'f24ae462b1d60c333df104f0b81ec7d0e12f6e9f',
'dev_requirement' => false,
),
'symfony/polyfill-intl-grapheme' => array(
......@@ -314,7 +314,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '2af24ef59d9888a3a8c64df2ea4efd62c8a675a1',
'reference' => '40f8b230881d7a86438dc069837b93af2d6b8b73',
'dev_requirement' => false,
),
),
......
......@@ -25,13 +25,13 @@ final class Ctype
*
* @see https://php.net/ctype-alnum
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_alnum($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
}
......@@ -41,13 +41,13 @@ final class Ctype
*
* @see https://php.net/ctype-alpha
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_alpha($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
}
......@@ -57,13 +57,13 @@ final class Ctype
*
* @see https://php.net/ctype-cntrl
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_cntrl($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
}
......@@ -73,13 +73,13 @@ final class Ctype
*
* @see https://php.net/ctype-digit
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_digit($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
}
......@@ -89,13 +89,13 @@ final class Ctype
*
* @see https://php.net/ctype-graph
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_graph($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
}
......@@ -105,13 +105,13 @@ final class Ctype
*
* @see https://php.net/ctype-lower
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_lower($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
}
......@@ -121,13 +121,13 @@ final class Ctype
*
* @see https://php.net/ctype-print
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_print($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
}
......@@ -137,13 +137,13 @@ final class Ctype
*
* @see https://php.net/ctype-punct
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_punct($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
}
......@@ -153,13 +153,13 @@ final class Ctype
*
* @see https://php.net/ctype-space
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_space($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
}
......@@ -169,13 +169,13 @@ final class Ctype
*
* @see https://php.net/ctype-upper
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_upper($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
}
......@@ -185,13 +185,13 @@ final class Ctype
*
* @see https://php.net/ctype-xdigit
*
* @param string|int $text
* @param mixed $text
*
* @return bool
*/
public static function ctype_xdigit($text)
{
$text = self::convert_int_to_char_for_ctype($text);
$text = self::convert_int_to_char_for_ctype($text, __FUNCTION__);
return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
}
......@@ -204,11 +204,12 @@ final class Ctype
* (negative values have 256 added in order to allow characters in the Extended ASCII range).
* Any other integer is interpreted as a string containing the decimal digits of the integer.
*
* @param string|int $int
* @param mixed $int
* @param string $function
*
* @return mixed
*/
private static function convert_int_to_char_for_ctype($int)
private static function convert_int_to_char_for_ctype($int, $function)
{
if (!\is_int($int)) {
return $int;
......@@ -218,6 +219,10 @@ final class Ctype
return (string) $int;
}
if (\PHP_VERSION_ID >= 80100) {
@trigger_error($function.'(): Argument of type int will be interpreted as string in the future', \E_USER_DEPRECATED);
}
if ($int < 0) {
$int += 256;
}
......
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