Commit 9d491bad authored by suntengda's avatar suntengda

Merge branch 'pindan_activity_list_optimize' into test

# Conflicts:
#	vendor/composer/installed.json
parents e1af227f e6d987c2
<?php <?php
use Api\PhpUtils\Log\FileLog;
use App\Base\Base; use App\Base\Base;
use App\Services\marketing\MarketingService; use App\Services\marketing\MarketingService;
use App\Exception\custom\MarketingException; use App\Exception\custom\MarketingException;
...@@ -8,8 +7,6 @@ use App\Services\marketing\MarketingGoodsService; ...@@ -8,8 +7,6 @@ use App\Services\marketing\MarketingGoodsService;
use \Validate\MarketingGoodsRateValidate; use \Validate\MarketingGoodsRateValidate;
use \Validate\MarketingOnlineStatusValidate; use \Validate\MarketingOnlineStatusValidate;
use \Validate\MarketingInfoValidate; use \Validate\MarketingInfoValidate;
use App\Models\marketing\mysql\Marketing;
use App\Models\marketing\mysql\MarketingPindan;
use Api\PhpUtils\Redis\RedisUtil; use Api\PhpUtils\Redis\RedisUtil;
class MarketingController extends Base class MarketingController extends Base
...@@ -165,104 +162,52 @@ class MarketingController extends Base ...@@ -165,104 +162,52 @@ class MarketingController extends Base
*/ */
public function tuancan_listAction() public function tuancan_listAction()
{ {
$this->params['marketing_type'] = Marketing::MARKETING_TYPE_PINDAN;//1分销 2团购 3秒杀 4团餐 $page = $this->params['page'] ?? 1;
$this->params['online_status'] = Marketing::ONLINE_STATUS_QIDONG;//状态 , 1启用,2关闭,3 到期 $pageSize = $this->params['page_size'] ?? 20;
$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();
$list = MarketingService::getPindanActiveAndReadyList($page,$pageSize);
$list['end'] = MarketingService::getPindanEndList($page,$pageSize);
$list['life_account_id'] = MarketingService::getPublicLifeAccountId(); $list['life_account_id'] = MarketingService::getPublicLifeAccountId();
$this->success(['result' => $list]); $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'] ?? [];
}
/** /**
* 给列表填充sku和订单相关信息 * 正在进行中的活动简单信息列表
* @param $marketingIds
* @param $list
* @return mixed
* @throws \App\Exception\custom\InterfaceException * @throws \App\Exception\custom\InterfaceException
*/ */
private function _fillSkuAndOrderInfo($marketingIds,$list) { public function pindan_active_basic_listAction()
//获取活动的sku列表 {
$skuList = MarketingService::getGoodsSkuListByMarketingIds($marketingIds); $excludeMarketingId = $this->params['exclude_marketing_id'] ?? '';
//获取活动支付用户列表 $limit = $this->params['limit'] ?? 1;
$orderUser = MarketingService::getMarketingOrderUser(['marketing_id' => $marketingIds]); $list = MarketingService::pindanActiveBasicList($excludeMarketingId,$limit,true);
//获取活动支付用户数 $this->success(['result' => $list]);
$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; /**
* 正在进行和未开始的拼单活动列表
* @throws \App\Exception\custom\InterfaceException
*/
public function pindan_active_and_ready_listAction()
{
$page = $this->params['page'] ?? 1;
$pageSize = $this->params['page_size'] ?? 50;
$list = MarketingService::getPindanActiveAndReadyList($page,$pageSize);
$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]);
}
/** /**
* 切换活动状态 * 切换活动状态
...@@ -285,4 +230,30 @@ class MarketingController extends Base ...@@ -285,4 +230,30 @@ class MarketingController extends Base
$lists = MarketingService::yingxiaoList($this->params); $lists = MarketingService::yingxiaoList($this->params);
$this->success(['result' => $lists]); $this->success(['result' => $lists]);
} }
/**
* 小程序审核查询设置safe_mode版本号
* @throws Exception
*/
public function get_small_program_configAction()
{
$redis = RedisUtil::getInstance('cache',['serializer'=>'none']);
$key = "small_program_config";
$value = $redis->get($key);
$this->success(['result' => $value]);
}
/**
* 小程序审核设置safe_mode版本号
* @throws Exception
*/
public function set_small_program_configAction()
{
$params = $this->params;
$cvVersion = empty($params["version"]) ? "" : $params["version"];
$redis = RedisUtil::getInstance('cache',['serializer'=>'none']);
$key = "small_program_config";
$res = $redis->set($key, $cvVersion);
$this->success(['result' => $res]);
}
} }
\ No newline at end of file
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"require": { "require": {
"php": "7.2.*", "php": "7.2.*",
"ext-json": "*", "ext-json": "*",
"api/php_services":"1.0.15", "api/php_services":"1.0.16",
"api/php_utils":"1.0.17", "api/php_utils":"1.0.17",
"ext-openssl": "*" "ext-openssl": "*"
}, },
......
This diff is collapsed.
...@@ -180,4 +180,61 @@ class Ks3Api ...@@ -180,4 +180,61 @@ class Ks3Api
list($msec, $sec) = explode(' ', microtime()); list($msec, $sec) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); 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); ...@@ -8,18 +8,18 @@ $baseDir = dirname($vendorDir);
return array( return array(
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.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', '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', 'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php', 'ad155f8f1cf0d418fe49e248db8c661b' => $vendorDir . '/react/promise/src/functions_include.php',
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'a9ed0d27b5a698798a89181429f162c5' => $vendorDir . '/khanamiryan/qrcode-detector-decoder/lib/Common/customFunctions.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', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'3a37ebac017bc098e9a86b35401e7a68' => $vendorDir . '/mongodb/mongodb/src/functions.php', '3a37ebac017bc098e9a86b35401e7a68' => $vendorDir . '/mongodb/mongodb/src/functions.php',
'8592c7b0947d8a0965a9e8c3d16f9c24' => $vendorDir . '/elasticsearch/elasticsearch/src/autoload.php',
); );
This diff is collapsed.
...@@ -5,18 +5,18 @@ ...@@ -5,18 +5,18 @@
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
'reference' => '2af24ef59d9888a3a8c64df2ea4efd62c8a675a1', 'reference' => '40f8b230881d7a86438dc069837b93af2d6b8b73',
'name' => 'yidian/yaf_demo', 'name' => 'yidian/yaf_demo',
'dev' => true, 'dev' => true,
), ),
'versions' => array( 'versions' => array(
'api/php_services' => array( 'api/php_services' => array(
'pretty_version' => '1.0.15', 'pretty_version' => '1.0.16',
'version' => '1.0.15.0', 'version' => '1.0.16.0',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../api/php_services', 'install_path' => __DIR__ . '/../api/php_services',
'aliases' => array(), 'aliases' => array(),
'reference' => '590b209014d0ccb8de96dd4cb243eeee41cae47d', 'reference' => 'ea80bdaefe875350b425b0aee11f59bf45d7258d',
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'api/php_utils' => array( 'api/php_utils' => array(
...@@ -223,7 +223,7 @@ ...@@ -223,7 +223,7 @@
'aliases' => array( 'aliases' => array(
0 => '1.23.x-dev', 0 => '1.23.x-dev',
), ),
'reference' => '46cd95797e9df938fdd2b03693b5fca5e64b01ce', 'reference' => 'f24ae462b1d60c333df104f0b81ec7d0e12f6e9f',
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'symfony/polyfill-intl-grapheme' => array( 'symfony/polyfill-intl-grapheme' => array(
...@@ -314,7 +314,7 @@ ...@@ -314,7 +314,7 @@
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
'reference' => '2af24ef59d9888a3a8c64df2ea4efd62c8a675a1', 'reference' => '40f8b230881d7a86438dc069837b93af2d6b8b73',
'dev_requirement' => false, 'dev_requirement' => false,
), ),
), ),
......
...@@ -25,13 +25,13 @@ final class Ctype ...@@ -25,13 +25,13 @@ final class Ctype
* *
* @see https://php.net/ctype-alnum * @see https://php.net/ctype-alnum
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_alnum($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
} }
...@@ -41,13 +41,13 @@ final class Ctype ...@@ -41,13 +41,13 @@ final class Ctype
* *
* @see https://php.net/ctype-alpha * @see https://php.net/ctype-alpha
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_alpha($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
} }
...@@ -57,13 +57,13 @@ final class Ctype ...@@ -57,13 +57,13 @@ final class Ctype
* *
* @see https://php.net/ctype-cntrl * @see https://php.net/ctype-cntrl
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_cntrl($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
} }
...@@ -73,13 +73,13 @@ final class Ctype ...@@ -73,13 +73,13 @@ final class Ctype
* *
* @see https://php.net/ctype-digit * @see https://php.net/ctype-digit
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_digit($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
} }
...@@ -89,13 +89,13 @@ final class Ctype ...@@ -89,13 +89,13 @@ final class Ctype
* *
* @see https://php.net/ctype-graph * @see https://php.net/ctype-graph
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_graph($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
} }
...@@ -105,13 +105,13 @@ final class Ctype ...@@ -105,13 +105,13 @@ final class Ctype
* *
* @see https://php.net/ctype-lower * @see https://php.net/ctype-lower
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_lower($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
} }
...@@ -121,13 +121,13 @@ final class Ctype ...@@ -121,13 +121,13 @@ final class Ctype
* *
* @see https://php.net/ctype-print * @see https://php.net/ctype-print
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_print($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
} }
...@@ -137,13 +137,13 @@ final class Ctype ...@@ -137,13 +137,13 @@ final class Ctype
* *
* @see https://php.net/ctype-punct * @see https://php.net/ctype-punct
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_punct($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
} }
...@@ -153,13 +153,13 @@ final class Ctype ...@@ -153,13 +153,13 @@ final class Ctype
* *
* @see https://php.net/ctype-space * @see https://php.net/ctype-space
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_space($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
} }
...@@ -169,13 +169,13 @@ final class Ctype ...@@ -169,13 +169,13 @@ final class Ctype
* *
* @see https://php.net/ctype-upper * @see https://php.net/ctype-upper
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_upper($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
} }
...@@ -185,13 +185,13 @@ final class Ctype ...@@ -185,13 +185,13 @@ final class Ctype
* *
* @see https://php.net/ctype-xdigit * @see https://php.net/ctype-xdigit
* *
* @param string|int $text * @param mixed $text
* *
* @return bool * @return bool
*/ */
public static function ctype_xdigit($text) 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); return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
} }
...@@ -204,11 +204,12 @@ final class Ctype ...@@ -204,11 +204,12 @@ final class Ctype
* (negative values have 256 added in order to allow characters in the Extended ASCII range). * (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. * 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 * @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)) { if (!\is_int($int)) {
return $int; return $int;
...@@ -218,6 +219,10 @@ final class Ctype ...@@ -218,6 +219,10 @@ final class Ctype
return (string) $int; 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) { if ($int < 0) {
$int += 256; $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