Commit d4455ace authored by wangdong1's avatar wangdong1

add:update vender

parent f6f4dab6
composer.lock
/vendor/
.idea
.DS_Store
.project
\ No newline at end of file
......@@ -192,7 +192,7 @@ class Daemon
// $to = 'api@yidian-inc.com';
$to = 'zhangyu1@yidian-inc.com';
Email::sendMail('noreply@yidian-inc.com', $to, $subject, $mail_body);
Email::sendMail('bp-noreply@yidian-inc.com', $to, $subject, $mail_body);
}
}
}
......@@ -263,11 +263,12 @@ class Daemon
*/
protected function set_base_config(){
ini_set("display_errors", 1);
error_reporting('E_ALL');
ini_set('date.timezone','Asia/Shanghai');
ini_set("memory_limit", '2048M');
error_reporting(E_ALL);
//日志存储到 php-error.log
/*
//创建任务日志文件
$log_dir = ROOT_PATH.'/logs/daemon/'.$this->task_name;
$log_path = $log_dir.'/'.$this->task_name.'.log';
......@@ -280,6 +281,7 @@ class Daemon
die($log_path."文件无法创建"."\n");
}
}
*/
$this->log_signature = "daemon:".$this->task_name;
}
......
......@@ -14,6 +14,7 @@ use Api\PhpUtils\Common\TimeOut;
use Api\PhpUtils\Http\Request;
use App\Exception\custom\CodeSpecialException;
use Api\PhpUtils\Log\FileLog;
use Api\PhpUtils\Mon\MonUtil;
class JwUser
{
......@@ -25,7 +26,7 @@ class JwUser
*/
public function getUserInfo($params)
{
$url = config('interface', 'service.jw_user.get_user_info');
if (!$url) {
throw new CodeSpecialException("failed");
......@@ -61,7 +62,16 @@ class JwUser
$params = ["userId" => $params['user_id']];
//$user_info = (new TimeOut())->runPost($url, $params);
$user_info = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
$begin = microtime(true);
$user_info = (new Request())->post($url, $params);
$end = microtime(true);
$total_time = round(($end - $begin), 4) * 1000;
if (!empty($user_info['response'])) {
$code = $user_info['response']['code'];
} else {
$code = -1;
}
MonUtil::proxyMon($url, $code, 'jw_user', $total_time);
FileLog::info('jw_user_getUserByUserId', json_encode($user_info));
if (!$user_info) {
throw new CodeSpecialException("timeout");
......@@ -82,7 +92,7 @@ class JwUser
$params = ["userIds" => $params['user_id']];
//$user_info = (new TimeOut())->runPost($url, $params);
$user_info = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
$user_info = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user');
FileLog::info('jw_user_getUserList', json_encode($user_info));
if (!$user_info) {
throw new CodeSpecialException("timeout");
......@@ -129,7 +139,7 @@ class JwUser
throw new CodeSpecialException("failed");
}
//$pushToken = (new TimeOut())->runPost($url, $params);
$pushToken = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
$pushToken = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user');
FileLog::info('jw_user_savePushToken', json_encode($pushToken));
if (!$pushToken) {
throw new CodeSpecialException("timeout");
......@@ -154,7 +164,7 @@ class JwUser
$params = ["userIds" => $params['user_id']];
//$list = (new TimeOut())->runPost($url, $params);
$list = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
$list = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user');
FileLog::info('jw_user_getUserListWithDynamic', json_encode($list));
if (!$list) {
throw new CodeSpecialException("timeout");
......@@ -179,7 +189,7 @@ class JwUser
$params = ["userId" => $params['user_id']];
//$list = (new TimeOut())->runPost($url, $params);
$list = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
$list = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user');
FileLog::info('jw_user_getUserDigg', json_encode($list));
if (!$list) {
throw new CodeSpecialException("timeout");
......@@ -197,11 +207,29 @@ class JwUser
throw new CodeSpecialException("failed");
}
//$ret = (new TimeOut())->runPost($url, $params);
$ret = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
$ret = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user');
FileLog::info('jw_user_saveUpdateLife', json_encode($ret));
if (!$ret) {
throw new CodeSpecialException("timeout");
}
return !empty($ret['response']) ? $ret['response'] : [];
}
}
\ No newline at end of file
/**
* 获取简网微信openid
*/
public static function getWechatOpenid($params)
{
$url = config('interface', 'service.jw_user.get_wechat_openid');
if (!$url) {
throw new CodeSpecialException("failed");
}
//$ret = (new TimeOut())->runPost($url, $params);
$ret = (new Request())->post($url, $params, 0, '', '', 0, true, 'jw_user');
FileLog::info('getWechatOpenid', json_encode($ret));
if (!$ret) {
throw new CodeSpecialException("timeout");
}
return !empty($ret['response']) ? $ret['response'] : [];
}
}
......@@ -3,6 +3,7 @@
namespace Api\PhpServices\Ksy;
use Api\PhpUtils\Http\HttpUtil;
use Api\PhpUtils\Mon\MonUtil;
/**
* 文档: http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=68515904
......@@ -47,7 +48,13 @@ class Ks3Api
"signature" => $signature,
"type" => $type,
];
return HttpUtil::post($url, $params);
$begin = microtime(true);
$genRes = HttpUtil::post($url, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
MonUtil::proxyMon($url, $genRes["response"]['code'], 'ks3api', $totalTime);
return $genRes;
}
/**
......@@ -78,7 +85,13 @@ class Ks3Api
"resource" => $resource,
"headers" => $headers,
];
return HttpUtil::post($url, $params);
$begin = microtime(true);
$signatureRes = HttpUtil::post($url, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
MonUtil::proxyMon($url, $signatureRes["response"]['code'], 'ks3api', $totalTime);
return $signatureRes;
}
/**
......@@ -112,7 +125,13 @@ class Ks3Api
"content_type" => $contentType,
"extend" => $extendJsonStr,
];
return HttpUtil::post($url, $params);
$begin = microtime(true);
$encryptRes = HttpUtil::post($url, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
MonUtil::proxyMon($url, $encryptRes["response"]['code'], 'ks3api', $totalTime);
return $encryptRes;
}
/**
......@@ -139,7 +158,13 @@ class Ks3Api
"signature" => $signature,
"extend" => $extendJsonStr,
];
return HttpUtil::post($url, $params);
$begin = microtime(true);
$uploadRes = HttpUtil::post($url, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
MonUtil::proxyMon($url, $uploadRes["response"]['code'], 'ks3api', $totalTime);
return $uploadRes;
}
/**
......
......@@ -3,7 +3,6 @@
namespace Api\PhpServices\Ksy;
use Api\PhpUtils\Http\Request;
use Api\PhpUtils\Mon\MonUtil;
use GuzzleHttp\TransferStats;
class Ksyun
{
......@@ -41,14 +40,16 @@ class Ksyun
'bucket' => $bucket,
'expire' => $expire_time,
];
$begin = microtime(true);
$res = (new Request())->post(self::get_down_from_ksyun, $post_data,50, 'json',[],1,true);
$end = microtime(true);
$total_time = round(($end - $begin),4) * 1000;
if(isset($res['response']['code'])){
$code = $res['response']['code'];
}else{
$code = -1;
}
(new MonUtil())::proxyMon(self::get_down_from_ksyun, $code, 'merchant',round((new TransferStats())->getHandlerStat('total_time'),4) * 1000);
MonUtil::proxyMon(self::get_down_from_ksyun, $code, 'merchant', $total_time);
if (isset($res['code'],$res['response']['status']) && $res['response']['status'] === 'success') {
return $res['response']['data'];
}
......
<?php
namespace Api\PhpServices\Printer\Fei;
/**
* 飞蛾 打印实现类
*
* @author mengweifu
* @date 2021-7-25 14:00:00
*/
use Api\PhpUtils\Http\HttpUtil;
class FeiPrinter extends \Api\PhpServices\Printer\Printer
{
/**
* *必填*:账号名
*/
private const USER = "yonghui.chen@linkingcities.com";
/**
* *必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】
*/
private const UKEY = "VjPMkB64QNuIIcgQ";
/**
* 飞鹅云打印 api前缀 不需要修改
*/
private const API = "http://api.feieyun.cn/Api/Open/";
/**
* 打印订单
*/
private const API_PRINT = "Open_printMsg";
/**
* 查询打印订单状态
*/
private const API_ORDER_STATUS = "Open_queryOrderState";
/**
* 获取某台打印机状态
*/
private const API_PRINTER_STATUS = "Open_queryPrinterStatus";
/**
* @param string $apiName api 名字
* @return array
*/
private function buildQuery(string $apiName) : array
{
$timestamp = time();
return [
'user' => self::USER,
'stime' => $timestamp,
'sig' => $this->signature(self::USER, self::UKEY, $timestamp),
'apiname' => $apiName
];
}
private function signature(String $user, String $uKey, int $sTime): string
{
return sha1($user . $uKey . $sTime);
}
/**
* 内部函数 查询
* @param string $apiName
* @param array $param
* @return array
*/
private function request(string $apiName,array $param): array
{
$param = $this->buildQuery($apiName) + $param;
return HttpUtil::post(self::API, http_build_query($param));
}
/**
* @inheritDoc
*/
public function addPrinter(array $param): bool
{
// TODO: Implement addPrinter() method.
}
/**
* @inheritDoc
*/
public function deletePrinter(string $printerId): bool
{
// TODO: Implement deletePrinter() method.
}
/**
* @inheritDoc
*/
public function getPrinterStatus(string $printerId): string
{
$res = $this->request(self::API_PRINTER_STATUS, [
'sn' => $printerId,
]);
if ($res['code'] == 0 && isset($res['response'])) {
if ($res['response']['ret'] == 0) {
return $res['response']['data'];
}
throw new Exception($res['response']['msg']);
}
throw new Exception("接口调用异常");
}
/**
* @inheritDoc
*/
public function printContent(string $printerId, array $content):string
{
$formattedContent = "";
$first = true;
foreach ($content as $row) {
$formattedRow = is_array($row) ? implode(' ', $row) : $row;
if ($first) {
$formattedContent .= "<CB>$formattedRow</CB><BR>";
}
else {
$formattedContent .= "$formattedRow<BR>";
}
$first = false;
}
$res = $this->request(self::API_PRINT, [
'sn' => $printerId,
'content' => $formattedContent,
'times' => 1,// 打印联数
]);
if ($res['code'] == 0 && isset($res['response'])) {
if ($res['response']['ret'] == 0) {
return $res['response']['data'];
}
throw new Exception($res['response']['msg']);
}
throw new Exception("接口调用异常");
}
/**
* @inheritDoc
*/
public function getOrderStatus(string $orderId): bool
{
$res = $this->request(self::API_ORDER_STATUS, [
'orderid' => $orderId,
]);
if ($res['code'] == 0 && isset($res['response'])) {
if ($res['response']['ret'] == 0) {
return (bool) $res['response']['data'];
}
throw new Exception($res['response']['msg']);
}
throw new Exception("接口调用异常");
}
}
\ No newline at end of file
<?php
namespace Api\PhpServices\Printer;
/**
* 打印抽象类
*
* @author mengweifu
* @date 2021-7-25 14:00:00
*/
abstract class Printer
{
/**
* 添加打印机
* @param array $param
* @return bool
*/
abstract public function addPrinter(array $param): bool;
/**
* 删除打印机
* @param string $printerId
* @return bool
*/
abstract public function deletePrinter(string $printerId): bool;
/**
* 获取打印机状态
* @param string $printerId
* @return string 状态描述
*/
abstract public function getPrinterStatus(string $printerId): string;
/**
* 打印
* @param string $printerId
* @param array $content 要打印的内容 支持一位数组 二维数组
* @return string 打印OrderID, ID
*/
abstract public function printContent(string $printerId, array $content): string;
/**
* 查询打印状态
* @param string $orderId 为printContent 返回
* @return bool
*/
abstract public function getOrderStatus(string $orderId): bool;
}
\ No newline at end of file
<?php
namespace Api\PhpServices\Printer;
/**
* 打印工厂类
*
* 如何使用:
* $content = [['aaa'], 'bbb'];
* $FeiPrinter = PrinterFactory::getPrinter('Fei');
* $res = $FeiPrinter->printContent('921617329', $content);
* $res = $FeiPrinter->getOrderStatus('921617329_20210725143642_699302110');
* $res = $FeiPrinter->getPrinterStatus('921617329');
* @author mengweifu
* @date 2021-7-25 14:00:00
*/
class PrinterFactory
{
/**
* 获取打印实现类
* @param string $printerName
* @return mixed
* @throws \Exception
*/
public static function getPrinter(string $printerName) : Printer
{
if (! file_exists(__DIR__ .DIRECTORY_SEPARATOR. $printerName. DIRECTORY_SEPARATOR . $printerName . 'Printer.php')) {
throw new \Exception("相应printer未找到");
}
$printerClass = "Api\\PhpServices\\Printer\\${printerName}\\${printerName}Printer";
return new $printerClass;
}
}
\ No newline at end of file
......@@ -173,7 +173,7 @@ class GetImage
// 底部二维码
$qr = new QR($qr_string);
$qr_size = 121;
$qr_size = 100;
$qr->setSize($qr_size);
$qr->setRoundBlockSize(QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN);
$qr_string = $qr->get();
......@@ -252,7 +252,44 @@ class GetImage
return $image_thump;
}
private function curlImage($url, $save_dir='',$filename='',$type=0){
$mimes = array(
'image/bmp'=>'bmp',
'image/gif'=>'gif',
'image/jpeg'=>'jpg',
'image/png'=>'png',
'image/tiff'=>'tiff',
'image/x-icon'=>'ico',
'mage/vnd.wap.wbmp'=>'wbmp',
'image/fax'=>'fax',
'image/pnetvue'=>'net',
'image/vnd.rn-realpix'=>'rp'
);
//创建保存目录
if(!file_exists($save_dir)&&!mkdir($save_dir,0777,true)){
return false;
}
// 获取响应头
if(($headers = get_headers($url, 1))!==false){
$type = $headers['Content-Type'];
if(isset($mimes[$type]))
{
$this->extension = $mimes[$type];
$file_path = $save_dir.$filename.".".$this->extension;
$contents = file_get_contents($url);
if(file_put_contents($file_path , $contents))
{
return $save_dir.$filename.".".$this->extension;
}
}
}
}
private function curlImageBak($url, $save_dir='',$filename='',$type=0){
if(trim($url)==''){
return array('file_name'=>'','save_path'=>'','error'=>1);
}
......
......@@ -81,6 +81,7 @@ class Sms
'ticket_expire' => !empty($params['ticket_expire']) ? $params['ticket_expire'] : 86400,
'resend_times' => !empty($params['resend_times']) ? $params['resend_times'] : 5,
'retry_times' => !empty($params['retry_times']) ? $params['retry_times'] : 10,
'code_expire' => !empty($params['code_expire']) ? $params['code_expire'] : 600,
];
$sms = (new TimeOut())->runGet($url, $params);
......
<?php
namespace Api\PhpServices\Wechat;
use Api\PhpUtils\Common\TimeOut;
use Api\PhpUtils\Http\Request;
use Api\PhpUtils\Http\HttpUtil;
use App\Exception\custom\CodeSpecialException;
class Msg
{
/**
* 发送微信模版消息
*
* @param $mobile 手机号
* @param $template 短信模版
* @param $param = [] 数组,多个参数传值
*/
public static function send($app_id, $secret, $template_id, $user_id, $type, $param = [])
{
$url = config('interface', 'interaction.index.wechat');
if (!$url) {
throw new CodeSpecialException("failed");
}
$params = [
'app_id' => $app_id,
'secret' => $secret,
'user_id' => $user_id,
'template_id' => $template_id,
'type' => $type,
'params' => $param
];
$sms = (new TimeOut())->runGet($url, $params);
if (!$sms) {
throw new CodeSpecialException("timeout");
}
if (!empty($sms) && $sms['code'] == 0) {
return true;
} else {
return false;
}
}
}
use Api\PhpServices\Wechat\Msg;
composer.lock
/vendor/
.idea
.DS_Store
.project
\ No newline at end of file
......@@ -74,36 +74,6 @@ class CacheUtil
return call_user_func_array([$this->handler, $method], $args);
}
/**
* 获取原始数据
* @param $key
* @return mixed
*/
public function getUnChange($key, $prefix = ''){
return $this->handler->get($this->getCacheKey($prefix, $key));
}
/**
* 保存原始数据
* @param $key
* @param $value
* @param $expire
* @return mixed
*/
public function setUnChange($key , $value , $expire = null, $prefix = ''){
if (is_null($expire)) {
// $expire = $this->expire;
return false;
}
$key = $this->getCacheKey($prefix, $key);
if (is_int($expire) && $expire) {
$result = $this->handler->setex($key, $expire, $value);
} else {
$result = $this->handler->set($key, $value);
}
return $result;
}
/**
* 读取缓存
* @access public
......@@ -117,9 +87,7 @@ class CacheUtil
if (is_null($value) || false === $value) {
return $default;
}
$jsonData = json_decode($value, true);
// 检测是否为JSON数据 true 返回JSON解析数组, false返回源数据
return (null === $jsonData) ? $value : $jsonData;
return $value;
}
/**
......@@ -129,24 +97,13 @@ class CacheUtil
* @param mixed $default 默认值
* @return mixed
*/
public function gets($keys, $prefix = '', $default = false)
public function gets($keys, $prefix = '')
{
if(empty($keys) || !is_array($keys)) {
return $default;
return false;
}
$keys = array_values($keys);
$values = $this->handler->mGet($this->getCacheKey($prefix, $keys));
if (is_null($values) || false === $values) {
return $default;
}
$result = [];
foreach((array)$values as $i => $value) {
if($value !== false) {
$jsonData = json_decode($value, true);
$result[$keys[$i]] = (null === $jsonData) ? $value : $jsonData;
}
}
return $result;
return $this->handler->mGet($this->getCacheKey($prefix, $keys));
}
/**
......@@ -165,7 +122,6 @@ class CacheUtil
}
$key = $this->getCacheKey($prefix, $key);
//对数组/对象数据进行缓存处理,保证数据完整性
$value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
if (is_int($expire) && $expire) {
$result = $this->handler->setex($key, $expire, $value);
} else {
......@@ -189,7 +145,6 @@ class CacheUtil
$this->handler->multi();
foreach($items as $key => $value) {
$key = $this->getCacheKey($prefix, $key);
$value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
$this->handler->setex($key, $expire, $value);
}
return $this->handler->exec();
......@@ -210,7 +165,6 @@ class CacheUtil
}
$key = $this->getCacheKey($prefix, $key);
//对数组/对象数据进行缓存处理,保证数据完整性
$value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
if(is_int($expire) && $expire) {
$result = $this->handler->setenx($key, $expire, $value);
} else {
......
<?php
namespace Api\PhpUtils\Common;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
/**
* 根据给定数据生成excel文件,可选择生成本地临时文件或浏览器直接输出
*
* @author
* @since 2021-07-25
*/
class ExportExcel
{
/**
* 获取生成excel文件的绝对地址
*
* @param 必填项 :items {要生成excel的二维数组,array}
* @param 必填项 :keywords {生成excel使用的keywords数组(具体格式详见SendExportMail.class.php中keywords属性),array}
* @param 必填项 :filename {要生成excel的文件名,string}
* @return string {生成的excel文件的绝对地址}
*/
public static function getExcelFilePath($items, array $keywords, $filename = false)
{
$objPHPExcel = self::getPHPExcelObj($items, $keywords, $filename);
$writer = new Xlsx($objPHPExcel);
$filename = "/tmp/" . $filename;
if (file_exists($filename)) {
unlink($filename);
} else {
//$fp = fopen($filename, 'a');
}
//$objWriter->save($filename);
$writer->save($filename);
return $filename;
}
/**
* 生成PHPExcel object用于输出
*
* @param 必填项 :items {要生成excel的数组,array}
* @param 必填项 :keywords {生成excel文件使用的keywords数组(具体格式详见本类中keywords属性),array}
* @param 必填项 :filename {要生成excel的文件名,string}
* @return object {PHPExcel object}
*/
private static function getPHPExcelObj($items, array $keywords, $filename = false)
{
set_time_limit(0);
// Create new PHPExcel object
$objPHPExcel = new \PHPExcel();
// Set document properties
$objPHPExcel->getProperties()
->setCreator("yidian")
->setLastModifiedBy("yidian")
->setTitle("标题")
->setSubject("题目")
->setDescription("描述")
->setKeywords("关键字")
->setCategory("种类");
$ActiveSheet = $objPHPExcel->getActiveSheet();
$keywords = self::getKeywordsWithAlpha($keywords);
foreach ($keywords as $key => $value) {
// set the wdith of cloumn
$ActiveSheet->getColumnDimension($key)->setWidth($value['column_width']);
// set the value of first row
$ActiveSheet->getStyle($key)
->getAlignment()
->setHorizontal('center');
$ActiveSheet->setCellValue($key . '1', $value['column_name']);
}
$index = 2;
if (is_array($items)) {
foreach ($items as $item) {
foreach ($keywords as $key => $value) {
if (0 && is_numeric($item[$value['key']]) && ! is_int($item[$value['key']])) {
$ActiveSheet->setCellValue($key . $index, floatval($item[$value['key']]));
} elseif (0 && is_numeric($item[$value['key']])) {
$ActiveSheet->setCellValue($key . $index, intval($item[$value['key']]));
} else {
$ActiveSheet->setCellValue($key . $index, $item[$value['key']] . ' ');
}
$Alignment = $ActiveSheet->getStyle($key . $index)->getAlignment();
// 换行
$Alignment->setWrapText(true);
// 垂直居中
$Alignment->setVertical('center');
}
$index ++;
}
}
return $objPHPExcel;
}
/**
* 获取生成多sheet页excel文件的绝对地址
*
* @param 必填项 :data {要生成excel的三维数组,sheet页为第一维,array}
* @param 必填项 :filename {要生成excel的文件名,string}
* @return string {生成的excel文件的绝对地址}
*/
public static function getExcelFileForMultiSheet($data, $filename)
{
$objPHPExcel = self::getPHPExcelObjForMultiSheet($data);
$writer = new Xlsx($objPHPExcel);
//$objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel);
$filename = "/tmp/" . $filename;
//$filename = "/Users/work/" . $filename;
if (file_exists($filename)) {
unlink($filename);
} else {
//$fp = fopen($filename, 'a');
}
//$objWriter->save($filename);
$writer->save($filename);
return $filename;
}
/**
* 生成多sheet页 PHPExcel object用于输出
*
* @param 必填项 :data {要生成excel的三维数组,sheet页为第一维,array}
* @param 必填项 :keywords {生成excel文件使用的keywords数组(具体格式详见本类中keywords属性),array}
* @param 必填项 :filename {要生成excel的文件名,string}
* @return object {PHPExcel object}
*/
private static function getPHPExcelObjForMultiSheet($data)
{
set_time_limit(0);
// Create new PHPExcel object
$objPHPExcel = new Spreadsheet();
// Set document properties
$objPHPExcel->getProperties()
->setCreator("yidian")
->setLastModifiedBy("yidian")
->setTitle("标题")
->setSubject("题目")
->setDescription("描述")
->setKeywords("关键字")
->setCategory("种类");
$sheetIndex = 0;
foreach ($data as $sheet) {
$sheetName = !empty($sheet['sheetName']) ? $sheet['sheetName'] : 'sheet'.$sheetIndex;
$topHeader = !empty($sheet['topHeader']) ? $sheet['topHeader'] : '';
$keywords = !empty($sheet['keywords']) ? $sheet['keywords'] : '';
$items = !empty($sheet['items']) ? $sheet['items'] : '';
//创建一个新的工作空间(sheet)
($sheetIndex > 0) && $objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($sheetIndex);
$activeSheet = $objPHPExcel->getActiveSheet();
$activeSheet->setTitle($sheetName);
$index = 1;
$keywords = self::getKeywordsWithAlpha($keywords);
if ($topHeader) {
$indexAlpha = array_keys($keywords);
$endAlpha = end($indexAlpha);
$activeSheet->setCellValue('A1', $topHeader);
$activeSheet->mergeCells('A1:' . $endAlpha . '1');
$activeSheet->getRowDimension(1)->setRowHeight(30);
$activeSheet->getStyle('A1:' . $endAlpha . '1')
->getAlignment()
->setHorizontal('center')
->setVertical('center');
$index++;
}
foreach ($keywords as $key => $value) {
// set the wdith of cloumn
$activeSheet->getColumnDimension($key)->setWidth($value['column_width']);
// set the value of first row
$activeSheet->getStyle($key)
->getAlignment()
->setHorizontal('center');
$activeSheet->setCellValue($key . $index, $value['column_name']);
}
$index++;
if (empty($items) || !is_array($items)) {
continue;
}
foreach ($items as $item) {
foreach ($keywords as $key => $value) {
if (0 && is_numeric($item[$value['key']]) && ! is_int($item[$value['key']])) {
$activeSheet->setCellValue($key . $index, floatval($item[$value['key']]));
} elseif (0 && is_numeric($item[$value['key']])) {
$activeSheet->setCellValue($key . $index, intval($item[$value['key']]));
} else {
$activeSheet->setCellValue($key . $index, $item[$value['key']] . ' ');
}
$alignment = $activeSheet->getStyle($key . $index)->getAlignment();
// 换行
$alignment->setWrapText(true);
// 垂直居中
$alignment->setVertical('center');
}
$index ++;
}
$sheetIndex++;
}
return $objPHPExcel;
}
/**
* 将keywords数组索引转为excel英文列名
*
* @param 必填项 :keywords {keywords数组中下标,array}
* @return array {英文下标的数组(下标类似A,AA,BA)}
*/
private static function getKeywordsWithAlpha($keywords)
{
$keywordsWithAlpha = array();
if (is_array($keywords)) {
foreach ($keywords as $key => $value) {
$keywordsWithAlpha[self::intToUpperAlpha($key)] = $value;
}
}
return $keywordsWithAlpha;
}
/**
* 将数组int索引转化为excel列的列名字符串(A,AA,BA)
*
* @param 必填项 :ord {keywords数组中下标,int}
* @return string {excel列的列名字符串}
*/
private static function intToUpperAlpha($ord)
{
$baseOrd = ord('A');
$mod = floor($ord/26);
if ($mod == 0) {
$retAphla = chr($baseOrd + $ord);
} else {
$retAphla = chr($baseOrd + $mod-1);
$retAphla .= chr($baseOrd + $ord%26);
}
return $retAphla;
}
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ use Api\PhpUtils\Redis\RedisUtil;
class FrequencyLockUtil
{
const MIN_FREQUENCY_SECONDS = 30; // 频率锁默认最小间隔秒数
const MIN_FREQUENCY_SECONDS = 3; // 频率锁默认最小间隔秒数
const MIN_FREQUENCY_TIMES = 1; // 频率锁默认最小间隔秒数内最大访问次数
const PREFIX_FREQUENCY_LOCK = 'flk:';
......@@ -41,7 +41,7 @@ class FrequencyLockUtil
if ($current_times == 1) {
self::$handler->expire($key, $expire);
}
return ($current_times > $times) ? false : true;
return ($current_times > $times) ? true : false;
}
/**
......
......@@ -70,7 +70,7 @@ class FileLog
foreach ($mail_to as $mail) {
$key = md5(sprintf("%s,%s", $mail, md5($signature)));
if (self::shouldSendEmail($key) === true) {
Email::sendMail('noreply@yidian-inc.com', $mail, $subject, $body);
Email::sendMail('bp-noreply@yidian-inc.com', $mail, $subject, $body);
}
}
}
......
......@@ -173,6 +173,10 @@ abstract class MysqlBase
*/
public static function getConnection($type, $flush = false)
{
if(PHP_SAPI == 'cli'){
// cli模式下,不走单例,gone away
//$flush = true;
}
if (!isset(self::$dbConnect[static::CONFIG_INDEX.':'.$type]) || $flush) {
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = new Medoo(self::getDbConf($type));
}
......@@ -495,4 +499,20 @@ abstract class MysqlBase
self::$dbConnect[static::CONFIG_INDEX.':'.$type] = self::getConnection($type);
return self::$dbConnect[static::CONFIG_INDEX.':'.$type]->action($actions);
}
/**
* 销毁所有已存在的连接,守护进程需要手动调用
*
* @return void
*/
public static function destroyConnetion()
{
if(self::$dbConnect) {
foreach(self::$dbConnect as $conn) {
$conn->pdo = null;
unset($conn);
}
self::$dbConnect = [];
}
}
}
......@@ -198,7 +198,8 @@ abstract class MysqlClusterBase
}
}
$end_time = microtime(true);
MonUtil::dbMon(self::$dbCurrentConnect['server'].'_'.self::$dbCurrentConnect['port'] ?? 'unknow_mysql', $method, 'mysql', $end_time-$start_time);
list($dbServer, $dbPort) = self::getDbServerPort($type, $dbShardingIndex);
MonUtil::dbMon($dbServer.'_'.$dbPort, $method, 'mysql', $end_time-$start_time);
return self::formatResult($method, $arguments);
}
......@@ -318,13 +319,21 @@ abstract class MysqlClusterBase
*
* @return array
*/
private static function getDatabaseShardingIndex()
protected static function getDatabaseShardingIndex($dbShardingColumnValue = 0, $dbShardingCompatColumnValue = 0)
{
// 未使用分库
if (!static::SHARDING_DATABASE) {
return 0;
}
if(!empty($dbShardingColumnValue)) {
self::$dbShardingColumnValue = $dbShardingColumnValue;
}
if(!empty($dbShardingCompatColumnValue)) {
self::$dbShardingCompatColumnValue = $dbShardingCompatColumnValue;
}
self::getDbShardingCount();
$dbShardingIndex = 0;
......
......@@ -69,7 +69,7 @@ class RedisUtil
* @param array $options 其他参数数组,优先级高于yaconf中的相同配置
* @param string $options['serverRegion'] 服务区域,不同数据中心
* @param bool $options['master'] 哨兵模式/主从模式,默认true使用主库,若使用从库值为false
* @param string $options['serializer'] 序列化选项,包括 none|php|igbinary, msgpack自己实现msgpack_pack|msgpack_unpack, incr等方法只能使用none,set等方法使用none不能存Array或Object
* @param string $options['serializer'] 序列化选项,包括 none|php|igbinary|json, msgpack自己实现msgpack_pack|msgpack_unpack, incr等方法只能使用none,set等方法使用none不能存Array或Object
* @param boolean $master
* @return mixed
*/
......@@ -368,10 +368,9 @@ class RedisUtil
case 'igbinary':
$this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); // Use igBinary serialize/unserialize
break;
case 'msgpack':
// Undefined class constant 'SERIALIZER_MSGPACK'
// $this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_MSGPACK); // Use msgpack serialize/unserialize
// break;
case 'json':
$this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_JSON); // Use json serialize/unserialize
break;
default:
$this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); // Don't serialize data
break;
......
......@@ -22,6 +22,9 @@ return array(
'Api\\PhpServices\\Ksy\\Ksyun' => $vendorDir . '/api/php_services/src/Ksy/Ksyun.php',
'Api\\PhpServices\\LifeAccount\\Account' => $vendorDir . '/api/php_services/src/LifeAccount/Account.php',
'Api\\PhpServices\\Login\\Login' => $vendorDir . '/api/php_services/src/Login/Login.php',
'Api\\PhpServices\\Printer\\Fei\\FeiPrinter' => $vendorDir . '/api/php_services/src/Printer/Fei/FeiPrinter.php',
'Api\\PhpServices\\Printer\\Printer' => $vendorDir . '/api/php_services/src/Printer/Printer.php',
'Api\\PhpServices\\Printer\\PrinterFactory' => $vendorDir . '/api/php_services/src/Printer/PrinterFactory.php',
'Api\\PhpServices\\PushToken\\Android' => $vendorDir . '/api/php_services/src/PushToken/Android.php',
'Api\\PhpServices\\PushToken\\Base' => $vendorDir . '/api/php_services/src/PushToken/Base.php',
'Api\\PhpServices\\PushToken\\Ios' => $vendorDir . '/api/php_services/src/PushToken/Ios.php',
......@@ -35,6 +38,7 @@ return array(
'Api\\PhpServices\\Sms\\Sms' => $vendorDir . '/api/php_services/src/Sms/Sms.php',
'Api\\PhpServices\\Towerpro\\Towerpro' => $vendorDir . '/api/php_services/src/Towerpro/Towerpro.php',
'Api\\PhpServices\\Tuffy\\TuffyService' => $vendorDir . '/api/php_services/src/Tuffy/TuffyService.php',
'Api\\PhpServices\\Wechat\\Msg' => $vendorDir . '/api/php_services/src/Wechat/Msg.php',
'Api\\PhpServices\\XhProfiler\\XhMongo' => $vendorDir . '/api/php_services/src/XhProfiler/XhMongo.php',
'Api\\PhpServices\\XhProfiler\\XhProfilerService' => $vendorDir . '/api/php_services/src/XhProfiler/XhProfilerService.php',
'Api\\PhpServices\\XhProfiler\\Xhprof' => $vendorDir . '/api/php_services/src/XhProfiler/Xhprof.php',
......@@ -42,6 +46,7 @@ return array(
'Api\\PhpUtils\\Cache\\CacheUtil' => $vendorDir . '/api/php_utils/src/Cache/CacheUtil.php',
'Api\\PhpUtils\\Common\\BaseConvert' => $vendorDir . '/api/php_utils/src/Common/BaseConvert.php',
'Api\\PhpUtils\\Common\\Docid' => $vendorDir . '/api/php_utils/src/Common/Docid.php',
'Api\\PhpUtils\\Common\\ExportExcel' => $vendorDir . '/api/php_utils/src/Common/ExportExcel.php',
'Api\\PhpUtils\\Common\\Geo' => $vendorDir . '/api/php_utils/src/Common/Geo.php',
'Api\\PhpUtils\\Common\\GoodsSkuId' => $vendorDir . '/api/php_utils/src/Common/GoodsSkuId.php',
'Api\\PhpUtils\\Common\\IP' => $vendorDir . '/api/php_utils/src/Common/IP.php',
......
......@@ -256,6 +256,9 @@ class ComposerStaticInit449f7c51756999ca9c3a3daf8077484c
'Api\\PhpServices\\Ksy\\Ksyun' => __DIR__ . '/..' . '/api/php_services/src/Ksy/Ksyun.php',
'Api\\PhpServices\\LifeAccount\\Account' => __DIR__ . '/..' . '/api/php_services/src/LifeAccount/Account.php',
'Api\\PhpServices\\Login\\Login' => __DIR__ . '/..' . '/api/php_services/src/Login/Login.php',
'Api\\PhpServices\\Printer\\Fei\\FeiPrinter' => __DIR__ . '/..' . '/api/php_services/src/Printer/Fei/FeiPrinter.php',
'Api\\PhpServices\\Printer\\Printer' => __DIR__ . '/..' . '/api/php_services/src/Printer/Printer.php',
'Api\\PhpServices\\Printer\\PrinterFactory' => __DIR__ . '/..' . '/api/php_services/src/Printer/PrinterFactory.php',
'Api\\PhpServices\\PushToken\\Android' => __DIR__ . '/..' . '/api/php_services/src/PushToken/Android.php',
'Api\\PhpServices\\PushToken\\Base' => __DIR__ . '/..' . '/api/php_services/src/PushToken/Base.php',
'Api\\PhpServices\\PushToken\\Ios' => __DIR__ . '/..' . '/api/php_services/src/PushToken/Ios.php',
......@@ -269,6 +272,7 @@ class ComposerStaticInit449f7c51756999ca9c3a3daf8077484c
'Api\\PhpServices\\Sms\\Sms' => __DIR__ . '/..' . '/api/php_services/src/Sms/Sms.php',
'Api\\PhpServices\\Towerpro\\Towerpro' => __DIR__ . '/..' . '/api/php_services/src/Towerpro/Towerpro.php',
'Api\\PhpServices\\Tuffy\\TuffyService' => __DIR__ . '/..' . '/api/php_services/src/Tuffy/TuffyService.php',
'Api\\PhpServices\\Wechat\\Msg' => __DIR__ . '/..' . '/api/php_services/src/Wechat/Msg.php',
'Api\\PhpServices\\XhProfiler\\XhMongo' => __DIR__ . '/..' . '/api/php_services/src/XhProfiler/XhMongo.php',
'Api\\PhpServices\\XhProfiler\\XhProfilerService' => __DIR__ . '/..' . '/api/php_services/src/XhProfiler/XhProfilerService.php',
'Api\\PhpServices\\XhProfiler\\Xhprof' => __DIR__ . '/..' . '/api/php_services/src/XhProfiler/Xhprof.php',
......@@ -276,6 +280,7 @@ class ComposerStaticInit449f7c51756999ca9c3a3daf8077484c
'Api\\PhpUtils\\Cache\\CacheUtil' => __DIR__ . '/..' . '/api/php_utils/src/Cache/CacheUtil.php',
'Api\\PhpUtils\\Common\\BaseConvert' => __DIR__ . '/..' . '/api/php_utils/src/Common/BaseConvert.php',
'Api\\PhpUtils\\Common\\Docid' => __DIR__ . '/..' . '/api/php_utils/src/Common/Docid.php',
'Api\\PhpUtils\\Common\\ExportExcel' => __DIR__ . '/..' . '/api/php_utils/src/Common/ExportExcel.php',
'Api\\PhpUtils\\Common\\Geo' => __DIR__ . '/..' . '/api/php_utils/src/Common/Geo.php',
'Api\\PhpUtils\\Common\\GoodsSkuId' => __DIR__ . '/..' . '/api/php_utils/src/Common/GoodsSkuId.php',
'Api\\PhpUtils\\Common\\IP' => __DIR__ . '/..' . '/api/php_utils/src/Common/IP.php',
......
......@@ -7,7 +7,7 @@
"source": {
"type": "git",
"url": "https://gitlab.yidian-inc.com/bp/php_services.git",
"reference": "e68700976b8cca3ecf4de5bfdb8c0df1276a25bd"
"reference": "7018d960b3d6c07fcc92a06011ab8973edd928c0"
},
"require": {
"api/php_utils": "dev-master",
......@@ -15,7 +15,7 @@
"perftools/php-profiler": "^0.18.0",
"php": "7.2.*"
},
"time": "2021-07-14T13:59:01+00:00",
"time": "2021-07-27T13:52:48+00:00",
"default-branch": true,
"type": "library",
"installation-source": "source",
......@@ -34,7 +34,7 @@
"source": {
"type": "git",
"url": "https://gitlab.yidian-inc.com/bp/php_utils.git",
"reference": "3c343d9deec02d60db43c034d1c5916b024eed3a"
"reference": "9dffcd9a08965d274c92810d2331bfa634d8f85a"
},
"require": {
"elasticsearch/elasticsearch": "~7.0",
......@@ -46,7 +46,7 @@
"mongodb/mongodb": "1.4.3",
"php": "7.2.*"
},
"time": "2021-07-14T12:48:42+00:00",
"time": "2021-07-27T13:46:20+00:00",
"default-branch": true,
"type": "library",
"installation-source": "source",
......@@ -1095,8 +1095,8 @@
},
{
"name": "psr/log",
"version": "dev-master",
"version_normalized": "dev-master",
"version": "1.1.4",
"version_normalized": "1.1.4.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
......@@ -1106,19 +1106,12 @@
"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"
},
"time": "2021-05-03T11:20:27+00:00",
"default-branch": true,
"type": "library",
"extra": {
"branch-alias": {
......@@ -1359,27 +1352,21 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "05b35d6cc6227dc22fc053d0cfcd9f41000e2c80"
"reference": "a603e5701bd6e305cfc777a8b50bf081ef73105e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/05b35d6cc6227dc22fc053d0cfcd9f41000e2c80",
"reference": "05b35d6cc6227dc22fc053d0cfcd9f41000e2c80",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/a603e5701bd6e305cfc777a8b50bf081ef73105e",
"reference": "a603e5701bd6e305cfc777a8b50bf081ef73105e",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-php73": "~1.0",
"symfony/polyfill-php80": "^1.15"
"symfony/polyfill-php80": "^1.16"
},
"time": "2021-07-02T16:38:59+00:00",
"time": "2021-07-23T15:55:36+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......@@ -1412,7 +1399,7 @@
"options"
],
"support": {
"source": "https://github.com/symfony/options-resolver/tree/5.3"
"source": "https://github.com/symfony/options-resolver/tree/5.4"
},
"funding": [
{
......@@ -1983,24 +1970,18 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/property-access.git",
"reference": "13c33f29a76bd99976ba7ee20297fa16d5a53a59"
"reference": "12e1e517a315fa3a108dfcd3674e31542055d133"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/13c33f29a76bd99976ba7ee20297fa16d5a53a59",
"reference": "13c33f29a76bd99976ba7ee20297fa16d5a53a59",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/symfony/property-access/zipball/12e1e517a315fa3a108dfcd3674e31542055d133",
"reference": "12e1e517a315fa3a108dfcd3674e31542055d133",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-php80": "^1.15",
"symfony/polyfill-php80": "^1.16",
"symfony/property-info": "^5.2|^6.0"
},
"require-dev": {
......@@ -2009,7 +1990,7 @@
"suggest": {
"psr/cache-implementation": "To cache access methods."
},
"time": "2021-07-03T09:16:21+00:00",
"time": "2021-07-21T12:43:48+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......@@ -2073,24 +2054,18 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/property-info.git",
"reference": "718f093ae4cac054db2bbb39ebf86fd898583ac8"
"reference": "63eddb6d10fffe3f25d901d78fef37ca88838b22"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-info/zipball/718f093ae4cac054db2bbb39ebf86fd898583ac8",
"reference": "718f093ae4cac054db2bbb39ebf86fd898583ac8",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/symfony/property-info/zipball/63eddb6d10fffe3f25d901d78fef37ca88838b22",
"reference": "63eddb6d10fffe3f25d901d78fef37ca88838b22",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-php80": "^1.15",
"symfony/polyfill-php80": "^1.16",
"symfony/string": "^5.1|^6.0"
},
"conflict": {
......@@ -2111,7 +2086,7 @@
"symfony/doctrine-bridge": "To use Doctrine metadata",
"symfony/serializer": "To use Serializer metadata"
},
"time": "2021-07-03T09:16:21+00:00",
"time": "2021-07-21T12:43:48+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
......
......@@ -5,7 +5,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '69c9bde1dd4fb167dc7d1eac77b1bde3fd599f56',
'reference' => 'f6f4dab64859cb2af08951813be34e8e7ba6865d',
'name' => 'bp/pay',
'dev' => true,
),
......@@ -18,7 +18,7 @@
'aliases' => array(
0 => '9999999-dev',
),
'reference' => 'e68700976b8cca3ecf4de5bfdb8c0df1276a25bd',
'reference' => '7018d960b3d6c07fcc92a06011ab8973edd928c0',
'dev_requirement' => false,
),
'api/php_utils' => array(
......@@ -29,7 +29,7 @@
'aliases' => array(
0 => '9999999-dev',
),
'reference' => '3c343d9deec02d60db43c034d1c5916b024eed3a',
'reference' => '9dffcd9a08965d274c92810d2331bfa634d8f85a',
'dev_requirement' => false,
),
'bacon/bacon-qr-code' => array(
......@@ -47,7 +47,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => '69c9bde1dd4fb167dc7d1eac77b1bde3fd599f56',
'reference' => 'f6f4dab64859cb2af08951813be34e8e7ba6865d',
'dev_requirement' => false,
),
'dasprid/enum' => array(
......@@ -191,13 +191,11 @@
),
),
'psr/log' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'pretty_version' => '1.1.4',
'version' => '1.1.4.0',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/log',
'aliases' => array(
0 => '1.1.x-dev',
),
'aliases' => array(),
'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
'dev_requirement' => false,
),
......@@ -236,7 +234,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/options-resolver',
'aliases' => array(),
'reference' => '05b35d6cc6227dc22fc053d0cfcd9f41000e2c80',
'reference' => 'a603e5701bd6e305cfc777a8b50bf081ef73105e',
'dev_requirement' => false,
),
'symfony/polyfill-ctype' => array(
......@@ -311,7 +309,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/property-access',
'aliases' => array(),
'reference' => '13c33f29a76bd99976ba7ee20297fa16d5a53a59',
'reference' => '12e1e517a315fa3a108dfcd3674e31542055d133',
'dev_requirement' => false,
),
'symfony/property-info' => array(
......@@ -320,7 +318,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/property-info',
'aliases' => array(),
'reference' => '718f093ae4cac054db2bbb39ebf86fd898583ac8',
'reference' => '63eddb6d10fffe3f25d901d78fef37ca88838b22',
'dev_requirement' => false,
),
'symfony/string' => array(
......
......@@ -1049,7 +1049,7 @@ class OptionsResolver implements Options
$fmtAllowedTypes = implode('" or "', $this->allowedTypes[$option]);
$fmtProvidedTypes = implode('|', array_keys($invalidTypes));
$allowedContainsArrayType = \count(array_filter($this->allowedTypes[$option], static function ($item) {
return '[]' === substr($item, -2);
return str_ends_with($item, '[]');
})) > 0;
if (\is_array($value) && $allowedContainsArrayType) {
......@@ -1211,6 +1211,8 @@ class OptionsResolver implements Options
/**
* Not supported.
*
* @return void
*
* @throws AccessException
*/
public function offsetSet($option, $value)
......@@ -1221,6 +1223,8 @@ class OptionsResolver implements Options
/**
* Not supported.
*
* @return void
*
* @throws AccessException
*/
public function offsetUnset($option)
......
......@@ -19,7 +19,7 @@
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-php73": "~1.0",
"symfony/polyfill-php80": "^1.15"
"symfony/polyfill-php80": "^1.16"
},
"autoload": {
"psr-4": { "Symfony\\Component\\OptionsResolver\\": "" },
......
......@@ -249,7 +249,7 @@ class PropertyAccessor implements PropertyAccessorInterface
}
if (\PHP_VERSION_ID < 80000) {
if (0 !== strpos($message, 'Argument ')) {
if (!str_starts_with($message, 'Argument ')) {
return;
}
......@@ -466,7 +466,7 @@ class PropertyAccessor implements PropertyAccessorInterface
&& $object instanceof $trace['class']
&& preg_match('/Return value (?:of .*::\w+\(\) )?must be of (?:the )?type (\w+), null returned$/', $e->getMessage(), $matches)
) {
throw new UninitializedPropertyException(sprintf('The method "%s::%s()" returned "null", but expected type "%3$s". Did you forget to initialize a property or to make the return type nullable using "?%3$s"?', false === strpos(\get_class($object), "@anonymous\0") ? \get_class($object) : (get_parent_class($object) ?: key(class_implements($object)) ?: 'class').'@anonymous', $name, $matches[1]), 0, $e);
throw new UninitializedPropertyException(sprintf('The method "%s::%s()" returned "null", but expected type "%3$s". Did you forget to initialize a property or to make the return type nullable using "?%3$s"?', !str_contains(\get_class($object), "@anonymous\0") ? \get_class($object) : (get_parent_class($object) ?: key(class_implements($object)) ?: 'class').'@anonymous', $name, $matches[1]), 0, $e);
}
throw $e;
......@@ -630,7 +630,7 @@ class PropertyAccessor implements PropertyAccessorInterface
private function getWriteInfo(string $class, string $property, $value): PropertyWriteInfo
{
$useAdderAndRemover = \is_array($value) || $value instanceof \Traversable;
$useAdderAndRemover = is_iterable($value);
$key = str_replace('\\', '.', $class).'..'.$property.'..'.(int) $useAdderAndRemover;
if (isset($this->writePropertyCache[$key])) {
......
......@@ -18,7 +18,7 @@
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-php80": "^1.15",
"symfony/polyfill-php80": "^1.16",
"symfony/property-info": "^5.2|^6.0"
},
"require-dev": {
......
......@@ -66,9 +66,9 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
$this->docBlockFactory = $docBlockFactory ?: DocBlockFactory::createInstance();
$this->contextFactory = new ContextFactory();
$this->phpDocTypeHelper = new PhpDocTypeHelper();
$this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : ReflectionExtractor::$defaultMutatorPrefixes;
$this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : ReflectionExtractor::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : ReflectionExtractor::$defaultArrayMutatorPrefixes;
$this->mutatorPrefixes = $mutatorPrefixes ?? ReflectionExtractor::$defaultMutatorPrefixes;
$this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes;
}
/**
......
......@@ -85,9 +85,9 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
*/
public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC, InflectorInterface $inflector = null, int $magicMethodsFlags = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET)
{
$this->mutatorPrefixes = null !== $mutatorPrefixes ? $mutatorPrefixes : self::$defaultMutatorPrefixes;
$this->accessorPrefixes = null !== $accessorPrefixes ? $accessorPrefixes : self::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = null !== $arrayMutatorPrefixes ? $arrayMutatorPrefixes : self::$defaultArrayMutatorPrefixes;
$this->mutatorPrefixes = $mutatorPrefixes ?? self::$defaultMutatorPrefixes;
$this->accessorPrefixes = $accessorPrefixes ?? self::$defaultAccessorPrefixes;
$this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? self::$defaultArrayMutatorPrefixes;
$this->enableConstructorExtraction = $enableConstructorExtraction;
$this->methodReflectionFlags = $this->getMethodsFlags($accessFlags);
$this->propertyReflectionFlags = $this->getPropertyFlags($accessFlags);
......
......@@ -109,14 +109,14 @@ final class PhpDocTypeHelper
return null;
}
if ('[]' === substr($docType, -2)) {
if (str_ends_with($docType, '[]')) {
$collectionKeyType = new Type(Type::BUILTIN_TYPE_INT);
$collectionValueType = $this->createType($type, false, substr($docType, 0, -2));
return new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, $collectionKeyType, $collectionValueType);
}
if (0 === strpos($docType, 'array<') && $type instanceof Array_) {
if (str_starts_with($docType, 'array<') && $type instanceof Array_) {
// array<value> is converted to x[] which is handled above
// so it's only necessary to handle array<key, value> here
$collectionKeyType = $this->getTypes($type->getKeyType())[0];
......
......@@ -25,7 +25,7 @@
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/polyfill-php80": "^1.15",
"symfony/polyfill-php80": "^1.16",
"symfony/string": "^5.1|^6.0"
},
"require-dev": {
......
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