Commit 5cff11f3 by allen

Merge branch 'master' of ssh://119.23.72.7:22611/zhujilai/Order into lt_订单周迭代3.09

parents 151fba26 7a811c86
Showing with 9971 additions and 847 deletions
......@@ -18,6 +18,7 @@ use App\Model\OrderActionLogModel;
use App\Model\OrderReturnModel;
use App\Model\OrderItemsTrackModel;
use Session;
use Hprose\Http\Client;
// 获取订单优惠券金额
function getCoupon($order_id)
......@@ -672,11 +673,51 @@ Class OrderController extends Controller
// 订单导出
public function export(Request $request)
{
$info = $this->_search($request, $request->input('order_goods_type'));
$order_goods_type = $request->input('order_goods_type', 1);
$info = $this->_search($request, $order_goods_type);
if ($order_goods_type == 1) {
$file_name = '联营订单导出';
$source_items_id = Config('website.export_joint_source_id');
$headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', '客服', '商品总额', '运费', '附加费', '优惠券', '订单总额', '人民币总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '是否为新订单'];
$return_url = '/list';
} else {
$file_name = '自营订单导出';
$source_items_id = Config('website.export_self_source_id');
$headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', '客服', '商品总额', '运费', '附加费', '优惠券', '订单总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '销售类型', '业务类型', '自采标记', '项目需求描述','收货联系电话'];
$return_url = '/self_order';
}
$info['map']['p'] = 1;
$potrol = $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http';
$params = [
"type" => 2, // 类型 1:模板调用 2: api回调 (必填)
"source_items_id" => $source_items_id, //设置来源明细id:http://data.ichunt.net/database/1199(必填)
"file_name" => $file_name,//导出后文件名称(必填)
"excel_suf" => "csv", //导出文件格式 csv,xls(必填)
"header" => $headerCell, //导出文件头部 (必填,不得用 ID 做头部,数据顺序必须一致)
"query_param" => $info['map'], //p 第几页,limit每页多少条 占位符,照抄不需要改 (必填)
"callbackurl" => $potrol."://".$_SERVER['HTTP_HOST']."/hprose/service", //hrpose 数据提供网址(提供导出脚本分页回调获取数据,必填)
"callbackfuc" => "orderExport", //hrpose 回调函数(必填)
"create_uid" => $request->user->userId, #创建人id(必填)
];
// 调用导出系统
$url = Config('website.export_url');
$client = new \Hprose\Http\Client($url."/insertExport", false);
$res = $client->insertExport(json_encode($params));
// print_r($res);
$res = json_decode($res, true);
if ($res['err_code'] == 0) return ['err_code'=>0, 'err_msg'=>'推入到导出系统成功', 'data'=>$res['data']];
return ['err_code'=>1, 'err_msg'=>'推入到导出系统失败'];
$orderModel = new OrderModel();
// $orderModel = new OrderModel();
return $orderModel->orderExport($info['map']);
// return $orderModel->orderExport($info['map']);
}
// 下载合同
......
......@@ -3,6 +3,8 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use DB;
use Illuminate\Support\Facades\Redis as Redis;
use App\Model\RegionModel;
class RegionController extends Controller
{
......@@ -38,11 +40,47 @@ class RegionController extends Controller
);
}
//获取省市县名称
public function getRegionName($region_id){
public function getRegionName($region_id)
{
if (empty($region_id)){
return "";
}
$list = DB::connection('order')->table('lie_region')->select("region_name")->where("region_id",$region_id)->get();
return !$list ? "" : current(objectToArray($list))['region_name'];
}
// 初始化地址缓存
public function cache()
{
$RegionModel = new RegionModel();
$province = $RegionModel->getRegion(1); // 获取省
S_str('oms:province', json_encode($province));
$city = $RegionModel->getRegion(2); // 获取城市
foreach($city as $c) {
S_hash('oms:city:'.$c['parent_id'], $c['region_id'], json_encode($c));
}
$district = $RegionModel->getRegion(3); // 获取区
foreach($district as $d) {
S_hash('oms:district:'.$d['parent_id'], $d['region_id'], json_encode($d));
}
echo '设置地址缓存成功';
}
// 清除缓存
public function clear()
{
Redis::del('oms:province');
Redis::del(Redis::keys('oms:city:*'));
Redis::del(Redis::keys('oms:district:*'));
echo '清除地址缓存成功';
}
}
\ No newline at end of file
......@@ -444,4 +444,42 @@ function Autograph(){
// // Session::forget($token); // 验证完毕后删除token
// // return true;
// }
\ No newline at end of file
// }
// 读取Redis缓存
function S_str($key, $value='')
{
static $redis = null;
if ($redis == null) $redis = new \App\Model\RedisModel();
if ($value === '') return json_decode($redis->get($key), true);
return $redis->set($key, $value);
}
function S_hash($key, $field='', $value='')
{
static $redis = null;
if ($redis == null) $redis = new \App\Model\RedisModel();
if ($value === '') {
$data = $field === '' ? $redis->hgetAll($key) : $redis->hget($key, $field);
$datas = [];
if (is_array($data)) {
foreach ($data as $v) {
$datas[] = json_decode($v, true);
}
} else {
$datas = json_decode($data, true);
}
return $datas;
}
return $redis->hset($key, $field, $value);
}
\ No newline at end of file
......@@ -39,9 +39,10 @@ class CheckLogin
$cookie = 'oa_user_id=' . $userId . '; oa_skey=' . $skey;
$client = new \GuzzleHttp\Client();
$rsp = $client->request('GET', $login['check'], [
'headers' => ['Cookie' => $cookie],
'connect_timeout' => 1,
'timeout' => 3
'headers' => ['Cookie' => $cookie],
'connect_timeout' => 1,
'timeout' => 10,
'verify' => false,
]);
if ($rsp->getStatusCode() != 200) {
......
......@@ -54,6 +54,8 @@ Route::group(['middleware' => 'web'], function () {
Route::match(['get', 'post'], '/changeShipping/{id?}', 'OrderController@changeShipping');
Route::post('/region/getAll', 'RegionController@getAll');
Route::get('/region/cache', 'RegionController@cache');
Route::get('/region/clear', 'RegionController@clear');
Route::match(['get', 'post'], '/changeInvoice/{id?}', 'OrderController@changeInvoice');
......@@ -153,5 +155,21 @@ Route::group(['middleware' => 'api'], function () {
Route::get ('/handle/paylog', 'SpecialController@handlePayLog'); // 处理支付记录
Route::get('/act/sendactmsg', 'CronController@sendActMsg'); // 推送活动短信
Route::get ('/handle/paytype', 'SpecialController@changeOrderPayType'); // 自营更改预付款支付方式
Route::post('/hprose/service', function (Request $request) {
$server = new \App\Services\ExportService();
$server->init(); //开启服务
});
Route::get('client', function () {
$server = new \App\Services\TestClient();
$server->index();
});
});
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class OrderAddressModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_address';
protected $primaryKey = 'order_address_id';
public $timestamps = false;
}
\ No newline at end of file
......@@ -23,19 +23,21 @@ class OrderModel extends Model
$userMainModel = new UserMainModel();
$map['testMobile'] = $userMainModel->testMobile();
$list = $this->from('lie_order_items as it')
->leftJoin('lie_order as o', 'it.order_id', '=', 'o.order_id')
->leftJoin('lie_pay_log as p', 'it.order_id', '=', 'p.order_id')
->leftJoin('lie_order_invoice as i', 'it.order_id', '=', 'i.order_id')
->leftJoin('lie_order_extend as oe', 'oe.order_id', '=', 'i.order_id')
->leftJoin('lie_order_address as a', function($join) {
$join->on('it.order_id', '=', 'a.order_id')->where('a.address_type', '=', 1);
})
->leftJoin('lie_order_shipping as s', function($join) {
$join->on('it.order_id', '=', 's.order_id')->where('s.shipping_type', '=', 1);
})
->leftJoin('lie_user_main as u', 'it.user_id', '=', 'u.user_id')
->leftJoin('lie_user_company as c', 'it.user_id', '=', 'c.user_id')
$map['limit'] = isset($map['limit']) ? $map['limit'] : 100;
$map['p'] = isset($map['p']) ? $map['p'] : 1;
$list = $this->from('lie_order as o')
->join('lie_order_items as it', 'o.order_id', '=', 'it.order_id')
->leftJoin('lie_order_invoice as i', 'o.order_id', '=', 'i.order_id')
->leftJoin('lie_order_extend as oe', 'o.order_id', '=', 'oe.order_id')
// ->leftJoin('lie_order_address as a', function($join) {
// $join->on('o.order_id', '=', 'a.order_id')->where('a.address_type', '=', 1);
// })
// ->leftJoin('lie_order_shipping as s', function($join) {
// $join->on('o.order_id', '=', 's.order_id')->where('s.shipping_type', '=', 1);
// })
->leftJoin('lie_user_main as u', 'o.user_id', '=', 'u.user_id')
// ->leftJoin('lie_user_company as c', 'o.user_id', '=', 'c.user_id')
->where(function ($query) use ($map) {
// 查询类型
if (!empty($map['order_contain'])) {
......@@ -176,10 +178,12 @@ class OrderModel extends Model
if (isset($map['is_fake'])) {
$query->where('o.is_type', '=', $map['is_fake']);
}
})
->where(function ($query) use ($map) {
// 支付方式
if (!empty($map['order_payment_mode'])) {
});
if (!empty($map['order_payment_mode'])) {
$list = $list->leftJoin('lie_pay_log as p', 'o.order_id', '=', 'p.order_id')
->where(function ($query) use ($map) {
// 支付方式
$pay_name = explode(',', $map['order_payment_mode']);
$order_payment_mode = [];
......@@ -198,9 +202,10 @@ class OrderModel extends Model
}
$query->whereIn('p.pay_name', $order_payment_mode);
}
})
->where(function ($query) use ($map) {
});
}
$list = $list->where(function ($query) use ($map) {
// 发票类型
if (!empty($map['order_invoice_status'])) {
$query->where('i.inv_type', '=', $map['order_invoice_status']);
......@@ -232,40 +237,47 @@ class OrderModel extends Model
})
->where('it.status', 1)
->where('o.order_goods_type', '=', $map['order_goods_type'])
->select('it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'it.goods_class', 'it.self_supplier_type', 'o.order_id', 'o.order_sn', 'o.order_type', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.sale_type', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'a.consignee', 'a.address', 's.status as shipping_status', 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'u.is_test', 'c.com_name', 'oe.erp_sn', 'oe.send_remark', 'oe.is_new as is_new_order', 'oe.business_type', 'oe.jd_order_id', 'oe.exchange_rate', 'oe.sample_demand_desc','a.mobile as address_mobile','a.province','a.city','a.district')
->select('o.order_id', 'o.order_sn', 'o.order_type', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.sale_type', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'it.goods_class', 'it.self_supplier_type', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'u.is_test', 'oe.erp_sn', 'oe.order_type as extend_order_type', 'oe.send_remark', 'oe.is_new as is_new_order', 'oe.business_type', 'oe.jd_order_id', 'oe.exchange_rate', 'oe.sample_demand_desc')
->groupBy('it.rec_id')
->orderBy('o.create_time', 'DESC')
->get()
->toArray();
// ->get()
// ->toArray();
->paginate($map['limit'], ['*'], 'p', $map['p'])->toArray();
if (!empty($list['data'])) {
$list['data'] = $this->exportList($list['data']); // 订单数据处理
}
return $list;
// dump($list->getBindings());
// dump($list->toSql());
// $tmp = str_replace('?', '"'.'%s'.'"', $list->toSql());
// $tmp = vsprintf($tmp, $list->getBindings());
// echo $tmp;
// exit;
if (!empty($list)) {
// 订单数据处理
$cellData = $this->exportList($list);
// 标题
if ($map['order_goods_type'] == 1) {
$headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', '客服', '商品总额', '运费', '附加费', '优惠券', '订单总额', '人民币总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '是否为新订单'];
} else {
$headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', '客服', '商品总额', '运费', '附加费', '优惠券', '订单总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '销售类型', '业务类型', '自采标记', '项目需求描述','收货联系电话'];
}
array_unshift($cellData, $headerCell);
$fileName = $map['order_goods_type'] == 1 ? '联营订单导出'.date('_YmdHis') : '自营订单导出'.date('_YmdHis');
Excel::create($fileName, function($excel) use ($cellData){
$excel->sheet('订单导出', function($sheet) use ($cellData){
$sheet->rows($cellData);
});
})->export('xls');
} else {
return redirect('/prompt')->with(['message'=>"数据为空无法导出!",'url' =>$_SERVER['HTTP_REFERER'], 'jumpTime'=>3,'status'=>false]);
}
// if (!empty($list)) {
// // 订单数据处理
// $cellData = $this->exportList($list);
// // 标题
// if ($map['order_goods_type'] == 1) {
// $headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', '客服', '商品总额', '运费', '附加费', '优惠券', '订单总额', '人民币总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '是否为新订单'];
// } else {
// $headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', '客服', '商品总额', '运费', '附加费', '优惠券', '订单总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '销售类型', '业务类型', '自采标记', '项目需求描述','收货联系电话'];
// }
// array_unshift($cellData, $headerCell);
// $fileName = $map['order_goods_type'] == 1 ? '联营订单导出'.date('_YmdHis') : '自营订单导出'.date('_YmdHis');
// Excel::create($fileName, function($excel) use ($cellData){
// $excel->sheet('订单导出', function($sheet) use ($cellData){
// $sheet->rows($cellData);
// });
// })->export('xls');
// } else {
// return redirect('/prompt')->with(['message'=>"数据为空无法导出!",'url' =>$_SERVER['HTTP_REFERER'], 'jumpTime'=>3,'status'=>false]);
// }
}
/**
......@@ -314,11 +326,33 @@ class OrderModel extends Model
$tmp = array();
$all_sale_id = array_column($order, 'sale_id');
$all_order_id = array_column($order, 'order_id');
$all_user_id = array_column($order, 'user_id');
// 获取所有客服
$sales = DB::table('user_info')->whereIn('userId', $all_sale_id)->lists('name', 'userId');
// 获取所有价格
$OrderPriceModel = new OrderPriceModel();
$order_price = $OrderPriceModel->whereIn('order_id', $all_order_id)->select('order_id', 'price_type', 'price')->get()->keyBy('order_id')->toArray();
// 获取用户公司名称
$UserCompanyModel = new UserCompanyModel();
$company_info = $UserCompanyModel->whereIn('user_id', $all_user_id)->lists('com_name', 'user_id')->toArray();
// 获取所有订单收货地址
$OrderAddressModel = new OrderAddressModel();
$order_address = $OrderAddressModel->where('address_type', 1)->whereIn('order_id', $all_order_id)->select('order_id', 'mobile', 'consignee', 'province','city','district', 'address')->get()->keyBy('order_id')->toArray();
// 获取所有订单物流信息
$OrderShippingModel = new OrderShippingModel();
$order_shipping = $OrderShippingModel->where('shipping_type', 1)->whereIn('order_id', $all_order_id)->select('order_id', 'status')->get()->keyBy('order_id')->toArray();
for ($i = 0; $i < count($order); $i++) {
// 推送人
if ($order[$i]['sale_id']) {
$sales = DB::table('user_info')->where(['userId' => $order[$i]['sale_id']])->select('name')->first();
}
$current_com_name = isset($company_info[$order[$i]['user_id']]) ? $company_info[$order[$i]['user_id']] : ''; // 当前公司
$current_order_addr = isset($order_address[$order[$i]['order_id']]) ? $order_address[$order[$i]['order_id']] : ''; // 当前订单收货地址
$current_order_shipping = isset($order_shipping[$order[$i]['order_id']]) ? $order_shipping[$order[$i]['order_id']] : ''; // 当前订单物流
$tmp[$i]['order_id'] = $order[$i]['order_id'];
$tmp[$i]['order_sn'] = "\t".$order[$i]['order_sn']."\t";
......@@ -327,11 +361,11 @@ class OrderModel extends Model
$tmp[$i]['user_account'] = $order[$i]['mobile'] ? $order[$i]['mobile'] : $order[$i]['email'];
// $tmp[$i]['is_new'] = $order[$i]['is_new'] == 1 ? '是' : '否'; // 是否为新用户
$tmp[$i]['consignee'] = isset($order[$i]['consignee']) ? $order[$i]['consignee'] : '';
$tmp[$i]['consignee'] = isset($current_order_addr['consignee']) ? $current_order_addr['consignee'] : '';
$tmp[$i]['create_time_date'] = date('Y-m-d', $order[$i]['create_time']);
$tmp[$i]['create_time_sec'] = date('H:i:s', $order[$i]['create_time']);
$tmp[$i]['com_name'] = !empty($order[$i]['tax_title']) ? $order[$i]['tax_title'] : $order[$i]['com_name'];
$tmp[$i]['items_source'] = $this->getOrderSource($order[$i]['order_id'], $order[$i]['order_type']);
$tmp[$i]['com_name'] = !empty($order[$i]['tax_title']) ? $order[$i]['tax_title'] : $current_com_name;
$tmp[$i]['items_source'] = $this->getOrderSource($order[$i]['order_id'], $order[$i]['order_type'], $order[$i]['extend_order_type'], $order[$i]['order_source']);
$tmp[$i]['goods_id'] = $order[$i]['goods_id'];
......@@ -345,7 +379,7 @@ class OrderModel extends Model
$tmp[$i]['single_pre_price'] = $order[$i]['single_pre_price'];
$tmp[$i]['goods_amount'] = $order[$i]['goods_number'] * $order[$i]['goods_price'];
$tmp[$i]['currency'] = $order[$i]['currency'] == 1 ? 'RMB' : 'USD';
$tmp[$i]['sale_name'] = isset($sales) ? $sales->name : ''; // 推送业务员
$tmp[$i]['sale_name'] = isset($sales[$order[$i]['sale_id']]) ? $sales[$order[$i]['sale_id']] : ''; // 推送业务员
if ($i > 0 && $order[$i]['order_id'] == $order[$i-1]['order_id']) {
$tmp[$i]['goods_sum'] = '';
......@@ -358,10 +392,12 @@ class OrderModel extends Model
$tmp[$i]['rmb_amount'] = ''; // 人民币总额
}
} else {
$tmp[$i]['goods_sum'] = $this->getOrderPrice($order[$i]['order_id'], 1);
$tmp[$i]['shipping_fee'] = $this->getOrderPrice($order[$i]['order_id'], 3);
$tmp[$i]['extra_fee'] = $this->getOrderPrice($order[$i]['order_id'], 2);
$tmp[$i]['coupon'] = $this->getOrderPrice($order[$i]['order_id'], -4);
$price = isset($order_price[$order[$i]['order_id']]) ? $order_price[$order[$i]['order_id']] : false;
$tmp[$i]['goods_sum'] = $price && $price['price_type'] == 1 ? $price['price'] : 0;
$tmp[$i]['shipping_fee'] = $price && $price['price_type'] == 3 ? $price['price'] : 0;
$tmp[$i]['extra_fee'] = $price && $price['price_type'] == 2 ? $price['price'] : 0;
$tmp[$i]['coupon'] = $price && $price['price_type'] == -4 ? $price['price'] : 0;
$tmp[$i]['order_amount'] = $order[$i]['order_amount'];
if ($order[$i]['order_goods_type'] == 1) {
......@@ -371,14 +407,19 @@ class OrderModel extends Model
$tmp[$i]['order_type'] = !empty($order[$i]['order_pay_type']) ? Config('params.order_pay_type')[$order[$i]['order_pay_type']] : '未知';
$tmp[$i]['order_status'] = !empty($order[$i]['status']) ? Config('params.order_status')[$order[$i]['status']] : '未知';
$tmp[$i]['shipping_status'] = !empty($order[$i]['shipping_status']) ? $shipping_status[$order[$i]['shipping_status']] : '无发货信息'; // 发货状态
$tmp[$i]['shipping_status'] = !empty($current_order_shipping['status']) ? $shipping_status[$current_order_shipping['status']] : '无发货信息'; // 发货状态
//查询发货地址的省市区
$province = self::get_address_name($order[$i]['province']);
$city = self::get_address_name($order[$i]['city']);
$district = self::get_address_name($order[$i]['district']);
if ($current_order_addr) {
$province = $this->getProvince($current_order_addr['province']);
$city = $this->getCity($current_order_addr['province'], $current_order_addr['city']);
$district = $this->getDistrict($current_order_addr['city'], $current_order_addr['district']);
$tmp[$i]['address'] = $province.$city.$district.$current_order_addr['address'];
} else {
$tmp[$i]['address'] = '';
}
$tmp[$i]['address'] = $province.$city.$district.$order[$i]['address'];
$tmp[$i]['inv_type'] = $order[$i]['inv_type'] ? $inv_type[$order[$i]['inv_type']] : '未知'; // 发票类型
$tmp[$i]['invoice_status'] = !empty($order[$i]['invoice_status']) ? $invoice_status[$order[$i]['invoice_status']] : '无发票信息'; // 发票状态
$tmp[$i]['tax_title'] = $order[$i]['tax_title'];
......@@ -406,15 +447,11 @@ class OrderModel extends Model
$tmp[$i]['business_type'] = $order[$i]['business_type'] ? Config('params.business_type')[$order[$i]['business_type']] : '正常订单';
$tmp[$i]['self_supplier_type'] = $self_supplier_type[$order[$i]['self_supplier_type']]; // 自采标记
$tmp[$i]['sample_demand_desc'] = $order[$i]['sample_demand_desc']; // 样片项目需求描述
//收货地址的电话
$tmp[$i]['receiving_address'] = isset($current_order_addr['address_mobile']) ? $current_order_addr['address_mobile'] : '';
} else {
$tmp[$i]['is_new_order'] = $order[$i]['is_new_order'] == 1 ? '是' : '否'; // 是否为新订单
}
if($order[$i]['order_goods_type'] != 1){
//收货地址的电话
$tmp[$i]['receiving_address'] = $order[$i]['address_mobile'];
}
}
unset($sales);
}
......@@ -422,6 +459,41 @@ class OrderModel extends Model
return $tmp;
}
// 获取省
public function getProvince($region_id)
{
if (!$region_id) return '';
$province = S_str('oms:province');
$filter = array_filter($province, function($v) use ($region_id) {
return $v['region_id'] == $region_id;
});
$filter = array_merge($filter); // 重新索引
return $filter ? $filter[0]['region_name'] : '';
}
// 获取城市
public function getCity($parent_id, $region_id)
{
if (!$parent_id || !$region_id) return '';
$city = S_hash('oms:city:'.$parent_id, $region_id);
return $city ? $city['region_name'] : '';
}
// 获取区
public function getDistrict($parent_id, $region_id)
{
if (!$parent_id || !$region_id) return '';
$district = S_hash('oms:district:'.$parent_id, $region_id);
return $district ? $district['region_name'] : '';
}
public function get_address_name($id){
$result = $this->from('lie_region')->where(['region_id' => $id])->select(array('region_name','parent_id','region_type'))->get()->toArray();
......@@ -467,27 +539,16 @@ class OrderModel extends Model
}
// 获取订单来源
public function getOrderSource($order_id, $order_type=1)
public function getOrderSource($order_id, $order_type=1, $extend_order_type=0, $order_source='')
{
if ($order_type == 1) {
$order = DB::connection('order')->table('lie_order_extend')->where('order_id', $order_id)->select('order_type')->first();
if ($order) {
switch ($order->order_type) {
case 1:
case 2:
case 3:
return '后台';
}
}
$order_source = DB::connection('order')->table('lie_order')->where('order_id', $order_id)->select('order_source')->first();
if ($extend_order_type) return '后台';
if (preg_match('/pf=1/', $order_source->order_source)) {
if (preg_match('/pf=1/', $order_source)) {
$source = 'PC端';
} else if (preg_match('/pf=2/', $order_source->order_source)) {
} else if (preg_match('/pf=2/', $order_source)) {
$source = '移动端';
} else if (preg_match('/pf=6/', $order_source->order_source)) {
} else if (preg_match('/pf=6/', $order_source)) {
$source = '小程序';
} else {
$source = '未知';
......
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class OrderShippingModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_order_shipping';
protected $primaryKey = 'order_shipping_id';
public $timestamps = false;
}
\ No newline at end of file
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
class RegionModel extends Model
{
protected $connection = 'order';
protected $table = 'lie_region';
protected $primaryKey = 'region_id';
public $timestamps = false;
// 获取地址
public function getRegion($region_type=1)
{
$map['region_type'] = $region_type;
return $this->where($map)->select('region_id', 'parent_id', 'region_name')->get()->toArray();
}
}
\ No newline at end of file
<?php
namespace App\Services;
use Hprose\Http\Server;
use App\Model\OrderModel;
class ExportService {
public function init()
{
$server = new Server();
$server->addMethod('test', $this);
$server->addMethod('orderExport', $this);
$server->handle();
}
public function test()
{
return 'hello';
}
// 订单导出
public function orderExport($map)
{
$map = json_decode($map, true);
if (!$map) return json_encode(['code'=>-10001, 'msg'=>'查询条件不能为空']);
$orderModel = new OrderModel();
$list = $orderModel->orderExport($map);
return json_encode(['code'=>0, 'msg'=>'成功', 'count'=>$list['total'], 'data'=>$list['data']]);
}
}
<?php
namespace App\Services;
use Hprose\Http\Client;
class TestClient
{
public function index()
{
//服务端路由在api路由中配置,则此处路由应加上api/test
//实例化可选参数 加上false 即创建创建一个同步的 HTTP 客户端
//不写false 为创建一个异步的 HTTP 客户端
$user =new Client('http://lorder.liexin.net/hprose/service', false);
// $res = $user->test();
$res=$user->orderExport(json_encode(['limit'=>10, 'p'=>1]));
print_r($res);
}
}
......@@ -12,7 +12,8 @@
"guzzlehttp/guzzle": "^6.3",
"predis/predis": "^1.1",
"redgo/monitor-ding": "0.2",
"barryvdh/laravel-debugbar": "^2.0"
"barryvdh/laravel-debugbar": "^2.0",
"hprose/hprose": "2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
......
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2f3bc10e21d2199280e3e49cd3d1b3e9",
"content-hash": "1343d55c7902e2dc79289d433b4bb4d3",
"packages": [
{
"name": "barryvdh/laravel-debugbar",
......@@ -18,7 +18,13 @@
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/d7c88f08131f6404cb714f3f6cf0642f6afa3903",
"reference": "d7c88f08131f6404cb714f3f6cf0642f6afa3903",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
......@@ -67,7 +73,13 @@
"type": "zip",
"url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/4729e438e0ada350f91148e7d4bb9809342575ff",
"reference": "4729e438e0ada350f91148e7d4bb9809342575ff",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"nikic/php-parser": "^1.0|^2.0|^3.0",
......@@ -121,7 +133,13 @@
"type": "zip",
"url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/265b8593498b997dc2d31e75b89f053b5cc9621a",
"reference": "265b8593498b997dc2d31e75b89f053b5cc9621a",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.2"
......@@ -154,7 +172,13 @@
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae",
"reference": "90b2128806bfde671b6952ab8bea493942c1fdae",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.2"
......@@ -221,7 +245,13 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"guzzlehttp/promises": "^1.0",
......@@ -286,7 +316,13 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.0"
......@@ -337,7 +373,13 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.4.0",
......@@ -391,6 +433,89 @@
"time": "2017-03-20T17:10:46+00:00"
},
{
"name": "hprose/hprose",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/hprose/hprose-php.git",
"reference": "380968f189829da4799215a11dca9a0ff147dab6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hprose/hprose-php/zipball/380968f189829da4799215a11dca9a0ff147dab6",
"reference": "380968f189829da4799215a11dca9a0ff147dab6",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": ">=4.0.0"
},
"suggest": {
"ext-hprose": "Faster serialize and unserialize hprose extension."
},
"type": "library",
"autoload": {
"files": [
"src/Hprose.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ma Bingyao",
"email": "andot@hprose.com",
"homepage": "http://hprose.com",
"role": "Developer"
}
],
"description": "It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.",
"homepage": "http://hprose.com/",
"keywords": [
"HTML5",
"Hprose",
"Socket",
"ajax",
"async",
"communication",
"cross-domain",
"cross-language",
"cross-platform",
"framework",
"future",
"game",
"http",
"json",
"jsonrpc",
"library",
"middleware",
"phprpc",
"protocol",
"rpc",
"serialization",
"serialize",
"service",
"tcp",
"unix",
"web",
"webapi",
"webservice",
"websocket",
"xmlrpc"
],
"time": "2016-07-24T16:23:24+00:00"
},
{
"name": "jakub-onderka/php-console-color",
"version": "v0.2",
"source": {
......@@ -402,7 +527,13 @@
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/d5deaecff52a0d61ccb613bb3804088da0307191",
"reference": "d5deaecff52a0d61ccb613bb3804088da0307191",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.4.0"
......@@ -444,7 +575,13 @@
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Highlighter/zipball/7daa75df45242c8d5b75a22c00a201e7954e4fb5",
"reference": "7daa75df45242c8d5b75a22c00a201e7954e4fb5",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"jakub-onderka/php-console-color": "~0.1",
......@@ -488,7 +625,13 @@
"type": "zip",
"url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/5707d5821b30b9a07acfb4d76949784aaa0e9ce9",
"reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"nikic/php-parser": "^1.2|^2.0|^3.0|^4.0",
......@@ -546,7 +689,13 @@
"type": "zip",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/cc84765fb7317f6b07bd8ac78364747f95b86341",
"reference": "cc84765fb7317f6b07bd8ac78364747f95b86341",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.29"
......@@ -612,7 +761,13 @@
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/2a79f920d5584ec6df7cf996d922a742d11095d1",
"reference": "2a79f920d5584ec6df7cf996d922a742d11095d1",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"classpreloader/classpreloader": "~3.0",
......@@ -742,7 +897,13 @@
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2",
"reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
......@@ -826,7 +987,13 @@
"type": "zip",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/731487fda0e3e26c8701d8ee1aafc7b7429a95ce",
"reference": "731487fda0e3e26c8701d8ee1aafc7b7429a95ce",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"illuminate/cache": "5.0.*|5.1.*|5.2.*",
......@@ -893,7 +1060,13 @@
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/afee79a236348e39a44cb837106b7c5b4897ac2a",
"reference": "afee79a236348e39a44cb837106b7c5b4897ac2a",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0",
......@@ -954,7 +1127,13 @@
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0",
......@@ -1032,7 +1211,13 @@
"type": "zip",
"url": "https://api.github.com/repos/mtdowling/cron-expression/zipball/9504fa9ea681b586028adaaa0877db4aecf32bad",
"reference": "9504fa9ea681b586028adaaa0877db4aecf32bad",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.2"
......@@ -1076,7 +1261,13 @@
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/b9a444d829c9a16735aceca1b173e765745bcc0c",
"reference": "b9a444d829c9a16735aceca1b173e765745bcc0c",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.9",
......@@ -1134,7 +1325,13 @@
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4dd659edadffdc2143e4753df655d866dbfeedf0",
"reference": "4dd659edadffdc2143e4753df655d866dbfeedf0",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-tokenizer": "*",
......@@ -1185,7 +1382,13 @@
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/9b3899e3c3ddde89016f576edb8c489708ad64cd",
"reference": "9b3899e3c3ddde89016f576edb8c489708ad64cd",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.2.0"
......@@ -1233,7 +1436,13 @@
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
"reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-xml": "*",
......@@ -1291,7 +1500,13 @@
"type": "zip",
"url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.9"
......@@ -1341,7 +1556,13 @@
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
......@@ -1391,7 +1612,13 @@
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
......@@ -1438,7 +1665,13 @@
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/e64e10b20f8d229cac76399e1f3edddb57a0f280",
"reference": "e64e10b20f8d229cac76399e1f3edddb57a0f280",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"dnoegel/php-xdg-base-dir": "0.1",
......@@ -1510,7 +1743,13 @@
"type": "zip",
"url": "https://api.github.com/repos/GreenLightt/monitorDing/zipball/c75a14a22c6308da89068a67bbd0e6caea05bfe2",
"reference": "c75a14a22c6308da89068a67bbd0e6caea05bfe2",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"laravel/framework": "^5.1"
......@@ -1546,7 +1785,13 @@
"type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/181b89f18a90f8925ef805f950d47a7190e9b950",
"reference": "181b89f18a90f8925ef805f950d47a7190e9b950",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
......@@ -1600,7 +1845,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/926061e74229e935d3c5b4e9ba87237316c6693f",
"reference": "926061e74229e935d3c5b4e9ba87237316c6693f",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -1660,7 +1911,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/b8999c1f33c224b2b66b38253f5e3a838d0d0115",
"reference": "b8999c1f33c224b2b66b38253f5e3a838d0d0115",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
......@@ -1713,7 +1970,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/697c527acd9ea1b2d3efac34d9806bf255278b0a",
"reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -1770,7 +2033,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14",
"reference": "db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.5.9|>=7.0.8"
......@@ -1833,7 +2102,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/3eb4e64c6145ef8b92adefb618a74ebdde9e3fe9",
"reference": "3eb4e64c6145ef8b92adefb618a74ebdde9e3fe9",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
......@@ -1882,7 +2157,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/49ba00f8ede742169cb6b70abe33243f4d673f82",
"reference": "49ba00f8ede742169cb6b70abe33243f4d673f82",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -1935,7 +2216,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/d97ba4425e36e79c794e7d14ff36f00f081b37b3",
"reference": "d97ba4425e36e79c794e7d14ff36f00f081b37b3",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -2017,7 +2304,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
......@@ -2076,7 +2369,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ff208829fe1aa48ab9af356992bb7199fed551af",
"reference": "ff208829fe1aa48ab9af356992bb7199fed551af",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3",
......@@ -2132,7 +2431,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-util/zipball/3b58903eae668d348a7126f999b0da0f2f93611c",
"reference": "3b58903eae668d348a7126f999b0da0f2f93611c",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
......@@ -2184,7 +2489,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/768debc5996f599c4372b322d9061dba2a4bf505",
"reference": "768debc5996f599c4372b322d9061dba2a4bf505",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
......@@ -2233,7 +2544,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/9038984bd9c05ab07280121e9e10f61a7231457b",
"reference": "9038984bd9c05ab07280121e9e10f61a7231457b",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
......@@ -2308,7 +2625,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/eee6c664853fd0576f21ae25725cfffeafe83f26",
"reference": "eee6c664853fd0576f21ae25725cfffeafe83f26",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -2372,7 +2695,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/1f7e071aafc6676fcb6e3f0497f87c2397247377",
"reference": "1f7e071aafc6676fcb6e3f0497f87c2397247377",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -2435,7 +2764,13 @@
"type": "zip",
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/9753fc340726e327e4d48b7c0604f85475ae0bc3",
"reference": "9753fc340726e327e4d48b7c0604f85475ae0bc3",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0",
......@@ -2482,7 +2817,13 @@
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8abb4f9aa89ddea9d52112c65bbe8d0125e2fa8e",
"reference": "8abb4f9aa89ddea9d52112c65bbe8d0125e2fa8e",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.9"
......
......@@ -12,7 +12,7 @@ return [
|
*/
'enabled' => env('APP_DEBUG', false),
'enabled' => env('APP_DEBUG_X', false),
/*
|--------------------------------------------------------------------------
......
......@@ -83,4 +83,9 @@ return [
// crm
'crm_domain' => 'http://lcrm.liexin.net',
// 导出系统
'export_url' => 'http://export.liexin.com',
'export_joint_source_id' => 16,
'export_self_source_id' => 17,
];
......@@ -285,27 +285,53 @@
listUrl += '&order_goods_type='+type;
}
location.href = listUrl;
return listUrl;
}
// 联营搜索
$('.searchOrder').click(function(){
orderListCommon('/list', 1);
})
var listUrl = orderListCommon('/list', 1);
// 联营导出订单
$('.exportExcel').click(function() {
orderListCommon('/export', 1);
location.href = listUrl;
})
// 自营搜索
$('.search_self_order').click(function(){
orderListCommon('/self_order', 2);
var listUrl = orderListCommon('/self_order', 2);
location.href = listUrl;
})
// 联营导出订单
$('.exportExcel').click(function() {
var listUrl = orderListCommon('/export', 1);
$.get(listUrl, function(resp) {
if (resp.err_code != 0) {
layer.msg(resp.err_msg);
return false;
}
window.open(resp.data, '_blank');
})
layer.msg('推入导出系统中...', {icon: 16, time: 1000, shade: 0.3}); // 阻止重复提交
})
// 自营导出订单
$('.self_export').click(function() {
orderListCommon('/export', 2);
var listUrl = orderListCommon('/export', 2);
$.get(listUrl, function(resp) {
if (resp.err_code != 0) {
layer.msg(resp.err_msg);
return false;
}
window.open(resp.data, '_blank');
})
layer.msg('推入导出系统中...', {icon: 16, time: 1000, shade: 0.3}); // 阻止重复提交
})
// 选择查看测试订单
......
......@@ -279,7 +279,7 @@ class ClassLoader
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
......@@ -377,11 +377,11 @@ class ClassLoader
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath.'\\';
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
$length = $this->prefixLengthsPsr4[$first][$search];
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
......
This diff could not be displayed because it is too large.
......@@ -17,6 +17,7 @@ return array(
'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'4a1f389d6ce373bda9e57857d3b61c84' => $vendorDir . '/barryvdh/laravel-debugbar/src/helpers.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'7a3a3ddf55aa5bdbff2cc90a2e666654' => $vendorDir . '/hprose/hprose/src/Hprose.php',
);
This diff could not be displayed because it is too large.
[
{
"name": "barryvdh/laravel-debugbar",
"version": "v2.4.3",
"version_normalized": "2.4.3.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "d7c88f08131f6404cb714f3f6cf0642f6afa3903"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/d7c88f08131f6404cb714f3f6cf0642f6afa3903",
"reference": "d7c88f08131f6404cb714f3f6cf0642f6afa3903",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
"maximebf/debugbar": "~1.13.0",
"php": ">=5.5.9",
"symfony/finder": "~2.7|~3.0"
},
"time": "2017-07-21T11:56:48+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Barryvdh\\Debugbar\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "PHP Debugbar integration for Laravel",
"keywords": [
"debug",
"debugbar",
"laravel",
"profiler",
"webprofiler"
]
},
{
"name": "classpreloader/classpreloader",
"version": "3.2.0",
"version_normalized": "3.2.0.0",
......@@ -12,7 +69,13 @@
"type": "zip",
"url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/4729e438e0ada350f91148e7d4bb9809342575ff",
"reference": "4729e438e0ada350f91148e7d4bb9809342575ff",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"nikic/php-parser": "^1.0|^2.0|^3.0",
......@@ -68,7 +131,13 @@
"type": "zip",
"url": "https://api.github.com/repos/dnoegel/php-xdg-base-dir/zipball/265b8593498b997dc2d31e75b89f053b5cc9621a",
"reference": "265b8593498b997dc2d31e75b89f053b5cc9621a",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.2"
......@@ -103,7 +172,13 @@
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae",
"reference": "90b2128806bfde671b6952ab8bea493942c1fdae",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.2"
......@@ -172,7 +247,13 @@
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3,<8.0-DEV"
......@@ -228,7 +309,13 @@
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/f72816b43e74063c8b10357394b6bba8cb1c10de",
"reference": "f72816b43e74063c8b10357394b6bba8cb1c10de",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.3.3 || ^7.0"
......@@ -280,7 +367,13 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"guzzlehttp/promises": "^1.0",
......@@ -347,7 +440,13 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.0"
......@@ -400,7 +499,13 @@
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.4.0",
......@@ -467,7 +572,13 @@
"type": "zip",
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c",
"reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.2"
......@@ -502,6 +613,91 @@
]
},
{
"name": "hprose/hprose",
"version": "v2.0.0",
"version_normalized": "2.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/hprose/hprose-php.git",
"reference": "380968f189829da4799215a11dca9a0ff147dab6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hprose/hprose-php/zipball/380968f189829da4799215a11dca9a0ff147dab6",
"reference": "380968f189829da4799215a11dca9a0ff147dab6",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": ">=4.0.0"
},
"suggest": {
"ext-hprose": "Faster serialize and unserialize hprose extension."
},
"time": "2016-07-24T16:23:24+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"src/Hprose.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ma Bingyao",
"email": "andot@hprose.com",
"homepage": "http://hprose.com",
"role": "Developer"
}
],
"description": "It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.",
"homepage": "http://hprose.com/",
"keywords": [
"HTML5",
"Hprose",
"Socket",
"ajax",
"async",
"communication",
"cross-domain",
"cross-language",
"cross-platform",
"framework",
"future",
"game",
"http",
"json",
"jsonrpc",
"library",
"middleware",
"phprpc",
"protocol",
"rpc",
"serialization",
"serialize",
"service",
"tcp",
"unix",
"web",
"webapi",
"webservice",
"websocket",
"xmlrpc"
]
},
{
"name": "jakub-onderka/php-console-color",
"version": "v0.2",
"version_normalized": "0.2.0.0",
......@@ -514,7 +710,13 @@
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Color/zipball/d5deaecff52a0d61ccb613bb3804088da0307191",
"reference": "d5deaecff52a0d61ccb613bb3804088da0307191",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.4.0"
......@@ -558,7 +760,13 @@
"type": "zip",
"url": "https://api.github.com/repos/JakubOnderka/PHP-Console-Highlighter/zipball/7daa75df45242c8d5b75a22c00a201e7954e4fb5",
"reference": "7daa75df45242c8d5b75a22c00a201e7954e4fb5",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"jakub-onderka/php-console-color": "~0.1",
......@@ -604,7 +812,13 @@
"type": "zip",
"url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/5707d5821b30b9a07acfb4d76949784aaa0e9ce9",
"reference": "5707d5821b30b9a07acfb4d76949784aaa0e9ce9",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"nikic/php-parser": "^1.2|^2.0|^3.0|^4.0",
......@@ -664,7 +878,13 @@
"type": "zip",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/cc84765fb7317f6b07bd8ac78364747f95b86341",
"reference": "cc84765fb7317f6b07bd8ac78364747f95b86341",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.29"
......@@ -732,7 +952,13 @@
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/2a79f920d5584ec6df7cf996d922a742d11095d1",
"reference": "2a79f920d5584ec6df7cf996d922a742d11095d1",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"classpreloader/classpreloader": "~3.0",
......@@ -852,6 +1078,98 @@
]
},
{
"name": "league/flysystem",
"version": "1.0.46",
"version_normalized": "1.0.46.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2",
"reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
},
"conflict": {
"league/flysystem-sftp": "<1.0.6"
},
"require-dev": {
"ext-fileinfo": "*",
"phpspec/phpspec": "^3.4",
"phpunit/phpunit": "^5.7.10"
},
"suggest": {
"ext-fileinfo": "Required for MimeType",
"ext-ftp": "Allows you to use FTP server storage",
"ext-openssl": "Allows you to use FTPS server storage",
"league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2",
"league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3",
"league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
"league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching",
"league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
"league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
"league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib",
"league/flysystem-webdav": "Allows you to use WebDAV storage",
"league/flysystem-ziparchive": "Allows you to use ZipArchive adapter",
"spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
"srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications"
},
"time": "2018-08-22T07:45:22+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"League\\Flysystem\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frenky.net"
}
],
"description": "Filesystem abstraction: Many filesystems, one API.",
"keywords": [
"Cloud Files",
"WebDAV",
"abstraction",
"aws",
"cloud",
"copy.com",
"dropbox",
"file systems",
"files",
"filesystem",
"filesystems",
"ftp",
"rackspace",
"remote",
"s3",
"sftp",
"storage"
]
},
{
"name": "maatwebsite/excel",
"version": "2.0.11",
"version_normalized": "2.0.11.0",
......@@ -864,7 +1182,13 @@
"type": "zip",
"url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/731487fda0e3e26c8701d8ee1aafc7b7429a95ce",
"reference": "731487fda0e3e26c8701d8ee1aafc7b7429a95ce",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"illuminate/cache": "5.0.*|5.1.*|5.2.*",
......@@ -921,6 +1245,75 @@
]
},
{
"name": "maximebf/debugbar",
"version": "1.13.1",
"version_normalized": "1.13.1.0",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "afee79a236348e39a44cb837106b7c5b4897ac2a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/afee79a236348e39a44cb837106b7c5b4897ac2a",
"reference": "afee79a236348e39a44cb837106b7c5b4897ac2a",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0",
"psr/log": "^1.0",
"symfony/var-dumper": "^2.6|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0"
},
"suggest": {
"kriswallsmith/assetic": "The best way to manage assets",
"monolog/monolog": "Log using Monolog",
"predis/predis": "Redis storage"
},
"time": "2017-01-05T08:46:19+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"DebugBar\\": "src/DebugBar/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maxime Bouroumeau-Fuseau",
"email": "maxime.bouroumeau@gmail.com",
"homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Debug bar in the browser for php application",
"homepage": "https://github.com/maximebf/php-debugbar",
"keywords": [
"debug",
"debugbar"
]
},
{
"name": "mockery/mockery",
"version": "0.9.9",
"version_normalized": "0.9.9.0",
......@@ -933,7 +1326,13 @@
"type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/6fdb61243844dc924071d3404bb23994ea0b6856",
"reference": "6fdb61243844dc924071d3404bb23994ea0b6856",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"hamcrest/hamcrest-php": "~1.1",
......@@ -988,8 +1387,94 @@
]
},
{
"name": "mtdowling/cron-expression",
"version": "v1.2.1",
"name": "monolog/monolog",
"version": "1.24.0",
"version_normalized": "1.24.0.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"time": "2018-11-05T09:00:11+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
]
},
{
"name": "mtdowling/cron-expression",
"version": "v1.2.1",
"version_normalized": "1.2.1.0",
"source": {
"type": "git",
......@@ -1000,7 +1485,13 @@
"type": "zip",
"url": "https://api.github.com/repos/mtdowling/cron-expression/zipball/9504fa9ea681b586028adaaa0877db4aecf32bad",
"reference": "9504fa9ea681b586028adaaa0877db4aecf32bad",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.2"
......@@ -1034,6 +1525,72 @@
]
},
{
"name": "nesbot/carbon",
"version": "1.34.4",
"version_normalized": "1.34.4.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "b9a444d829c9a16735aceca1b173e765745bcc0c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/b9a444d829c9a16735aceca1b173e765745bcc0c",
"reference": "b9a444d829c9a16735aceca1b173e765745bcc0c",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.9",
"symfony/translation": "~2.6 || ~3.0 || ~4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7"
},
"suggest": {
"friendsofphp/php-cs-fixer": "Needed for the `composer phpcs` command. Allow to automatically fix code style.",
"phpstan/phpstan": "Needed for the `composer phpstan` command. Allow to detect potential errors."
},
"time": "2018-11-13T08:26:10+00:00",
"type": "library",
"extra": {
"laravel": {
"providers": [
"Carbon\\Laravel\\ServiceProvider"
]
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brian Nesbitt",
"email": "brian@nesbot.com",
"homepage": "http://nesbot.com"
}
],
"description": "A simple API extension for DateTime.",
"homepage": "http://carbon.nesbot.com",
"keywords": [
"date",
"datetime",
"time"
]
},
{
"name": "nikic/php-parser",
"version": "v2.1.1",
"version_normalized": "2.1.1.0",
......@@ -1046,7 +1603,13 @@
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4dd659edadffdc2143e4753df655d866dbfeedf0",
"reference": "4dd659edadffdc2143e4753df655d866dbfeedf0",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-tokenizer": "*",
......@@ -1099,7 +1662,13 @@
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/9b3899e3c3ddde89016f576edb8c489708ad64cd",
"reference": "9b3899e3c3ddde89016f576edb8c489708ad64cd",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.2.0"
......@@ -1149,7 +1718,13 @@
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5"
......@@ -1205,7 +1780,13 @@
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2",
"reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.6 || ^7.0",
......@@ -1252,7 +1833,13 @@
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7",
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.5 || ^7.0",
......@@ -1301,7 +1888,13 @@
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
"reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-xml": "*",
......@@ -1361,7 +1954,13 @@
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
"reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"doctrine/instantiator": "^1.0.2",
......@@ -1426,7 +2025,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979",
"reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3",
......@@ -1490,7 +2095,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4",
"reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
......@@ -1539,7 +2150,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
"reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
......@@ -1582,7 +2199,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
"reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.3.3 || ^7.0"
......@@ -1633,7 +2256,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16",
"reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-tokenizer": "*",
......@@ -1684,7 +2313,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517",
"reference": "46023de9a91eec7dfb06cc56cb4e260017298517",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-dom": "*",
......@@ -1758,7 +2393,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"doctrine/instantiator": "^1.0.2",
......@@ -1801,7 +2442,8 @@
"keywords": [
"mock",
"xunit"
]
],
"abandoned": true
},
{
"name": "predis/predis",
......@@ -1816,7 +2458,13 @@
"type": "zip",
"url": "https://api.github.com/repos/nrk/predis/zipball/f0210e38881631afeafb56ab43405a92cafd9fd1",
"reference": "f0210e38881631afeafb56ab43405a92cafd9fd1",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.9"
......@@ -1868,7 +2516,13 @@
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
......@@ -1920,7 +2574,13 @@
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
......@@ -1969,7 +2629,13 @@
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/e64e10b20f8d229cac76399e1f3edddb57a0f280",
"reference": "e64e10b20f8d229cac76399e1f3edddb57a0f280",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"dnoegel/php-xdg-base-dir": "0.1",
......@@ -2031,6 +2697,50 @@
]
},
{
"name": "redgo/monitor-ding",
"version": "0.2",
"version_normalized": "0.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/GreenLightt/monitorDing.git",
"reference": "c75a14a22c6308da89068a67bbd0e6caea05bfe2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/GreenLightt/monitorDing/zipball/c75a14a22c6308da89068a67bbd0e6caea05bfe2",
"reference": "c75a14a22c6308da89068a67bbd0e6caea05bfe2",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"laravel/framework": "^5.1"
},
"time": "2018-07-09T09:21:34+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Redgo\\MonitorDing\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "redgo",
"email": "1223858310@qq.com"
}
],
"description": "用于给钉钉自定义机器人发送消息"
},
{
"name": "sebastian/comparator",
"version": "1.2.4",
"version_normalized": "1.2.4.0",
......@@ -2043,7 +2753,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be",
"reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3",
......@@ -2109,7 +2825,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4",
"reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.3.3 || ^7.0"
......@@ -2163,7 +2885,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea",
"reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.3.3 || ^7.0"
......@@ -2215,7 +2943,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4",
"reference": "42c4c2eec485ee3e159ec9884f95b431287edde4",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3",
......@@ -2284,7 +3018,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4",
"reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
......@@ -2337,7 +3077,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7",
"reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
......@@ -2392,7 +3138,13 @@
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
"reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"time": "2015-06-21T13:59:46+00:00",
"type": "library",
......@@ -2429,7 +3181,13 @@
"type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/181b89f18a90f8925ef805f950d47a7190e9b950",
"reference": "181b89f18a90f8925ef805f950d47a7190e9b950",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
......@@ -2485,7 +3243,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/926061e74229e935d3c5b4e9ba87237316c6693f",
"reference": "926061e74229e935d3c5b4e9ba87237316c6693f",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -2547,7 +3311,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/b8999c1f33c224b2b66b38253f5e3a838d0d0115",
"reference": "b8999c1f33c224b2b66b38253f5e3a838d0d0115",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
......@@ -2602,7 +3372,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/697c527acd9ea1b2d3efac34d9806bf255278b0a",
"reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -2661,7 +3437,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/dff8fecf1f56990d88058e3a1885c2a5f1b8e970",
"reference": "dff8fecf1f56990d88058e3a1885c2a5f1b8e970",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -2707,34 +3489,54 @@
"homepage": "https://symfony.com"
},
{
"name": "symfony/finder",
"version": "v3.0.9",
"version_normalized": "3.0.9.0",
"name": "symfony/event-dispatcher",
"version": "v3.4.18",
"version_normalized": "3.4.18.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "3eb4e64c6145ef8b92adefb618a74ebdde9e3fe9"
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/3eb4e64c6145ef8b92adefb618a74ebdde9e3fe9",
"reference": "3eb4e64c6145ef8b92adefb618a74ebdde9e3fe9",
"shasum": ""
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14",
"reference": "db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
"php": "^5.5.9|>=7.0.8"
},
"time": "2016-06-29T05:40:00+00:00",
"conflict": {
"symfony/dependency-injection": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~2.8|~3.0|~4.0",
"symfony/dependency-injection": "~3.3|~4.0",
"symfony/expression-language": "~2.8|~3.0|~4.0",
"symfony/stopwatch": "~2.8|~3.0|~4.0"
},
"suggest": {
"symfony/dependency-injection": "",
"symfony/http-kernel": ""
},
"time": "2018-10-30T16:50:50+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
"Symfony\\Component\\EventDispatcher\\": ""
},
"exclude-from-classmap": [
"/Tests/"
......@@ -2754,23 +3556,86 @@
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Finder Component",
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com"
},
{
"name": "symfony/http-foundation",
"name": "symfony/finder",
"version": "v3.0.9",
"version_normalized": "3.0.9.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "49ba00f8ede742169cb6b70abe33243f4d673f82"
"url": "https://github.com/symfony/finder.git",
"reference": "3eb4e64c6145ef8b92adefb618a74ebdde9e3fe9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/3eb4e64c6145ef8b92adefb618a74ebdde9e3fe9",
"reference": "3eb4e64c6145ef8b92adefb618a74ebdde9e3fe9",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
},
"time": "2016-06-29T05:40:00+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com"
},
{
"name": "symfony/http-foundation",
"version": "v3.0.9",
"version_normalized": "3.0.9.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "49ba00f8ede742169cb6b70abe33243f4d673f82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/49ba00f8ede742169cb6b70abe33243f4d673f82",
"reference": "49ba00f8ede742169cb6b70abe33243f4d673f82",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -2825,7 +3690,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/d97ba4425e36e79c794e7d14ff36f00f081b37b3",
"reference": "d97ba4425e36e79c794e7d14ff36f00f081b37b3",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -2897,6 +3768,197 @@
"homepage": "https://symfony.com"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.10.0",
"version_normalized": "1.10.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"time": "2018-09-21T13:07:52+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
]
},
{
"name": "symfony/polyfill-php56",
"version": "v1.10.0",
"version_normalized": "1.10.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php56.git",
"reference": "ff208829fe1aa48ab9af356992bb7199fed551af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ff208829fe1aa48ab9af356992bb7199fed551af",
"reference": "ff208829fe1aa48ab9af356992bb7199fed551af",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3",
"symfony/polyfill-util": "~1.0"
},
"time": "2018-09-21T06:26:08+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php56\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
]
},
{
"name": "symfony/polyfill-util",
"version": "v1.10.0",
"version_normalized": "1.10.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-util.git",
"reference": "3b58903eae668d348a7126f999b0da0f2f93611c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-util/zipball/3b58903eae668d348a7126f999b0da0f2f93611c",
"reference": "3b58903eae668d348a7126f999b0da0f2f93611c",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.3"
},
"time": "2018-09-30T16:36:12+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Util\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony utilities for portability of PHP codes",
"homepage": "https://symfony.com",
"keywords": [
"compat",
"compatibility",
"polyfill",
"shim"
]
},
{
"name": "symfony/process",
"version": "v3.0.9",
"version_normalized": "3.0.9.0",
......@@ -2909,7 +3971,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/768debc5996f599c4372b322d9061dba2a4bf505",
"reference": "768debc5996f599c4372b322d9061dba2a4bf505",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
......@@ -2960,7 +4028,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/9038984bd9c05ab07280121e9e10f61a7231457b",
"reference": "9038984bd9c05ab07280121e9e10f61a7231457b",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9"
......@@ -3037,7 +4111,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/eee6c664853fd0576f21ae25725cfffeafe83f26",
"reference": "eee6c664853fd0576f21ae25725cfffeafe83f26",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -3103,7 +4183,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/1f7e071aafc6676fcb6e3f0497f87c2397247377",
"reference": "1f7e071aafc6676fcb6e3f0497f87c2397247377",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.9",
......@@ -3168,7 +4254,13 @@
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/af615970e265543a26ee712c958404eb9b7ac93d",
"reference": "af615970e265543a26ee712c958404eb9b7ac93d",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.5.9|>=7.0.8"
......@@ -3225,7 +4317,13 @@
"type": "zip",
"url": "https://api.github.com/repos/tijsverkoyen/CssToInlineStyles/zipball/9753fc340726e327e4d48b7c0604f85475ae0bc3",
"reference": "9753fc340726e327e4d48b7c0604f85475ae0bc3",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0",
......@@ -3274,7 +4372,13 @@
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/8abb4f9aa89ddea9d52112c65bbe8d0125e2fa8e",
"reference": "8abb4f9aa89ddea9d52112c65bbe8d0125e2fa8e",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.9"
......@@ -3326,7 +4430,13 @@
"type": "zip",
"url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a",
"reference": "0df1908962e7a3071564e857d86874dad1ef204a",
"shasum": ""
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.3.3 || ^7.0"
......@@ -3364,621 +4474,5 @@
"check",
"validate"
]
},
{
"name": "league/flysystem",
"version": "1.0.46",
"version_normalized": "1.0.46.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2",
"reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"conflict": {
"league/flysystem-sftp": "<1.0.6"
},
"require-dev": {
"ext-fileinfo": "*",
"phpspec/phpspec": "^3.4",
"phpunit/phpunit": "^5.7.10"
},
"suggest": {
"ext-fileinfo": "Required for MimeType",
"ext-ftp": "Allows you to use FTP server storage",
"ext-openssl": "Allows you to use FTPS server storage",
"league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2",
"league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3",
"league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
"league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching",
"league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
"league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
"league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib",
"league/flysystem-webdav": "Allows you to use WebDAV storage",
"league/flysystem-ziparchive": "Allows you to use ZipArchive adapter",
"spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
"srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications"
},
"time": "2018-08-22T07:45:22+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"League\\Flysystem\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frenky.net"
}
],
"description": "Filesystem abstraction: Many filesystems, one API.",
"keywords": [
"Cloud Files",
"WebDAV",
"abstraction",
"aws",
"cloud",
"copy.com",
"dropbox",
"file systems",
"files",
"filesystem",
"filesystems",
"ftp",
"rackspace",
"remote",
"s3",
"sftp",
"storage"
]
},
{
"name": "monolog/monolog",
"version": "1.24.0",
"version_normalized": "1.24.0.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"time": "2018-11-05T09:00:11+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
]
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.10.0",
"version_normalized": "1.10.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494",
"reference": "c79c051f5b3a46be09205c73b80b346e4153e494",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"time": "2018-09-21T13:07:52+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
]
},
{
"name": "nesbot/carbon",
"version": "1.34.4",
"version_normalized": "1.34.4.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "b9a444d829c9a16735aceca1b173e765745bcc0c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/b9a444d829c9a16735aceca1b173e765745bcc0c",
"reference": "b9a444d829c9a16735aceca1b173e765745bcc0c",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"symfony/translation": "~2.6 || ~3.0 || ~4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7"
},
"suggest": {
"friendsofphp/php-cs-fixer": "Needed for the `composer phpcs` command. Allow to automatically fix code style.",
"phpstan/phpstan": "Needed for the `composer phpstan` command. Allow to detect potential errors."
},
"time": "2018-11-13T08:26:10+00:00",
"type": "library",
"extra": {
"laravel": {
"providers": [
"Carbon\\Laravel\\ServiceProvider"
]
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Brian Nesbitt",
"email": "brian@nesbot.com",
"homepage": "http://nesbot.com"
}
],
"description": "A simple API extension for DateTime.",
"homepage": "http://carbon.nesbot.com",
"keywords": [
"date",
"datetime",
"time"
]
},
{
"name": "symfony/polyfill-util",
"version": "v1.10.0",
"version_normalized": "1.10.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-util.git",
"reference": "3b58903eae668d348a7126f999b0da0f2f93611c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-util/zipball/3b58903eae668d348a7126f999b0da0f2f93611c",
"reference": "3b58903eae668d348a7126f999b0da0f2f93611c",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"time": "2018-09-30T16:36:12+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Util\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony utilities for portability of PHP codes",
"homepage": "https://symfony.com",
"keywords": [
"compat",
"compatibility",
"polyfill",
"shim"
]
},
{
"name": "symfony/polyfill-php56",
"version": "v1.10.0",
"version_normalized": "1.10.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php56.git",
"reference": "ff208829fe1aa48ab9af356992bb7199fed551af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ff208829fe1aa48ab9af356992bb7199fed551af",
"reference": "ff208829fe1aa48ab9af356992bb7199fed551af",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"symfony/polyfill-util": "~1.0"
},
"time": "2018-09-21T06:26:08+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.9-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php56\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
]
},
{
"name": "symfony/event-dispatcher",
"version": "v3.4.18",
"version_normalized": "3.4.18.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14",
"reference": "db9e829c8f34c3d35cf37fcd4cdb4293bc4a2f14",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
},
"conflict": {
"symfony/dependency-injection": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~2.8|~3.0|~4.0",
"symfony/dependency-injection": "~3.3|~4.0",
"symfony/expression-language": "~2.8|~3.0|~4.0",
"symfony/stopwatch": "~2.8|~3.0|~4.0"
},
"suggest": {
"symfony/dependency-injection": "",
"symfony/http-kernel": ""
},
"time": "2018-10-30T16:50:50+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\EventDispatcher\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com"
},
{
"name": "redgo/monitor-ding",
"version": "0.2",
"version_normalized": "0.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/GreenLightt/monitorDing.git",
"reference": "c75a14a22c6308da89068a67bbd0e6caea05bfe2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/GreenLightt/monitorDing/zipball/c75a14a22c6308da89068a67bbd0e6caea05bfe2",
"reference": "c75a14a22c6308da89068a67bbd0e6caea05bfe2",
"shasum": ""
},
"require": {
"laravel/framework": "^5.1"
},
"time": "2018-07-09T09:21:34+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Redgo\\MonitorDing\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "redgo",
"email": "1223858310@qq.com"
}
],
"description": "用于给钉钉自定义机器人发送消息"
},
{
"name": "maximebf/debugbar",
"version": "1.13.1",
"version_normalized": "1.13.1.0",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "afee79a236348e39a44cb837106b7c5b4897ac2a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/afee79a236348e39a44cb837106b7c5b4897ac2a",
"reference": "afee79a236348e39a44cb837106b7c5b4897ac2a",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "^1.0",
"symfony/var-dumper": "^2.6|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0"
},
"suggest": {
"kriswallsmith/assetic": "The best way to manage assets",
"monolog/monolog": "Log using Monolog",
"predis/predis": "Redis storage"
},
"time": "2017-01-05T08:46:19+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"DebugBar\\": "src/DebugBar/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maxime Bouroumeau-Fuseau",
"email": "maxime.bouroumeau@gmail.com",
"homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Debug bar in the browser for php application",
"homepage": "https://github.com/maximebf/php-debugbar",
"keywords": [
"debug",
"debugbar"
]
},
{
"name": "barryvdh/laravel-debugbar",
"version": "v2.4.3",
"version_normalized": "2.4.3.0",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "d7c88f08131f6404cb714f3f6cf0642f6afa3903"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/d7c88f08131f6404cb714f3f6cf0642f6afa3903",
"reference": "d7c88f08131f6404cb714f3f6cf0642f6afa3903",
"shasum": ""
},
"require": {
"illuminate/support": "5.1.*|5.2.*|5.3.*|5.4.*|5.5.*",
"maximebf/debugbar": "~1.13.0",
"php": ">=5.5.9",
"symfony/finder": "~2.7|~3.0"
},
"time": "2017-07-21T11:56:48+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Barryvdh\\Debugbar\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "PHP Debugbar integration for Laravel",
"keywords": [
"debug",
"debugbar",
"laravel",
"profiler",
"webprofiler"
]
}
]
temp
vendor
composer.phar
composer.lock
/netbeans
/nbproject
/examples/nbproject
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
sudo: required
before_script:
- composer install
- cd tests
script: phpunit -v
The MIT License (MIT)
Copyright (c) 2008-2016 http://hprose.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Hprose for PHP
[![Build Status](https://travis-ci.org/hprose/hprose-php.svg?branch=master)](https://travis-ci.org/hprose/hprose-php)
[![Join the chat at https://gitter.im/hprose/hprose-php](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/hprose/hprose-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Supported PHP versions: 5.3 .. 7.1](https://img.shields.io/badge/php-5.3~7.1-blue.svg)
[![Packagist](https://img.shields.io/packagist/v/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
[![Packagist Download](https://img.shields.io/packagist/dm/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
[![License](https://img.shields.io/packagist/l/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
## Introduction
*Hprose* is a High Performance Remote Object Service Engine.
It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.
*Hprose* supports many programming languages, for example:
* AAuto Quicker
* ActionScript
* ASP
* C++
* Dart
* Delphi/Free Pascal
* dotNET(C#, Visual Basic...)
* Golang
* Java
* JavaScript
* Node.js
* Objective-C
* Perl
* PHP
* Python
* Ruby
* ...
Through *Hprose*, You can conveniently and efficiently intercommunicate between those programming languages.
This project is the implementation of Hprose for PHP.
Hprose 2.0 for PHP Documents: https://github.com/hprose/hprose-php/wiki
# Hprose for PHP
[![Build Status](https://travis-ci.org/hprose/hprose-php.svg?branch=master)](https://travis-ci.org/hprose/hprose-php)
[![Join the chat at https://gitter.im/hprose/hprose-php](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/hprose/hprose-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Supported PHP versions: 5.3 .. 7.1](https://img.shields.io/badge/php-5.3~7.1-blue.svg)
[![Packagist](https://img.shields.io/packagist/v/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
[![Packagist Download](https://img.shields.io/packagist/dm/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
[![License](https://img.shields.io/packagist/l/hprose/hprose.svg)](https://packagist.org/packages/hprose/hprose)
## 简介
*Hprose* 是高性能远程对象服务引擎(High Performance Remote Object Service Engine)的缩写。
它是一个先进的轻量级的跨语言跨平台面向对象的高性能远程动态通讯中间件。它不仅简单易用,而且功能强大。你只需要稍许的时间去学习,就能用它轻松构建跨语言跨平台的分布式应用系统了。
*Hprose* 支持众多编程语言,例如:
* AAuto Quicker
* ActionScript
* ASP
* C++
* Dart
* Delphi/Free Pascal
* dotNET(C#, Visual Basic...)
* Golang
* Java
* JavaScript
* Node.js
* Objective-C
* Perl
* PHP
* Python
* Ruby
* ...
通过 *Hprose*,你就可以在这些语言之间方便高效的实现互通了。
本项目是 Hprose 的 PHP 语言版本实现。
Hprose 2.0 for PHP 文档: https://github.com/hprose/hprose-php/wiki
{
"name": "hprose/hprose",
"type": "library",
"description": "It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.",
"keywords": [
"hprose",
"phprpc",
"rpc",
"webservice",
"websocket",
"http",
"ajax",
"json",
"jsonrpc",
"xmlrpc",
"cross-language",
"cross-platform",
"cross-domain",
"html5",
"serialize",
"serialization",
"protocol",
"web",
"service",
"framework",
"library",
"game",
"communication",
"middleware",
"webapi",
"socket",
"tcp",
"async",
"unix",
"future"
],
"homepage": "http://hprose.com/",
"license": "MIT",
"authors": [
{
"name": "Ma Bingyao",
"email": "andot@hprose.com",
"homepage": "http://hprose.com",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"suggest": {
"ext-hprose": "Faster serialize and unserialize hprose extension."
},
"require-dev": {
"phpunit/phpunit": ">=4.0.0"
},
"autoload": {
"files": ["src/Hprose.php"]
}
}
{
"name": "hprose/examples",
"description": "examples of hprose",
"authors": [
{
"name": "andot",
"email": "mabingyao@gmail.com"
}
],
"require": {
"php": ">=5.3.0",
"hprose/hprose": "dev-master"
}
}
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
Future\all(array(1, Future\value(2), 3))->then(function($value) {
var_dump($value);
});
Future\join(1, Future\value(2), 3)->then(function($value) {
var_dump($value);
});
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$p = Future\reject(new OutOfRangeException());
$p->catchError(function($reason) { return 'this is a OverflowException'; },
function($reason) { return $reason instanceof OverflowException; })
->catchError(function($reason) { return 'this is a OutOfRangeException'; },
function($reason) { return $reason instanceof OutOfRangeException; })
->then(function($value) { var_dump($value); });
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use \Hprose\Future;
use \Hprose\Http\Client;
Future\co(function() {
$test = new Client("http://hprose.com/example/");
var_dump((yield $test->hello("hprose")));
$a = $test->sum(1, 2, 3);
$b = $test->sum(4, 5, 6);
$c = $test->sum(7, 8, 9);
var_dump((yield $test->sum($a, $b, $c)));
var_dump((yield $test->hello("world")));
});
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use \Hprose\Future;
use \Hprose\Http\Client;
$test = new Client("http://hprose.com/example/");
Future\co(function() use ($test) {
for ($i = 0; $i < 5; $i++) {
var_dump((yield $test->hello("1-" . $i)));
}
});
Future\co(function() use ($test) {
for ($i = 0; $i < 5; $i++) {
var_dump((yield $test->hello("2-" . $i)));
}
});
<?php
require_once "../vendor/autoload.php";
use \Hprose\Future;
use \Hprose\Http\Client;
$test = new Client("http://hprose.com/example/");
function hello($n, $test) {
$result = array();
for ($i = 0; $i < 5; $i++) {
$result[] = $test->hello("$n-$i");
}
yield $result;
}
Future\co(function() use ($test) {
$result = (yield Future\co(function($test) {
$result = array();
for ($i = 0; $i < 3; $i++) {
$result[] = Future\co('hello', $i, $test);
}
yield $result;
}, $test));
var_dump($result);
});
<?php
require_once "../vendor/autoload.php";
use \Hprose\Future;
use \Hprose\Http\Client;
$test = new Client("http://hprose.com/example/");
Future\co(function() use ($test) {
for ($i = 0; $i < 5; $i++) {
var_dump((yield $test->hello("1-" . $i)));
}
$var_dump = Future\wrap('var_dump');
for ($i = 0; $i < 5; $i++) {
$var_dump($test->hello("2-" . $i));
}
for ($i = 0; $i < 5; $i++) {
var_dump((yield $test->hello("3-" . $i)));
}
});
<?php
require_once "../vendor/autoload.php";
use \Hprose\Future;
use \Hprose\Http\Client;
$test = new Client("http://hprose.com/example/");
$coroutine = Future\wrap(function($test) {
var_dump(1);
var_dump((yield $test->hello("hprose")));
$a = $test->sum(1, 2, 3);
$b = $test->sum(4, 5, 6);
$c = $test->sum(7, 8, 9);
var_dump((yield $test->sum($a, $b, $c)));
var_dump((yield $test->hello("world")));
});
$coroutine($test);
$coroutine(Future\value($test));
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use \Hprose\Future;
class Test {
function test($x) {
yield $x;
}
}
$test = Future\wrap(new Test());
$test->test(123)->then('var_dump');
$test->test(Future\value('hello'))->then('var_dump');
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use Hprose\Completer;
$completer = new Completer();
$promise = $completer->future();
$promise->then(function($value) {
var_dump($value);
});
var_dump($completer->isCompleted());
$completer->complete('hprose');
var_dump($completer->isCompleted());
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
function dumpArray($value, $key) {
var_dump("a[$key] = $value");
}
$a1 = array(2, Future\value(5), 9);
$a2 = array('name' => Future\value('Tom'), 'age' => Future\value(18));
Future\each($a1, 'dumpArray');
Future\each($a2, 'dumpArray');
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
function dumpArray($value, $key) {
var_dump("a[$key] = $value");
}
$a1 = Future\value(array(2, Future\value(5), 9));
$a2 = Future\value(array('name' => Future\value('Tom'), 'age' => Future\value(18)));
$a1->each('dumpArray');
$a2->each('dumpArray');
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
function isBigEnough($value) {
return $value >= 10;
}
$a1 = array(12, Future\value(5), 8, Future\value(130), 44);
$a2 = array(12, Future\value(54), 18, Future\value(130), 44);
$a3 = Future\value($a1);
$a4 = Future\value($a2);
$dump(Future\every($a1, 'isBigEnough')); // false
$dump(Future\every($a2, 'isBigEnough')); // true
$dump(Future\every($a3, 'isBigEnough')); // false
$dump(Future\every($a4, 'isBigEnough')); // true
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
function isBigEnough($value) {
return $value >= 10;
}
$a1 = Future\value(array(12, Future\value(5), 8, Future\value(130), 44));
$a2 = Future\value(array(12, Future\value(54), 18, Future\value(130), 44));
$dump($a1->every('isBigEnough')); // false
$dump($a2->every('isBigEnough')); // true
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
function isBigEnough($value) {
return $value >= 8;
}
$a1 = array(12, Future\value(5), 8, Future\value(130), 44);
$a2 = Future\value($a1);
$dump(Future\filter($a1, 'isBigEnough'));
$dump(Future\filter($a2, 'isBigEnough'));
$a3 = array('Tom' => 8, 'Jerry' => Future\value(5), 'Spike' => 10, 'Tyke' => 3);
$a4 = Future\value($a3);
$dump(Future\filter($a3, 'isBigEnough'));
$dump(Future\filter($a3, 'isBigEnough', true));
$dump(Future\filter($a4, 'isBigEnough', true));
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
function isBigEnough($value) {
return $value >= 8;
}
$a = Future\value(array(
'Tom' => 8,
'Jerry' => Future\value(5),
'Spike' => 10,
'Tyke' => 3
));
$dump($a->filter('isBigEnough'));
$dump($a->filter('isBigEnough', true));
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
var_dump(Future\isFuture(123));
var_dump(Future\isFuture(Future\value(123)));
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
$a = array(1, Future\value(4), 9);
$dump(Future\map($a, 'sqrt'));
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
$a = Future\value(array(1, Future\value(4), 9));
$dump($a->map('sqrt'));
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$p = Future\promise(function($resolve, $reject) {
$a = 1;
$b = 2;
if ($a != $b) {
$resolve('OK');
}
else {
$reject(new Exception("$a == $b"));
}
});
$p->then(function($value) {
var_dump($value);
});
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
$numbers = array(Future\value(0), 1, Future\value(2), 3, Future\value(4));
function add($a, $b) {
return $a + $b;
}
$dump(Future\reduce($numbers, 'add'));
$dump(Future\reduce($numbers, 'add', 10));
$dump(Future\reduce($numbers, 'add', Future\value(20)));
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
$numbers = Future\value(array(Future\value(0), 1, Future\value(2), 3, Future\value(4)));
function add($a, $b) {
return $a + $b;
}
$dump($numbers->reduce('add'));
$dump($numbers->reduce('add', 10));
$dump($numbers->reduce('add', Future\value(20)));
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
function add($a, $b) {
return $a + $b;
}
$p1 = Future\resolve(3);
Future\run('add', 2, $p1)->then('var_dump');
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
$numbers = Future\value(array(Future\value(0), 1, Future\value(2), 3, Future\value(4)));
$dump($numbers->search(2));
$dump($numbers->search(Future\value(3)));
$dump($numbers->search(true));
$dump($numbers->search(true, true));
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
$numbers = array(Future\value(0), 1, Future\value(2), 3, Future\value(4));
$dump(Future\search($numbers, 2));
$dump(Future\search($numbers, Future\value(3)));
$dump(Future\search($numbers, true));
$dump(Future\search($numbers, true, true));
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$p1 = Future\resolve(3);
$p2 = Future\reject(new Exception("x"));
Future\settle(array(true, $p1, $p2))->then('print_r');
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
function isBigEnough($value) {
return $value >= 10;
}
$a1 = array(12, Future\value(5), 8, Future\value(130), 44);
$a2 = array(1, Future\value(5), 8, Future\value(1), 4);
$a3 = Future\value($a1);
$a4 = Future\value($a2);
$dump(Future\some($a1, 'isBigEnough')); // true
$dump(Future\some($a2, 'isBigEnough')); // false
$dump(Future\some($a3, 'isBigEnough')); // true
$dump(Future\some($a4, 'isBigEnough')); // false
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$dump = Future\wrap('var_dump');
function isBigEnough($value) {
return $value >= 10;
}
$a1 = Future\value(array(12, Future\value(5), 8, Future\value(130), 44));
$a2 = Future\value(array(1, Future\value(5), 8, Future\value(1), 4));
$dump($a1->some('isBigEnough')); // true
$dump($a2->some('isBigEnough')); // false
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$p1 = new Future(function() {
return array(Future\value(1), Future\value(2));
});
$p1->then(function($value) {
var_dump($value);
});
$p2 = Future\sync(function() {
return array(Future\value(1), Future\value(2));
});
$p2->then(function($value) {
var_dump($value);
});
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$a = array(1, Future\value(2), 3, Future\value(4), 5);
$o = new \stdClass();
$o->name = Future\value("Tom");
$o->age = Future\value(18);
Future\toFuture($a)->then(function($value) {
var_dump($value);
});
Future\toFuture($o)->then(function($value) {
var_dump($value);
});
Future\toPromise($a)->then(function($value) {
var_dump($value);
});
Future\toPromise($o)->then(function($value) {
var_dump($value);
});
\ No newline at end of file
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
$p1 = Future\resolve('resolve hprose');
$p1->whenComplete(function() {
var_dump('p1 complete');
})->then(function($value) {
var_dump($value);
});
$p2 = Future\reject(new Exception('reject thrift'));
$p2->whenComplete(function() {
var_dump('p2 complete');
})->catchError(function($reason) {
var_dump($reason->getMessage());
});
$p3 = Future\resolve('resolve protobuf');
$p3->whenComplete(function() {
var_dump('p3 complete');
throw new Exception('reject protobuf');
})->catchError(function($reason) {
var_dump($reason->getMessage());
});
<?php
require_once "../vendor/autoload.php";
use Hprose\Future;
class Test {
function add($a, $b) {
return $a + $b;
}
function sub($a, $b) {
return $a - $b;
}
function mul($a, $b) {
return $a * $b;
}
function div($a, $b) {
return $a / $b;
}
}
$var_dump = Future\wrap('var_dump');
$test = Future\wrap(new Test());
$var_dump($test->add(1, Future\value(2)));
$var_dump($test->sub(Future\value(1), 2));
$var_dump($test->mul(Future\value(1), Future\value(2)));
$var_dump($test->div(1, 2));
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose.php *
* *
* hprose for php 5.3+ *
* *
* LastModified: Jul 24, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
require_once 'Throwable.php';
require_once 'TypeError.php';
require_once 'Hprose/Future/functions.php';
require_once 'Hprose/Promise/functions.php';
require_once 'Hprose/functions.php';
require_once 'functions.php';
spl_autoload_register(function($className) {
if ((strlen($className) > 6) && (strtolower(substr($className, 0, 6)) === "hprose")) {
if ($className{6} === '\\') {
include __DIR__ . DIRECTORY_SEPARATOR . str_replace("\\", DIRECTORY_SEPARATOR, $className) . ".php";
}
else {
// Deprecated
// Compatible with older versions only
// You'd better not use these classes.
switch (strtolower($className)) {
case 'hproseasync':
class_alias('Hprose\\Async', 'HproseAsync');
break;
case 'hprosecompleter':
class_alias('Hprose\\Completer', 'HproseCompleter');
break;
case 'hprosefuture':
class_alias('Hprose\\Future', 'HproseFuture');
break;
case 'hprosetags':
class_alias('Hprose\\Tags', 'HproseTags');
break;
case 'hprosebytesio':
class_alias('Hprose\\BytesIO', 'HproseBytesIO');
break;
case 'hproseclassmanager':
class_alias('Hprose\\ClassManager', 'HproseClassManager');
break;
case 'hproserawreader':
class_alias('Hprose\\RawReader', 'HproseRawReader');
break;
case 'hprosereader':
class_alias('Hprose\\Reader', 'HproseReader');
break;
case 'hprosewriter':
class_alias('Hprose\\Writer', 'HproseWriter');
break;
case 'hproseformatter':
class_alias('Hprose\\Formatter', 'HproseFormatter');
break;
case 'hproseresultmode':
class_alias('Hprose\\ResultMode', 'HproseResultMode');
break;
case 'hprosefilter':
class_alias('Hprose\\Filter', 'HproseFilter');
break;
case 'hproseclient':
class_alias('Hprose\\Client', 'HproseClient');
break;
case 'hproseservice':
class_alias('Hprose\\Service', 'HproseService');
break;
case 'hprosehttpclient':
class_alias('Hprose\\Http\\Client', 'HproseHttpClient');
break;
case 'hprosehttpservice':
class_alias('Hprose\\Http\\Service', 'HproseHttpService');
break;
case 'hprosehttpserver':
class_alias('Hprose\\Http\\Server', 'HproseHttpServer');
break;
case 'hprosesocketclient':
class_alias('Hprose\\Socket\\Client', 'HproseSocketClient');
break;
case 'hprosejsonrpcclientfilter':
class_alias('Hprose\\Filter\\JSONRPC\\ClientFilter', 'HproseJSONRPCClientFilter');
break;
case 'hprosejsonrpcservicefilter':
class_alias('Hprose\\Filter\\JSONRPC\\ServiceFilter', 'HproseJSONRPCServiceFilter');
break;
case 'hprosexmlrpcclientfilter':
class_alias('Hprose\\Filter\\XMLRPC\\ClientFilter', 'HproseXMLRPCClientFilter');
break;
case 'hprosexmlrpcservicefilter':
class_alias('Hprose\\Filter\\XMLRPC\\ServiceFilter', 'HproseXMLRPCServiceFilter');
break;
default:
return false;
}
}
return true;
}
return false;
});
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/BytesIO.php *
* *
* hprose BytesIO class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
class BytesIO {
protected $buffer;
protected $length;
protected $pos = 0;
protected $mark = -1;
public function __construct($string = '') {
$this->buffer = $string;
$this->length = strlen($string);
}
public function close() {
$this->buffer = '';
$this->pos = 0;
$this->mark = -1;
$this->length = 0;
}
public function length() {
return $this->length;
}
public function getc() {
if ($this->pos < $this->length) {
return $this->buffer[$this->pos++];
}
return '';
}
public function read($n) {
$s = substr($this->buffer, $this->pos, $n);
$this->skip($n);
return $s;
}
public function readfull() {
$s = substr($this->buffer, $this->pos);
$this->pos = $this->length;
return $s;
}
public function readuntil($tag) {
$pos = strpos($this->buffer, $tag, $this->pos);
if ($pos !== false) {
$s = substr($this->buffer, $this->pos, $pos - $this->pos);
$this->pos = $pos + strlen($tag);
}
else {
$s = substr($this->buffer, $this->pos);
$this->pos = $this->length;
}
return $s;
}
public function readString($n) {
$pos = $this->pos;
$buffer = $this->buffer;
for ($i = 0; $i < $n; ++$i) {
switch (ord($buffer[$pos]) >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7: {
// 0xxx xxxx
++$pos;
break;
}
case 12:
case 13: {
// 110x xxxx 10xx xxxx
$pos += 2;
break;
}
case 14: {
// 1110 xxxx 10xx xxxx 10xx xxxx
$pos += 3;
break;
}
case 15: {
// 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
$pos += 4;
++$i;
if ($i >= $n) {
throw new Exception('bad utf-8 encoding');
}
break;
}
default: {
throw new Exception('bad utf-8 encoding');
}
}
}
return $this->read($pos - $this->pos);
}
public function mark() {
$this->mark = $this->pos;
}
public function unmark() {
$this->mark = -1;
}
public function reset() {
if ($this->mark != -1) {
$this->pos = $this->mark;
}
}
public function skip($n) {
$this->pos += $n;
}
public function eof() {
return ($this->pos >= $this->length);
}
public function write($str, $n = -1) {
if ($n == -1) {
$this->buffer .= $str;
$n = strlen($str);
}
else {
$this->buffer .= substr($str, 0, $n);
}
$this->length += $n;
}
public function load($filename) {
$str = file_get_contents($filename);
if ($str === false) return false;
$this->buffer = $str;
$this->pos = 0;
$this->mark = -1;
$this->length = strlen($str);
return true;
}
public function save($filename) {
return file_put_contents($filename, $this->buffer);
}
public function toString() {
return $this->buffer;
}
public function __toString() {
return $this->buffer;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/ClassManager.php *
* *
* hprose class manager class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class ClassManager {
private static $classCache1 = array();
private static $classCache2 = array();
public static function register($class, $alias) {
self::$classCache1[$alias] = $class;
self::$classCache2[$class] = $alias;
}
public static function getClassAlias($class) {
if (isset(self::$classCache2[$class])) {
return self::$classCache2[$class];
}
$alias = str_replace('\\', '_', $class);
self::register($class, $alias);
return $alias;
}
public static function getClass($alias) {
if (isset(self::$classCache1[$alias])) {
return self::$classCache1[$alias];
}
if (!class_exists($alias)) {
$class = str_replace('_', '\\', $alias);
if (class_exists($class)) {
self::register($class, $alias);
return $class;
}
return 'stdClass';
}
return $alias;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Client.php *
* *
* hprose client class for php 5.3+ *
* *
* LastModified: Jul 24, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use stdClass;
use Closure;
use Exception;
use Throwable;
use TypeError;
use ReflectionMethod;
use ReflectionFunction;
abstract class Client extends HandlerManager {
private $index = -1;
protected $async = true;
public $uri = null;
public $uris = null;
public $filters = array();
public $timeout = 30000;
public $retry = 10;
public $idempontent = false;
public $failswitch = false;
public $byref = false;
public $simple = false;
public $onError = null;
private static $clientFactories = array();
private static $clientFactoriesInited = false;
public static function registerClientFactory($scheme, $clientFactory) {
self::$clientFactories[$scheme] = $clientFactory;
}
public static function tryRegisterClientFactory($scheme, $clientFactory) {
if (empty(self::$clientFactories[$scheme])) {
self::$clientFactories[$scheme] = $clientFactory;
}
}
private static function initClientFactories() {
self::tryRegisterClientFactory("http", "\\Hprose\\Http\\Client");
self::tryRegisterClientFactory("https", "\\Hprose\\Http\\Client");
self::tryRegisterClientFactory("tcp", "\\Hprose\\Socket\\Client");
self::tryRegisterClientFactory("ssl", "\\Hprose\\Socket\\Client");
self::tryRegisterClientFactory("sslv2", "\\Hprose\\Socket\\Client");
self::tryRegisterClientFactory("sslv3", "\\Hprose\\Socket\\Client");
self::tryRegisterClientFactory("tls", "\\Hprose\\Socket\\Client");
self::tryRegisterClientFactory("unix", "\\Hprose\\Socket\\Client");
self::$clientFactoriesInited = true;
}
public static function create($uris, $async = true) {
if (!self::$clientFactoriesInited) self::initClientFactories();
if (is_string($uris)) $uris = array($uris);
$scheme = strtolower(parse_url($uris[0], PHP_URL_SCHEME));
$n = count($uris);
for ($i = 1; $i < $n; ++$i) {
if (strtolower(parse_url($uris[$i], PHP_URL_SCHEME)) != $scheme) {
throw new Exception("Not support multiple protocol.");
}
}
$clientFactory = self::$clientFactories[$scheme];
if (empty($clientFactory)) {
throw new Exception("This client doesn't support $scheme scheme.");
}
return new $clientFactory($uris, $async);
}
public function __construct($uris = null, $async = true) {
parent::__construct();
if ($uris != null) {
if (is_string($uris)) $uris = array($uris);
if (is_array($uris)) {
$this->useService($uris);
}
if (is_bool($uris)) {
$async = $uris;
}
}
$this->async = $async;
}
public function close() {}
public final function getTimeout() {
return $this->timeout;
}
public final function setTimeout($timeout) {
if ($timeout < 1) throw new Exception("timeout must be great than 0");
$this->timeout = $timeout;
}
public final function getRetry() {
return $this->retry;
}
public final function setRetry($retry) {
$this->retry = $retry;
}
public final function isIdempontent() {
return $this->idempontent;
}
public final function setIdempontent($idempontent) {
$this->idempontent = $idempontent;
}
public final function isFailswitch() {
return $this->failswitch;
}
public final function setFailswitch($failswitch) {
$this->failswitch = $failswitch;
}
public final function isByref() {
return $this->byref;
}
public final function setByref($byref) {
$this->byref = $byref;
}
public final function isSimple() {
return $this->simple;
}
public final function setSimple($simple = true) {
$this->simple = $simple;
}
public final function getFilter() {
if (empty($this->filters)) {
return null;
}
return $this->filters[0];
}
public final function setFilter(Filter $filter) {
$this->filters = array();
if ($filter !== null) {
$this->filters[] = $filter;
}
}
public final function addFilter(Filter $filter) {
if ($filter !== null) {
if (empty($this->filters)) {
$this->filters = array($filter);
}
else {
$this->filters[] = $filter;
}
}
}
public final function removeFilter(Filter $filter) {
if (empty($this->filters)) {
return false;
}
$i = array_search($filter, $this->filters);
if ($i === false || $i === null) {
return false;
}
$this->filters = array_splice($this->filters, $i, 1);
return true;
}
protected function setUri($uri) {
$this->uri = $uri;
}
public function useService($uris = array(), $namespace = '') {
if (!empty($uris)) {
if (is_string($uris)) {
$this->uris = array($uris);
$this->index = 0;
$this->setUri($uris);
}
else {
$this->uris = $uris;
$this->index = mt_rand(0, count($uris) - 1);
$this->setUri($uris[$this->index]);
}
}
if ($namespace) {
$namespace .= "_";
}
return new Proxy($this, $namespace);
}
private function outputFilter($request, stdClass $context) {
if (empty($this->filters)) return $request;
$count = count($this->filters);
for ($i = 0; $i < $count; ++$i) {
$request = $this->filters[$i]->outputFilter($request, $context);
}
return $request;
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function inputFilter($response, stdClass $context) {
if (empty($this->filters)) return $response;
$count = count($this->filters);
for ($i = $count - 1; $i >= 0; --$i) {
$response = $this->filters[$i]->inputFilter($response, $context);
}
return $response;
}
protected function wait($interval, $callback) {
$seconds = floor($interval);
$nanoseconds = ($interval - $seconds) * 1000000000;
time_nanosleep($seconds, $nanoseconds);
return $callback();
}
private function failswitch() {
$i = $this->index + 1;
if ($i >= count($this->uris)) {
$i = 0;
}
$this->index = $i;
$this->setUri($this->uris[$i]);
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function retry($request, stdClass $context) {
if ($context->failswitch) {
$this->failswitch();
}
if ($context->idempontent) {
$n = $context->retry;
if ($n > 0) {
$context->retry = $n - 1;
$interval = ($n >= 10) ? 0.5 : (10 - $n) * 0.5;
$self = $this;
return $this->wait($interval, function() use ($self, $request, $context) {
return $self->sendRequest($request, $context);
});
}
}
return null;
}
private function encode($name, array $args, stdClass $context) {
$stream = new BytesIO(Tags::TagCall);
$writer = new Writer($stream, $context->simple);
$writer->writeString($name);
if (count($args) > 0 || $context->byref) {
$writer->reset();
$writer->writeArray($args);
if ($context->byref) {
$writer->writeBoolean(true);
}
}
$stream->write(Tags::TagEnd);
$request = $stream->toString();
$stream->close();
return $request;
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function decode($response, array &$args, stdClass $context) {
if ($context->oneway) return null;
if (empty($response)) throw new Exception("EOF");
if ($response[strlen($response) - 1] !== Tags::TagEnd) {
throw new Exception("Wrong Response: \r\n$response");
}
$mode = $context->mode;
if ($mode === ResultMode::RawWithEndTag) {
return $response;
}
elseif ($mode === ResultMode::Raw) {
return substr($response, 0, -1);
}
$stream = new BytesIO($response);
$reader = new Reader($stream);
$result = null;
$tag = $stream->getc();
if ($tag === Tags::TagResult) {
if ($mode === ResultMode::Normal) {
$result = $reader->unserialize();
}
elseif ($mode === ResultMode::Serialized) {
$result = $reader->readRaw()->toString();
}
$tag = $stream->getc();
if ($tag === Tags::TagArgument) {
$reader->reset();
$arguments = $reader->readList();
$n = min(count($arguments), count($args));
for ($i = 0; $i < $n; $i++) {
$args[$i] = $arguments[$i];
}
$tag = $stream->getc();
}
}
elseif ($tag === Tags::TagError) {
$e = new Exception($reader->readString());
$stream->close();
throw $e;
}
if ($tag !== Tags::TagEnd) {
$stream->close();
throw new Exception("Wrong Response: \r\n$response");
}
$stream->close();
return $result;
}
private function getContext(InvokeSettings $settings) {
$context = new stdClass();
$context->client = $this;
$context->userdata = isset($settings->userdata) ? (object)($settings->userdata) : new stdClass();
$context->mode = isset($settings->mode) ? $settings->mode : ResultMode::Normal;
$context->oneway = isset($settings->oneway) ? $settings->oneway : false;
$context->byref = isset($settings->byref) ? $settings->byref : $this->byref;
$context->simple = isset($settings->simple) ? $settings->simple : $this->simple;
$context->failswitch = isset($settings->failswitch) ? $settings->failswitch : $this->failswitch;
$context->idempontent = isset($settings->idempontent) ? $settings->idempontent : $this->idempontent;
$context->retry = isset($settings->retry) ? $settings->retry : $this->retry;
$context->timeout = isset($settings->timeout) ? $settings->timeout : $this->timeout;
return $context;
}
public function __call($name, array $args) {
$n = count($args);
if ($n > 0) {
if ($args[$n - 1] instanceof Closure) {
$callback = array_pop($args);
return $this->invoke($name, $args, $callback);
}
else if ($args[$n - 1] instanceof InvokeSettings) {
if (($n > 1) && ($args[$n - 2] instanceof Closure)) {
$settings = array_pop($args);
$callback = array_pop($args);
return $this->invoke($name, $args, $callback, $settings);
}
$settings = array_pop($args);
return $this->invoke($name, $args, $settings);
}
else if (($n > 1) && is_array($args[$n - 1]) &&
($args[$n - 2] instanceof Closure)) {
$settings = new InvokeSettings(array_pop($args));
$callback = array_pop($args);
return $this->invoke($name, $args, $callback, $settings);
}
}
return $this->invoke($name, $args);
}
public function __get($name) {
return new Proxy($this, $name . '_');
}
protected function getNextInvokeHandler(Closure $next, /*callable*/ $handler) {
if ($this->async) return parent::getNextInvokeHandler($next, $handler);
return function($name, array $args, stdClass $context) use ($next, $handler) {
return call_user_func($handler, $name, $args, $context, $next);
};
}
protected function getNextFilterHandler(Closure $next, /*callable*/ $handler) {
if ($this->async) return parent::getNextFilterHandler($next, $handler);
return function($request, stdClass $context) use ($next, $handler) {
return call_user_func($handler, $request, $context, $next);
};
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function sendRequest($request, stdClass $context) {
$beforeFilterHandler = $this->beforeFilterHandler;
if ($this->async) {
$self = $this;
return $beforeFilterHandler($request, $context)->catchError(function($e) use ($self, $request, $context) {
$response = $self->retry($request, $context);
if ($response !== null) {
return $response;
}
throw $e;
});
}
$error = null;
try {
$response = $beforeFilterHandler($request, $context);
}
catch (Exception $e) { $error = $e; }
catch (Throwable $e) { $error = $e; }
if ($error !== null) {
$response = $this->retry($request, $context);
if ($response !== null) {
return $response;
}
throw $error;
}
return $response;
}
private function asyncInvokeHandler($name, array &$args, stdClass $context) {
try {
$request = $this->encode($name, $args, $context);
}
catch (Exception $e) {
return Future\error($e);
}
catch (Throwable $e) {
return Future\error($e);
}
$self = $this;
return $this->sendRequest($request, $context)->then(function($response) use ($self, &$args, $context) {
return $self->decode($response, $args, $context);
});
}
private function syncInvokeHandler($name, array &$args, stdClass $context) {
$request = $this->encode($name, $args, $context);
$response = $this->sendRequest($request, $context);
return $this->decode($response, $args, $context);
}
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ function invokeHandler($name, array &$args, stdClass $context) {
if ($this->async) {
return $this->asyncInvokeHandler($name, $args, $context);
}
return $this->syncInvokeHandler($name, $args, $context);
}
private function asyncBeforeFilterHandler($request, stdClass $context) {
$afterFilterHandler = $this->afterFilterHandler;
$self = $this;
return $afterFilterHandler($this->outputFilter($request, $context), $context)
->then(function($response) use ($self, $context) {
if ($context->oneway) return null;
return $self->inputFilter($response, $context);
});
}
private function syncBeforeFilterHandler($request, stdClass $context) {
$afterFilterHandler = $this->afterFilterHandler;
$response = $afterFilterHandler($this->outputFilter($request, $context), $context);
if ($context->oneway) return null;
return $this->inputFilter($response, $context);
}
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ function beforeFilterHandler($request, stdClass $context) {
if ($this->async) {
return $this->asyncBeforeFilterHandler($request, $context);
}
return $this->syncBeforeFilterHandler($request, $context);
}
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ function afterFilterHandler($request, stdClass $context) {
return $this->sendAndReceive($request, $context);
}
public function invoke($name, array $args = array(), $callback = null, InvokeSettings $settings = null) {
if ($callback instanceof InvokeSettings) {
$settings = $callback;
$callback = null;
}
if ($settings === null) $settings = new InvokeSettings();
$context = $this->getContext($settings);
$invokeHandler = $this->invokeHandler;
if (is_callable($callback)) {
if (is_array($callback)) {
$f = new ReflectionMethod($callback[0], $callback[1]);
}
else {
$f = new ReflectionFunction($callback);
}
$n = $f->getNumberOfParameters();
$onError = $this->onError;
return Future\all($args)->then(function($args) use ($invokeHandler, $name, $context, $n, $callback, $onError) {
$result = Future\toFuture($invokeHandler($name, $args, $context));
$result->then(
function($result) use ($n, $callback, $args) {
switch($n) {
case 0: call_user_func($callback); break;
case 1: call_user_func($callback, $result); break;
case 2: call_user_func($callback, $result, $args); break;
case 3: call_user_func($callback, $result, $args, null); break;
}
},
function($error) use ($n, $callback, $args, $name, $onError) {
switch($n) {
case 0:
call_user_func($callback);
if (is_callable($onError)) {
call_user_func($onError, $name, $error);
}
break;
case 1: call_user_func($callback, $error); break;
case 2: call_user_func($callback, $error, $args); break;
case 3: call_user_func($callback, null, $args, $error); break;
}
}
);
return $result;
});
}
else {
if ($this->async) {
$args = Future\all($args);
return $args->then(function($args) use ($invokeHandler, $name, $context) {
return $invokeHandler($name, $args, $context);
});
}
return $invokeHandler($name, $args, $context);
}
}
protected abstract function sendAndReceive($request, stdClass $context);
private $topics;
private $id;
private function autoId() {
$settings = new InvokeSettings(array(
'idempotent' => true,
'failswitch' => true
));
return Future\toFuture($this->invoke('#', array(), $settings));
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function getTopic($name, $id, $create) {
if (isset($this->topics[$name])) {
$topics = $this->topics[$name];
if (isset($topics[$id])) {
return $topics[$id];
}
return null;
}
if ($create) {
$this->topics[$name] = array();
}
}
// subscribe($name, $callback, $timeout)
// subscribe($name, $id, $callback, $timeout)
public function subscribe($name, $id = null, $callback = null, $timeout = null) {
$self = $this;
if (!is_string($name)) {
throw new TypeError('topic name must be a string');
}
if (is_callable($id) && !is_callable($callback)) {
$timeout = $callback;
$callback = $id;
$id = null;
}
if (!is_callable($callback)) {
throw new TypeError('callback must be a function.');
}
if ($id === null) {
if ($this->id == null) {
$this->id = $this->autoId();
}
$this->id->then(function($id) use ($self, $name, $callback, $timeout) {
$self->subscribe($name, $id, $callback, $timeout);
});
return;
}
if (!is_int($timeout)) $timeout = $this->timeout;
$topic = $this->getTopic($name, $id, true);
if ($topic === null) {
$topic = new stdClass();
$settings = new InvokeSettings(array(
'idempotent' => true,
'failswitch' => false,
'timeout' => $timeout
));
$cb = function() use ($self, &$cb, $topic, $name, $id, $settings) {
$self->invoke($name, array($id), $settings)
->then($topic->handler, $cb);
};
$topic->handler = function($result) use ($self, $name, $id, $cb) {
$topic = $self->getTopic($name, $id, false);
if ($topic !== null) {
if ($result !== null) {
$callbacks = $topic->callbacks;
foreach ($callbacks as $callback) {
try {
call_user_func($callback, $result);
}
catch (Exception $ex) {}
catch (Throwable $ex) {}
}
}
if ($self->getTopic($name, $id, false) !== null) $cb();
}
};
$topic->callbacks = array($callback);
$this->topics[$name][$id] = $topic;
$cb();
}
elseif (array_search($callback, $topic->callbacks, true) === false) {
$topic->callbacks[] = $callback;
}
}
private function delTopic(&$topics, $id, $callback) {
if ($topics !== null) {
if (is_callable($callback)) {
$topic = @$topics[$id];
if ($topic !== null) {
$callbacks = array_diff($topic->callbacks, array($callback));
if (count($callbacks) > 0) {
$topic->callbacks = $callbacks;
}
else {
unset($topics[$id]);
}
}
}
else {
unset($topics[$id]);
}
}
}
// unsubscribe($name)
// unsubscribe($name, $callback)
// unsubscribe($name, $id)
// unsubscribe($name, $id, $callback)
public function unsubscribe($name, $id = null, $callback = null) {
$self = $this;
if (!is_string($name)) {
throw new TypeError('topic name must be a string');
}
if (($id === null) && ($callback === null)) {
unset($this->topics[$name]);
return;
}
if (is_callable($id) && !is_callable($callback)) {
$callback = $id;
$id = null;
}
if ($id === null) {
if ($this->id === null) {
if (isset($this->topics[$name])) {
$topics = $this->topics[$name];
$ids = array_keys($topics);
foreach ($ids as $id) {
$this->delTopic($topics, $id, $callback);
}
}
}
else {
$this->id->then(function($id) use ($self, $name, $callback) {
$self->unsubscribe($name, $id, $callback);
});
}
}
elseif (Future\isFuture($id)) {
$id->then(function($id) use ($self, $name, $callback) {
$self->unsubscribe($name, $id, $callback);
});
}
else {
$this->delTopic($this->topics[$name], $id, $callback);
}
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Completer.php *
* *
* hprose Completer class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Completer {
private $future;
public function __construct() {
$this->future = new Future();
}
public function future() {
return $this->future;
}
public function complete($result) {
$this->future->resolve($result);
}
public function completeError($error) {
$this->future->reject($error);
}
public function isCompleted() {
return $this->future->state !== Future::PENDING;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Deferred.php *
* *
* hprose Deferred class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Deferred {
public $promise;
public function __construct() {
$this->promise = new Future();
}
public function resolve($value) {
$this->promise->resolve($value);
}
public function reject($reason) {
$this->promise->reject($reason);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/FakeReaderRefer.php *
* *
* hprose FakeReaderRefer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
class FakeReaderRefer implements ReaderRefer {
public function set($val) {}
public function read($index) {
throw new Exception("Unexpected serialize tag '" .
Tags::TagRef .
"' in stream");
}
public function reset() {}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/FakeWriterRefer.php *
* *
* hprose FakeWriterRefer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class FakeWriterRefer implements WriterRefer {
public function set($val) {}
public function write(BytesIO $stream, $val) { return false; }
public function reset() {}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter.php *
* *
* hprose filter interface for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use stdClass;
interface Filter {
public function inputFilter($data, stdClass $context);
public function outputFilter($data, stdClass $context);
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter/JSONRPC/ClientFilter.php *
* *
* json rpc client filter class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Filter\JSONRPC;
use stdClass;
use Exception;
use Hprose\Filter;
use Hprose\BytesIO;
use Hprose\Writer;
use Hprose\Reader;
use Hprose\Tags;
class ClientFilter implements Filter {
private static $id = 1;
private $version;
public function __construct() {
$this->version = "2.0";
}
public function getVersion() {
return $this->version;
}
public function setVersion($version) {
if ($version === "1.0" || $version === "1.1" || $version === "2.0") {
$this->version = $version;
}
else {
throw new Exception("version must be 1.0, 1.1 or 2.0 in string format.");
}
}
public function inputFilter($data, stdClass $context) {
$response = json_decode($data);
if (!isset($response->result)) {
$response->result = null;
}
if (!isset($response->error)) {
$response->error = null;
}
$stream = new BytesIO();
$writer = new Writer($stream, true);
if ($response->error) {
$stream->write(Tags::TagError);
$writer->writeString($response->error->message);
}
else {
$stream->write(Tags::TagResult);
$writer->serialize($response->result);
}
$stream->write(Tags::TagEnd);
return $stream->toString();
}
public function outputFilter($data, stdClass $context) {
$request = new stdClass();
if ($this->version === "1.1") {
$request->version = "1.1";
}
else if ($this->version === "2.0") {
$request->jsonrpc = "2.0";
}
$stream = new BytesIO($data);
$reader = new Reader($stream);
$tag = $stream->getc();
if ($tag === Tags::TagCall) {
$request->method = $reader->readString();
$tag = $stream->getc();
if ($tag == Tags::TagList) {
$reader->reset();
$request->params = $reader->readListWithoutTag();
}
}
else {
throw new Exception("Error Processing Request", 1);
}
$request->id = self::$id++;
return json_encode($request);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter/JSONRPC/ServiceFilter.php *
* *
* json rpc service filter class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Filter\JSONRPC;
use stdClass;
use Hprose\Filter;
use Hprose\BytesIO;
use Hprose\Writer;
use Hprose\Reader;
use Hprose\Tags;
class ServiceFilter implements Filter {
function inputFilter($data, stdClass $context) {
if ($data !== "" && ($data{0} === '[' || $data{0} === '{')) {
try {
$requests = json_decode($data);
}
catch (Exception $e) {
return $data;
}
if ($data{0} === '{') {
$requests = array($requests);
}
else if (count($requests) === 0) {
return $data;
}
$stream = new BytesIO();
$writer = new Writer($stream, true);
$context->userdata->jsonrpc = array();
foreach ($requests as $request) {
$jsonrpc = new stdClass();
if (isset($request->id)) {
$jsonrpc->id = $request->id;
}
else {
$jsonrpc->id = null;
}
if (isset($request->version)) {
$jsonrpc->version = $request->version;
}
else if (isset($request->jsonrpc)) {
$jsonrpc->version = $request->jsonrpc;
}
else {
$jsonrpc->version = '1.0';
}
$context->userdata->jsonrpc[] = $jsonrpc;
if (isset($request->method)) {
$stream->write(Tags::TagCall);
$writer->writeString($request->method);
if (isset($request->params) &&
count($request->params) > 0) {
$writer->writeArray($request->params);
}
}
else {
unset($context->userdata->jsonrpc);
return $data;
}
}
$stream->write(Tags::TagEnd);
$data = $stream->toString();
unset($stream);
unset($writer);
}
return $data;
}
function outputFilter($data, stdClass $context) {
if (isset($context->userdata->jsonrpc)) {
$responses = array();
$stream = new BytesIO($data);
$reader = new Reader($stream);
$tag = $stream->getc();
foreach ($context->userdata->jsonrpc as $jsonrpc) {
$response = new stdClass();
$response->id = $jsonrpc->id;
$version = $jsonrpc->version;
if ($version !== '2.0') {
if ($version === '1.1') {
$response->version = '1.1';
}
$response->result = null;
$response->error = null;
}
else {
$response->jsonrpc = '2.0';
}
if ($tag !== Tags::TagEnd) {
$reader->reset();
if ($tag === Tags::TagResult) {
$response->result = $reader->unserialize();
}
else if ($tag === Tags::TagError) {
$lasterror = error_get_last();
$response->error = new stdClass();
$response->error->code = $lasterror['type'];
$response->error->message = $reader->unserialize();
}
$tag = $stream->getc();
}
else {
$response->result = null;
}
if ($response->id !== null) {
$responses[] = $response;
}
}
if (count($context->userdata->jsonrpc) === 1) {
if (count($responses) === 1) {
return json_encode($responses[0]);
}
return '';
}
return json_encode($responses);
}
return $data;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter/XMLRPC/ClientFilter.php *
* *
* xml-rpc client filter class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Filter\XMLRPC;
use stdClass;
use Exception;
use Hprose\Filter;
use Hprose\BytesIO;
use Hprose\Writer;
use Hprose\Reader;
use Hprose\Tags;
class ClientFilter implements Filter {
public function inputFilter($data, stdClass $context) {
$result = xmlrpc_decode($data, "UTF-8");
$stream = new BytesIO();
$writer = new Writer($stream, true);
if (isset($result['faultString'])) {
$stream->write(Tags::TagError);
$writer->writeString($result['faultString']);
}
else {
$stream->write(Tags::TagResult);
$writer->serialize($result);
}
$stream->write(Tags::TagEnd);
return $stream->toString();
}
public function outputFilter($data, stdClass $context) {
$method = null;
$params = array();
$stream = new BytesIO($data);
$reader = new Reader($stream);
$tag = $stream->getc();
if ($tag === Tags::TagCall) {
$method = $reader->readString();
$tag = $stream->getc();
if ($tag ==Tags::TagList) {
$reader->reset();
$params = $reader->readListWithoutTag();
}
}
else {
throw new Exception("Error Processing Request", 1);
}
return xmlrpc_encode_request($method, $params);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Filter/XMLRPC/ServiceFilter.php *
* *
* xml-rpc service filter class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Filter\XMLRPC;
use stdClass;
use Hprose\Filter;
use Hprose\BytesIO;
use Hprose\Writer;
use Hprose\Reader;
use Hprose\Tags;
class ServiceFilter implements Filter {
public function inputFilter($data, stdClass $context) {
if ($data !== "" && $data{0} === '<') {
$context->userdata->format = "xmlrpc";
$method = null;
$params = xmlrpc_decode_request($data, $method, "UTF-8");
$stream = new BytesIO();
$writer = new Writer($stream, true);
if (isset($method)) {
$stream->write(Tags::TagCall);
$writer->writeString($method);
if (isset($params)) {
$writer->writeArray($params);
}
}
$stream->write(Tags::TagEnd);
$data = $stream->toString();
}
return $data;
}
public function outputFilter($data, stdClass $context) {
if (isset($context->userdata->format) && $context->userdata->format === "xmlrpc") {
$result = null;
if ($data !== "") {
$stream = new BytesIO($data);
$reader = new Reader($stream);
while (($tag = $stream->getc()) !== Tags::TagEnd) {
$reader->reset();
switch ($tag) {
case Tags::TagResult:
$result = $reader->unserialize();
break;
case Tags::TagError:
$lasterror = error_get_last();
$result = array(
"faultCode" => $lasterror["type"],
"faultString" => $reader->unserialize()
);
break;
case Tags::TagFunctions:
$result = $reader->unserialize();
break;
default:
return xmlrpc_encode($result);
}
}
}
$data = xmlrpc_encode($result);
}
return $data;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Formatter.php *
* *
* hprose formatter class for php 5.3+ *
* *
* LastModified: Jul 16, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Formatter {
public static function serialize($var, $simple = false) {
$stream = new BytesIO();
$writer = new Writer($stream, $simple);
$writer->serialize($var);
$data = $stream->toString();
$stream->close();
return $data;
}
public static function unserialize($data, $simple = false) {
$stream = new BytesIO($data);
$reader = new Reader($stream, $simple);
$result = $reader->unserialize();
$stream->close();
return $result;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Future.php *
* *
* hprose future class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
use Throwable;
use TypeError;
use Hprose\Future\UncatchableException;
class Future {
const PENDING = 0;
const FULFILLED = 1;
const REJECTED = 2;
public $state = Future::PENDING;
public $value;
public $reason;
private $subscribers = array();
public function __construct($computation = NULL) {
if (is_callable($computation)) {
try {
$this->resolve(call_user_func($computation));
}
catch (UncatchableException $e) {
throw $e->getPrevious();
}
catch (Exception $e) {
$this->reject($e);
}
catch (Throwable $e) {
$this->reject($e);
}
}
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function privateCall($callback, $next, $x) {
try {
$r = call_user_func($callback, $x);
$next->resolve($r);
}
catch (UncatchableException $e) {
throw $e->getPrevious();
}
catch (Exception $e) {
$next->reject($e);
}
catch (Throwable $e) {
$next->reject($e);
}
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function privateReject($onreject, $next, $e) {
if (is_callable($onreject)) {
$this->privateCall($onreject, $next, $e);
}
else {
$next->reject($e);
}
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function privateResolve($onfulfill, $onreject, $next, $x) {
$self = $this;
$resolvePromise = function($y) use ($onfulfill, $onreject, $self, $next) {
$self->privateResolve($onfulfill, $onreject, $next, $y);
};
$rejectPromise = function($r) use ($onreject, $self, $next) {
$self->privateReject($onreject, $next, $r);
};
if (Future\isFuture($x)) {
if ($x === $this) {
$rejectPromise(new TypeError('Self resolution'));
return;
}
$x->then($resolvePromise, $rejectPromise);
return;
}
if (($x !== NULL) and is_object($x) or is_string($x)) {
if (method_exists($x, 'then')) {
$then = array($x, 'then');
$notrun = true;
try {
call_user_func($then,
function($y) use (&$notrun, $resolvePromise) {
if ($notrun) {
$notrun = false;
$resolvePromise($y);
}
},
function($r) use (&$notrun, $rejectPromise) {
if ($notrun) {
$notrun = false;
$rejectPromise($r);
}
}
);
}
catch (UncatchableException $e) {
throw $e->getPrevious();
}
catch (Exception $e) {
if ($notrun) {
$notrun = false;
$rejectPromise($e);
}
}
catch (Throwable $e) {
if ($notrun) {
$notrun = false;
$rejectPromise($e);
}
}
return;
}
}
if ($onfulfill) {
$this->privateCall($onfulfill, $next, $x);
}
else {
$next->resolve($x);
}
}
public function resolve($value) {
if ($this->state === self::PENDING) {
$this->state = self::FULFILLED;
$this->value = $value;
while (count($this->subscribers) > 0) {
$subscriber = array_shift($this->subscribers);
$this->privateResolve($subscriber['onfulfill'],
$subscriber['onreject'],
$subscriber['next'],
$value);
}
}
}
public function reject($reason) {
if ($this->state === self::PENDING) {
$this->state = self::REJECTED;
$this->reason = $reason;
while (count($this->subscribers) > 0) {
$subscriber = array_shift($this->subscribers);
if (is_callable($subscriber['onreject'])) {
$this->privateCall($subscriber['onreject'],
$subscriber['next'],
$reason);
}
else {
$subscriber['next']->reject($reason);
}
}
}
}
public function then($onfulfill, $onreject = NULL) {
if (!is_callable($onfulfill)) { $onfulfill = NULL; }
if (!is_callable($onreject)) { $onreject = NULL; }
if (($onfulfill !== NULL) or ($onreject !== NULL)) {
$next = new Future();
if ($this->state === self::FULFILLED) {
$this->privateResolve($onfulfill, $onreject, $next, $this->value);
}
elseif ($this->state === self::REJECTED) {
if ($onreject !== NULL) {
$this->privateCall($onreject, $next, $this->reason);
}
else {
$next->reject($this->reason);
}
}
else {
array_push($this->subscribers, array(
'onfulfill' => $onfulfill,
'onreject' => $onreject,
'next' => $next
));
}
return $next;
}
return $this;
}
public function done($onfulfill, $onreject = NULL) {
$this->then($onfulfill, $onreject)->then(NULL, function($error) {
throw new UncatchableException("", 0, $error);
});
}
public function inspect() {
switch ($this->state) {
case self::PENDING: return array('state' => 'pending');
case self::FULFILLED: return array('state' => 'fulfilled', 'value' => $this->value);
case self::REJECTED: return array('state' => 'rejected', 'reason' => $this->reason);
}
}
public function catchError($onreject, $test = NULL) {
if (is_callable($test)) {
$self = $this;
return $this->then(NULL,
function($e) use ($self, $onreject, $test) {
if (call_user_func($test, $e)) {
return $self->then(NULL, $onreject);
}
else {
throw $e;
}
}
);
}
return $this->then(NULL, $onreject);
}
public function fail($onreject) {
$this->done(NULL, $onreject);
}
public function whenComplete($action) {
return $this->then(
function($v) use ($action) {
call_user_func($action);
return $v;
},
function($e) use ($action) {
call_user_func($action);
throw $e;
}
);
}
public function complete($oncomplete) {
return $this->then($oncomplete, $oncomplete);
}
public function always($oncomplete) {
$this->done($oncomplete, $oncomplete);
}
public function fill($future) {
$this->then(array($future, 'resolve'), array($future, 'reject'));
}
public function tap($onfulfilledSideEffect) {
return $this->then(
function($result) use ($onfulfilledSideEffect) {
call_user_func($onfulfilledSideEffect, $result);
return $result;
}
);
}
public function spread($onfulfilledArray) {
return $this->then(
function($array) use ($onfulfilledArray) {
return call_user_func_array($onfulfilledArray, $array);
}
);
}
public function __get($key) {
return $this->then(
function($result) use ($key) {
return $result->$key;
}
);
}
public function __call($method, $args) {
if ($args === NULL) {
$args = array();
}
return $this->then(
function($result) use ($method, $args) {
return Future\all($args)->then(
function($args) use ($result, $method) {
return call_user_func_array(array($result, $method), $args);
}
);
}
);
}
public function each($callback) {
return Future\each($this, $callback);
}
public function every($callback) {
return Future\every($this, $callback);
}
public function some($callback) {
return Future\some($this, $callback);
}
public function filter($callback, $preserveKeys = false) {
return Future\filter($this, $callback, $preserveKeys);
}
public function map($callback) {
return Future\map($this, $callback);
}
public function reduce($callback, $initial = NULL) {
return Future\reduce($this, $callback, $initial);
}
public function search($searchElement, $strict = false) {
return Future\search($this, $searchElement, $strict);
}
public function includes($searchElement, $strict = false) {
return Future\includes($this, $searchElement, $strict);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Future/CallableWrapper.php *
* *
* Future CallableWrapper for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Future;
class CallableWrapper extends Wrapper {
public function __invoke() {
$obj = $this->obj;
return all(func_get_args())->then(function($args) use ($obj) {
return call_user_func_array($obj, $args);
});
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Future/UncatchableException.php *
* *
* UncatchableException for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Future;
use Exception;
class UncatchableException extends Exception {}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Future/Wrapper.php *
* *
* Future Wrapper for php 5.3+ *
* *
* LastModified: Jul 25, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Future;
use ReflectionMethod;
class Wrapper {
protected $obj;
public function __construct($obj) {
$this->obj = $obj;
}
public function __call($name, array $arguments) {
$method = array($this->obj, $name);
return all($arguments)->then(function($args) use ($method, $name) {
if (class_exists("\\Generator")) {
$m = new ReflectionMethod($this->obj, $name);
if ($m->isGenerator()) {
array_splice($args, 0, 0, array($method));
return call_user_func_array('\\Hprose\\Future\\co', $args);
}
}
return call_user_func_array($method, $args);
});
}
public function __get($name) {
return $this->obj->$name;
}
public function __set($name, $value) {
$this->obj->$name = $value;
}
public function __isset($name) {
return isset($this->obj->$name);
}
public function __unset($name) {
unset($this->obj->$name);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Future/functions.php *
* *
* some helper functions for php 5.3+ *
* *
* LastModified: Jul 25, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Future;
use Hprose\Future;
use Exception;
use Throwable;
use RangeException;
use ReflectionFunction;
use ReflectionMethod;
function isFuture($obj) {
return $obj instanceof Future;
}
function error($e) {
$future = new Future();
$future->reject($e);
return $future;
}
function value($v) {
$future = new Future();
$future->resolve($v);
return $future;
}
function resolve($value) {
return value($value);
}
function reject($reason) {
return error($reason);
}
function sync($computation) {
try {
return toPromise(call_user_func($computation));
}
catch (UncatchableException $e) {
throw $e->getPrevious();
}
catch (Exception $e) {
return error($e);
}
catch (Throwable $e) {
return error($e);
}
}
function promise($executor) {
$future = new Future();
call_user_func($executor,
function($value) use ($future) {
$future->resolve($value);
},
function($reason) use ($future) {
$future->reject($reason);
}
);
return $future;
}
function toFuture($obj) {
return isFuture($obj) ? $obj : value($obj);
}
function all($array) {
return toFuture($array)->then(
function($array) {
$keys = array_keys($array);
$n = count($array);
$result = array();
if ($n === 0) {
return value($result);
}
$future = new Future();
$onfulfilled = function($index) use ($future, &$result, &$n, $keys) {
return function($value) use ($index, $future, &$result, &$n, $keys) {
$result[$index] = $value;
if (--$n === 0) {
$array = array();
foreach($keys as $key) {
$array[$key] = $result[$key];
}
$future->resolve($array);
}
};
};
$onrejected = array($future, "reject");
foreach ($array as $index => $element) {
toFuture($element)->then($onfulfilled($index), $onrejected);
}
return $future;
}
);
}
function join() {
return all(func_get_args());
}
function race($array) {
return toFuture($array)->then(
function($array) {
$future = new Future();
foreach ($array as $element) {
toFuture($element)->fill($future);
}
return $future;
}
);
}
function any($array) {
return toFuture($array)->then(
function($array) {
$keys = array_keys($array);
$n = count($array);
if ($n === 0) {
throw new RangeException('any(): $array must not be empty');
}
$reasons = array();
$future = new Future();
$onfulfilled = array($future, "resolve");
$onrejected = function($index) use ($future, &$reasons, &$n, $keys) {
return function($reason) use ($index, $future, &$reasons, &$n, $keys) {
$reasons[$index] = $reason;
if (--$n === 0) {
$array = array();
foreach($keys as $key) {
$array[$key] = $reasons[$key];
}
$future->reject($array);
}
};
};
foreach ($array as $index => $element) {
$f = toFuture($element);
$f->then($onfulfilled, $onrejected($index));
}
return $future;
}
);
}
function settle($array) {
return toFuture($array)->then(
function($array) {
$keys = array_keys($array);
$n = count($array);
$result = array();
if ($n === 0) {
return value($result);
}
$future = new Future();
$oncomplete = function($index, $f) use ($future, &$result, &$n, $keys) {
return function() use ($index, $f, $future, &$result, &$n, $keys) {
$result[$index] = $f->inspect();
if (--$n === 0) {
$array = array();
foreach($keys as $key) {
$array[$key] = $result[$key];
}
$future->resolve($array);
}
};
};
foreach ($array as $index => $element) {
$f = toFuture($element);
$f->whenComplete($oncomplete($index, $f));
}
return $future;
}
);
}
function run($handler/*, arg1, arg2, ... */) {
$args = array_slice(func_get_args(), 1);
return all($args)->then(
function($args) use ($handler) {
return call_user_func_array($handler, $args);
}
);
}
function wrap($handler) {
if (class_exists("\\Generator") && is_callable($handler)) {
if (is_array($handler)) {
$m = new ReflectionMethod($handler[0], $handler[1]);
}
else {
$m = new ReflectionFunction($handler);
}
if ($m->isGenerator()) {
return function() use ($handler) {
return all(func_get_args())->then(
function($args) use ($handler) {
array_splice($args, 0, 0, array($handler));
return call_user_func_array('\\Hprose\\Future\\co', $args);
}
);
};
}
}
if (is_object($handler)) {
if (is_callable($handler)) {
return new CallableWrapper($handler);
}
return new Wrapper($handler);
}
if (is_callable($handler)) {
return function() use ($handler) {
return all(func_get_args())->then(
function($args) use ($handler) {
return call_user_func_array($handler, $args);
}
);
};
}
return $handler;
}
function each($array, $callback) {
if (is_array($callback)) {
$f = new ReflectionMethod($callback[0], $callback[1]);
}
else {
$f = new ReflectionFunction($callback);
}
$n = $f->getNumberOfParameters();
return all($array)->then(
function($array) use ($n, $callback) {
foreach ($array as $key => $value) {
switch ($n) {
case 1: call_user_func($callback, $value); break;
case 2: call_user_func($callback, $value, $key); break;
default: call_user_func($callback, $value, $key, $array); break;
}
}
}
);
}
function every($array, $callback) {
if (is_array($callback)) {
$f = new ReflectionMethod($callback[0], $callback[1]);
}
else {
$f = new ReflectionFunction($callback);
}
$n = $f->getNumberOfParameters();
return all($array)->then(
function($array) use ($n, $callback) {
foreach ($array as $key => $value) {
switch ($n) {
case 1: {
if (!call_user_func($callback, $value)) return false;
break;
}
case 2: {
if (!call_user_func($callback, $value, $key)) return false;
break;
}
default: {
if (!call_user_func($callback, $value, $key, $array)) return false;
break;
}
}
}
return true;
}
);
}
function some($array, $callback) {
if (is_array($callback)) {
$f = new ReflectionMethod($callback[0], $callback[1]);
}
else {
$f = new ReflectionFunction($callback);
}
$n = $f->getNumberOfParameters();
return all($array)->then(
function($array) use ($n, $callback) {
foreach ($array as $key => $value) {
switch ($n) {
case 1: {
if (call_user_func($callback, $value)) return true;
break;
}
case 2: {
if (call_user_func($callback, $value, $key)) return true;
break;
}
default: {
if (call_user_func($callback, $value, $key, $array)) return true;
break;
}
}
}
return false;
}
);
}
function filter($array, $callback, $preserveKeys = false) {
if (is_array($callback)) {
$f = new ReflectionMethod($callback[0], $callback[1]);
}
else {
$f = new ReflectionFunction($callback);
}
$n = $f->getNumberOfParameters();
return all($array)->then(
function($array) use ($n, $callback, $preserveKeys) {
$result = array();
$setResult = function($key, $value) use (&$result, $preserveKeys) {
if ($preserveKeys) {
$result[$key] = $value;
}
else {
$result[] = $value;
}
};
foreach ($array as $key => $value) {
switch ($n) {
case 1: {
if (call_user_func($callback, $value)) {
$setResult($key, $value);
}
break;
}
case 2: {
if (call_user_func($callback, $value, $key)) {
$setResult($key, $value);
}
break;
}
default: {
if (call_user_func($callback, $value, $key, $array)) {
$setResult($key, $value);
}
break;
}
}
}
return $result;
}
);
}
function map($array, $callback) {
if (is_array($callback)) {
$f = new ReflectionMethod($callback[0], $callback[1]);
}
else {
$f = new ReflectionFunction($callback);
}
$n = $f->getNumberOfParameters();
return all($array)->then(
function($array) use ($n, $callback) {
switch ($n) {
case 1: return array_map($callback, $array);
case 2: return array_map($callback, $array, array_keys($array));
default: {
$result = array();
foreach ($array as $key => $value) {
$result[$key] = call_user_func($callback, $value, $key, $array);
}
return $result;
}
}
}
);
}
function reduce($array, $callback, $initial = NULL) {
if ($initial !== NULL) {
return all($array)->then(
function($array) use ($callback, $initial) {
$initial = toFuture($initial);
return $initial->then(
function($initial) use ($array, $callback) {
return array_reduce($array, $callback, $initial);
}
);
}
);
}
return all($array)->then(
function($array) use ($callback) {
return array_reduce($array, $callback);
}
);
}
function search($array, $searchElement, $strict = false) {
return all($array)->then(
function($array) use ($searchElement, $strict) {
$searchElement = toFuture($searchElement);
return $searchElement->then(
function($searchElement) use ($array, $strict) {
return array_search($searchElement, $array, $strict);
}
);
}
);
}
function includes($array, $searchElement, $strict = false) {
return all($array)->then(
function($array) use ($searchElement, $strict) {
$searchElement = toFuture($searchElement);
return $searchElement->then(
function($searchElement) use ($array, $strict) {
return in_array($searchElement, $array, $strict);
}
);
}
);
}
function diff(/*$array1, $array2, ...*/) {
$args = func_get_args();
for ($i = 0, $n = func_num_args(); $i < $n; ++$i) {
$args[$i] = all($args[$i]);
}
return all($args)->then(
function($array) {
return call_user_func_array("array_diff", $array);
}
);
}
function udiff(/*$array1, $array2, $...*/) {
$args = func_get_args();
$callback = array_pop($args);
for ($i = 0, $n = func_num_args() - 1; $i < $n; ++$i) {
$args[$i] = all($args[$i]);
}
return all($args)->then(
function($array) use ($callback) {
array_push($array, $callback);
return call_user_func_array("array_udiff", $array);
}
);
}
function toPromise($obj) {
if (isFuture($obj)) return $obj;
if (class_exists("\\Generator") && ($obj instanceof \Generator)) return co($obj);
if (is_array($obj)) return arrayToPromise($obj);
if (is_object($obj)) return objectToPromise($obj);
return value($obj);
}
function arrayToPromise(array $array) {
$result = array();
foreach ($array as $key => $value) {
$result[$key] = toPromise($value);
}
return all($result);
}
function objectToPromise($obj) {
$result = clone $obj;
$values = array();
foreach ($result as $key => $value) {
$values[] = toPromise($value)->then(function($v) use ($result, $key) {
$result->$key = $v;
});
}
return all($values)->then(function() use ($result) {
return $result;
});
}
if (class_exists("\\Generator")) {
function co($generator/*, arg1, arg2...*/) {
if (is_callable($generator)) {
$args = array_slice(func_get_args(), 1);
$generator = call_user_func_array($generator, $args);
}
if (!($generator instanceof \Generator)) {
return value($generator);
}
$next = function($yield) use ($generator, &$next) {
if ($generator->valid()) {
return toPromise($yield)->then(function($value) use ($generator, &$next) {
$yield = $generator->send($value);
if ($generator->valid()) {
return $next($yield);
}
if (method_exists($generator, "getReturn")) {
$result = $generator->getReturn();
return ($result === null) ? $value : $result;
}
return $value;
},
function($e) use ($generator, &$next) {
return $next($generator->throw($e));
});
}
else {
if (method_exists($generator, "getReturn")) {
return value($generator->getReturn());
}
else {
return value(null);
}
}
};
return $next($generator->current());
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/HandlerManager.php *
* *
* hprose HandlerManager class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use stdClass;
use Closure;
use Exception;
use Throwable;
abstract class HandlerManager {
private $invokeHandlers = array();
private $beforeFilterHandlers = array();
private $afterFilterHandlers = array();
private $defaultInvokeHandler;
private $defaultBeforeFilterHandler;
private $defaultAfterFilterHandler;
protected $invokeHandler;
protected $beforeFilterHandler;
protected $afterFilterHandler;
public function __construct() {
$self = $this;
$this->defaultInvokeHandler = function(/*string*/ $name, array &$args, stdClass $context) use ($self) {
return $self->invokeHandler($name, $args, $context);
};
$this->defaultBeforeFilterHandler = function(/*string*/ $request, stdClass $context) use ($self) {
return $self->beforeFilterHandler($request, $context);
};
$this->defaultAfterFilterHandler = function(/*string*/ $request, stdClass $context) use ($self) {
return $self->afterFilterHandler($request, $context);
};
$this->invokeHandler = $this->defaultInvokeHandler;
$this->beforeFilterHandler = $this->defaultBeforeFilterHandler;
$this->afterFilterHandler = $this->defaultAfterFilterHandler;
}
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ abstract function invokeHandler(/*string*/ $name, array &$args, stdClass $context);
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ abstract function beforeFilterHandler(/*string*/ $request, stdClass $context);
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ abstract function afterFilterHandler(/*string*/ $request, stdClass $context);
protected function getNextInvokeHandler(Closure $next, /*callable*/ $handler) {
return function(/*string*/ $name, array $args, stdClass $context) use ($next, $handler) {
try {
return Future\toPromise(call_user_func($handler, $name, $args, $context, $next));
}
catch (Exception $e) {
return Future\error($e);
}
catch (Throwable $e) {
return Future\error($e);
}
};
}
protected function getNextFilterHandler(Closure $next, /*callable*/ $handler) {
return function(/*string*/ $request, stdClass $context) use ($next, $handler) {
try {
return Future\toPromise(call_user_func($handler, $request, $context, $next));
}
catch (Exception $e) {
return Future\error($e);
}
catch (Throwable $e) {
return Future\error($e);
}
};
}
public function addInvokeHandler(/*callable*/ $handler) {
if ($handler == null) return;
$this->invokeHandlers[] = $handler;
$next = $this->defaultInvokeHandler;
for ($i = count($this->invokeHandlers) - 1; $i >= 0; --$i) {
$next = $this->getNextInvokeHandler($next, $this->invokeHandlers[$i]);
}
$this->invokeHandler = $next;
return $this;
}
public function addBeforeFilterHandler(/*callable*/ $handler) {
if ($handler == null) return;
$this->beforeFilterHandlers[] = $handler;
$next = $this->defaultBeforeFilterHandler;
for ($i = count($this->beforeFilterHandlers) - 1; $i >= 0; --$i) {
$next = $this->getNextFilterHandler($next, $this->beforeFilterHandlers[$i]);
}
$this->beforeFilterHandler = $next;
return $this;
}
public function addAfterFilterHandler(/*callable*/ $handler) {
if ($handler == null) return;
$this->afterFilterHandlers[] = $handler;
$next = $this->defaultAfterFilterHandler;
for ($i = count($this->afterFilterHandlers) - 1; $i >= 0; --$i) {
$next = $this->getNextFilterHandler($next, $this->afterFilterHandlers[$i]);
}
$this->afterFilterHandler = $next;
return $this;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Http/Client.php *
* *
* hprose http client class for php 5.3+ *
* *
* LastModified: Jul 24, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Http;
use stdClass;
use Exception;
use Throwable;
use Hprose\Future;
class Client extends \Hprose\Client {
private static $cookieManager = array();
private $host = '';
private $path = '';
private $secure = false;
public $proxy = '';
public $keepAlive = true;
public $keepAliveTimeout = 300;
private $header;
private $options;
private $curl;
private $curlVersionLittleThan720;
private $results = array();
private $curls = array();
public static function keepSession() {
if (isset($_SESSION['HPROSE_COOKIE_MANAGER'])) {
self::$cookieManager = $_SESSION['HPROSE_COOKIE_MANAGER'];
}
$cookieManager = &self::$cookieManager;
register_shutdown_function(function() use (&$cookieManager) {
$_SESSION['HPROSE_COOKIE_MANAGER'] = $cookieManager;
});
}
public function __construct($uris = null, $async = true) {
parent::__construct($uris, $async);
$this->header = array('Content-type' => 'application/hprose');
$this->options = array(
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_NOSIGNAL => 1
);
if (!$async) {
$this->curl = curl_init();
}
$curl_version = curl_version();
$this->curlVersionLittleThan720 = (1 == version_compare('7.20.0', $curl_version['version']));
}
public function __destruct() {
if ($this->async) {
try {
$this->loop();
}
catch (Exception $e) {
}
}
else {
curl_close($this->curl);
}
}
public function setHeader($name, $value) {
$lname = strtolower($name);
if ($lname != 'content-type' &&
$lname != 'content-length' &&
$lname != 'host') {
if ($value) {
$this->header[$name] = $value;
}
else {
unset($this->header[$name]);
}
}
}
public function setOption($name, $value) {
$this->options[$name] = $value;
}
public function removeOption($name) {
unset($this->options[$name]);
}
public function setProxy($proxy = '') {
$this->proxy = $proxy;
}
public function setKeepAlive($keepAlive = true) {
$this->keepAlive = $keepAlive;
}
public function getKeepAlive() {
return $this->keepAlive;
}
public function setKeepAliveTimeout($timeout) {
$this->keepAliveTimeout = $timeout;
}
public function getKeepAliveTimeout() {
return $this->keepAliveTimeout;
}
private function setCookie(array $headers) {
foreach ($headers as $header) {
@list($name, $value) = explode(':', $header, 2);
if (strtolower($name) == 'set-cookie' ||
strtolower($name) == 'set-cookie2') {
$cookies = explode(';', trim($value));
$cookie = array();
$pair = explode('=', trim($cookies[0]), 2);
$cookie['name'] = $pair[0];
if (count($pair) > 1) $cookie['value'] = $pair[1];
for ($i = 1; $i < count($cookies); $i++) {
$pair = explode('=', trim($cookies[$i]), 2);
$cookie[strtoupper($pair[0])] = (count($pair) > 1) ? $pair[1] : '';
}
// Tomcat can return SetCookie2 with path wrapped in "
if (isset($cookie['PATH'])) {
$cookie['PATH'] = trim($cookie['PATH'], '"');
}
else {
$cookie['PATH'] = '/';
}
if (isset($cookie['DOMAIN'])) {
$cookie['DOMAIN'] = strtolower($cookie['DOMAIN']);
}
else {
$cookie['DOMAIN'] = $this->host;
}
if (!isset(self::$cookieManager[$cookie['DOMAIN']])) {
self::$cookieManager[$cookie['DOMAIN']] = array();
}
self::$cookieManager[$cookie['DOMAIN']][$cookie['name']] = $cookie;
}
}
}
private function getCookie() {
$cookies = array();
foreach (self::$cookieManager as $domain => $cookieList) {
if (strpos($this->host, $domain) !== false) {
$names = array();
foreach ($cookieList as $cookie) {
if (isset($cookie['EXPIRES']) && (time() > strtotime($cookie['EXPIRES']))) {
$names[] = $cookie['name'];
}
elseif (strpos($this->path, $cookie['PATH']) === 0) {
if ((($this->secure &&
isset($cookie['SECURE'])) ||
!isset($cookie['SECURE'])) &&
isset($cookie['value'])) {
$cookies[] = $cookie['name'] . '=' . $cookie['value'];
}
}
}
foreach ($names as $name) {
unset(self::$cookieManager[$domain][$name]);
}
}
}
if (count($cookies) > 0) {
return "Cookie: " . implode('; ', $cookies);
}
return '';
}
protected function setUri($uri) {
parent::setUri($uri);
$url = parse_url($uri);
$this->secure = (strtolower($url['scheme']) == 'https');
$this->host = strtolower($url['host']);
$this->path = isset($url['path']) ? $url['path'] : "/";
$this->keepAlive = true;
$this->keepAliveTimeout = 300;
}
private function initCurl($curl, $request, $timeout) {
foreach ($this->options as $name => $value) {
curl_setopt($curl, $name, $value);
}
curl_setopt($curl, CURLOPT_URL, $this->uri);
if (!ini_get('safe_mode')) {
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
$headers_array = array($this->getCookie(),
"Content-Length: " . strlen($request));
if ($this->keepAlive) {
$headers_array[] = "Connection: keep-alive";
$headers_array[] = "Keep-Alive: " . $this->keepAliveTimeout;
curl_setopt($curl, CURLOPT_FRESH_CONNECT, false);
curl_setopt($curl, CURLOPT_FORBID_REUSE, false);
}
else {
$headers_array[] = "Connection: close";
}
foreach ($this->header as $name => $value) {
$headers_array[] = $name . ": " . $value;
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers_array);
if ($this->proxy) {
curl_setopt($curl, CURLOPT_PROXY, $this->proxy);
}
if (defined('CURLOPT_TIMEOUT_MS')) {
curl_setopt($curl, CURLOPT_TIMEOUT_MS, $timeout);
}
else {
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout / 1000);
}
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function getContents($response) {
do {
list($response_headers, $response) = explode("\r\n\r\n", $response, 2);
$http_response_header = explode("\r\n", $response_headers);
$http_response_firstline = array_shift($http_response_header);
$matches = array();
if (preg_match('@^HTTP/[0-9]\.[0-9]\s([0-9]{3})\s(.*)@',
$http_response_firstline, $matches)) {
$response_code = $matches[1];
$response_status = trim($matches[2]);
}
else {
$response_code = "500";
$response_status = "Unknown Error.";
}
} while (substr($response_code, 0, 1) == "1");
if ($response_code != '200') {
throw new Exception($response_code . ": " . $response_status . "\r\n\r\n" . $response);
}
$this->setCookie($http_response_header);
return $response;
}
private function syncSendAndReceive($request, stdClass $context) {
$curl = $this->curl;
$this->initCurl($curl, $request, $context->timeout);
$data = curl_exec($curl);
$errno = curl_errno($curl);
if ($errno) {
throw new Exception($errno . ": " . curl_error($curl));
}
return $this->getContents($data);
}
private function asyncSendAndReceive($request, stdClass $context) {
$result = new Future();
$curl = curl_init();
$this->initCurl($curl, $request, $context->timeout);
$this->curls[] = $curl;
$this->results[] = $result;
return $result;
}
protected function sendAndReceive($request, stdClass $context) {
if ($this->async) {
return $this->asyncSendAndReceive($request, $context);
}
return $this->syncSendAndReceive($request, $context);
}
private function curlMultiExec($multicurl, &$active) {
if ($this->curlVersionLittleThan720) {
do {
$status = curl_multi_exec($multicurl, $active);
} while ($status === CURLM_CALL_MULTI_PERFORM);
return $status;
}
return curl_multi_exec($multicurl, $active);
}
public function loop() {
$self = $this;
$multicurl = curl_multi_init();
while (($count = count($this->curls)) > 0) {
$curls = $this->curls;
$this->curls = array();
$results = $this->results;
$this->results = array();
foreach ($curls as $curl) {
curl_multi_add_handle($multicurl, $curl);
}
$err = null;
try {
$active = null;
$status = $this->curlMultiExec($multicurl, $active);
while ($status === CURLM_OK && $count > 0) {
$status = $this->curlMultiExec($multicurl, $active);
$msgs_in_queue = null;
while ($info = curl_multi_info_read($multicurl, $msgs_in_queue)) {
$handle = $info['handle'];
$index = array_search($handle, $curls, true);
$results[$index]->resolve(Future\sync(function() use ($self, $info, $handle) {
if ($info['result'] === CURLM_OK) {
return $self->getContents(curl_multi_getcontent($handle));
}
throw new Exception($info['result'] . ": " . curl_error($handle));
}));
--$count;
if ($msgs_in_queue === 0) break;
}
}
}
catch (Exception $e) {
$err = $e;
}
catch (Throwable $e) {
$err = $e;
}
foreach($curls as $index => $curl) {
curl_multi_remove_handle($multicurl, $curl);
curl_close($curl);
if ($err !== null) $results[$index]->reject($err);
}
}
curl_multi_close($multicurl);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Http/Server.php *
* *
* hprose http server class for php 5.3+ *
* *
* LastModified: Jul 17, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Http;
class Server extends Service {
public function start() {
$this->handle();
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Http/Service.php *
* *
* hprose http service class for php 5.3+ *
* *
* LastModified: Jul 22, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Http;
use stdClass;
use Hprose\Future;
class Service extends \Hprose\Service {
const ORIGIN = 'HTTP_ORIGIN';
public $onSendHeader = null;
public $crossDomain = false;
public $p3p = false;
public $get = true;
private $origins = array();
public function header($name, $value, $context) {
header("$name: $value");
}
public function getAttribute($name, $context) {
return $_SERVER[$name];
}
public function hasAttribute($name, $context) {
return isset($_SERVER[$name]);
}
protected function readRequest($context) {
return file_get_contents("php://input");
}
protected function createContext($request, $response) {
$context = new stdClass();
$context->server = $this;
$context->request = $request;
$context->response = $response;
$context->userdata = new stdClass();
return $context;
}
public function writeResponse($data, $context) {
echo $data;
}
public function isGet($context) {
return @$_SERVER['REQUEST_METHOD'] === 'GET';
}
public function isPost($context) {
return @$_SERVER['REQUEST_METHOD'] === 'POST';
}
private function sendHeader($context) {
if ($this->onSendHeader !== null) {
$sendHeader = $this->onSendHeader;
call_user_func($sendHeader, $context);
}
$this->header('Content-Type', 'text/plain', $context);
if ($this->p3p) {
$this->header('P3P', 'CP="CAO DSP COR CUR ADM DEV TAI PSA PSD ' .
'IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi ' .
'UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV ' .
'INT DEM CNT STA POL HEA PRE GOV"', $context);
}
if ($this->crossDomain) {
if ($this->hasAttribute(static::ORIGIN, $context) &&
$this->getAttribute(static::ORIGIN, $context) != "null") {
$origin = $this->getAttribute(static::ORIGIN, $context);
if (count($this->origins) === 0 ||
isset($this->origins[strtolower($origin)])) {
$this->header('Access-Control-Allow-Origin', $origin, $context);
$this->header('Access-Control-Allow-Credentials', 'true', $context);
}
}
else {
$this->header('Access-Control-Allow-Origin', '*', $context);
}
}
}
public function isCrossDomainEnabled() {
return $this->crossDomain;
}
public function setCrossDomainEnabled($enable = true) {
$this->crossDomain = $enable;
}
public function isP3PEnabled() {
return $this->p3p;
}
public function setP3PEnabled($enable = true) {
$this->p3p = $enable;
}
public function isGetEnabled() {
return $this->get;
}
public function setGetEnabled($enable = true) {
$this->get = $enable;
}
public function addAccessControlAllowOrigin($origin) {
$count = count($origin);
if (($count > 0) && ($origin[$count - 1] === "/")) {
$origin = substr($origin, 0, -1);
}
$this->origins[strtolower($origin)] = true;
}
public function removeAccessControlAllowOrigin($origin) {
$count = count($origin);
if (($count > 0) && ($origin[$count - 1] === "/")) {
$origin = substr($origin, 0, -1);
}
unset($this->origins[strtolower($origin)]);
}
public function handle($request = null, $response = null) {
$context = $this->createContext($request, $response);
$self = $this;
$this->userFatalErrorHandler = function($error) use ($self, $context) {
$self->writeResponse($self->endError($error, $context), $context);
};
$this->sendHeader($context);
$result = '';
if ($this->isGet($context) && $this->get) {
$result = $this->doFunctionList();
}
elseif ($this->isPost($context)) {
$result = $this->defaultHandle($this->readRequest($context), $context);
}
else {
$result = $this->doFunctionList();
}
if (Future\isFuture($result)) {
$result->then(function($result) use ($self, $context) {
$self->writeResponse($result, $context);
});
}
else {
$self->writeResponse($result, $context);
}
return $context->response;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/InvokeSettings.php *
* *
* hprose InvokeSettings class for php 5.3+ *
* *
* LastModified: Jul 11, 2015 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class InvokeSettings {
public $settings;
public function __construct(array $settings = array()) {
if ($settings !== null) {
$this->settings = $settings;
}
else {
$this->settings = array();
}
}
public function __set($name, $value) {
$this->settings[$name] = $value;
}
public function __get($name) {
return $this->settings[$name];
}
public function __isset($name) {
return isset($this->settings[$name]);
}
public function __unset($name) {
unset($this->settings[$name]);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Promise.php *
* *
* Promise for php 5.3+ *
* *
* LastModified: Jul 23, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Promise extends Future {
public function __construct($executor = null) {
parent::__construct();
if (is_callable($executor)) {
$self = $this;
call_user_func($executor,
function($value) use ($self) {
$self->resolve($value);
},
function($reason) use ($self) {
$self->reject($reason);
}
);
}
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Promise/functions.php *
* *
* some helper functions for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Promise;
use Hprose\Future;
function isPromise($obj) {
return $obj instanceof Future;
}
function error($e) {
return Future\error($e);
}
function value($v) {
return Future\value($v);
}
function resolve($value) {
return value($value);
}
function reject($reason) {
return error($reason);
}
function sync($computation) {
return Future\sync($computation);
}
function promise($executor) {
return new Promise($executor);
}
function all($array) {
return Future\all($array);
}
function join() {
return all(func_get_args());
}
function race($array) {
return Future\race($array);
}
function any($array) {
return Future\any($array);
}
function settle($array) {
return Future\settle($array);
}
function run($handler/*, arg1, arg2, ... */) {
$args = array_slice(func_get_args(), 1);
return all($args)->then(
function($args) use ($handler) {
return call_user_func_array($handler, $args);
}
);
}
function wrap($handler) {
return Future\wrap($handler);
}
function each($array, $callback) {
return Future\each($array, $callback);
}
function every($array, $callback) {
return Future\every($array, $callback);
}
function some($array, $callback) {
return Future\some($array, $callback);
}
function filter($array, $callback, $preserveKeys = false) {
return Future\filter($array, $callback, $preserveKeys);
}
function map($array, $callback) {
return Future\map($array, $callback);
}
function reduce($array, $callback, $initial = NULL) {
return Future\reduce($array, $callback, $initial);
}
function search($array, $searchElement, $strict = false) {
return Future\search($array, $searchElement, $strict);
}
function includes($array, $searchElement, $strict = false) {
return Future\includes($array, $searchElement, $strict);
}
function diff(/*$array1, $array2, ...*/) {
return call_user_func_array("\\Hprose\\Future\\diff", func_get_args());
}
function udiff(/*$array1, $array2, $...*/) {
return call_user_func_array("\\Hprose\\Future\\udiff", func_get_args());
}
function toPromise($obj) {
return Future\toPromise($obj);
}
function arrayToPromise(array $array) {
return Future\arrayToPromise($array);
}
function objectToPromise($obj) {
return Future\objectToPromise($obj);
}
if (class_exists("\\Generator")) {
function co(/*$generator, arg1, arg2...*/) {
return call_user_func_array("\\Hprose\\Future\\co", func_get_args());
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Proxy.php *
* *
* hprose Proxy class for php 5.3+ *
* *
* LastModified: Jul 24, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Closure;
class Proxy {
private $client;
private $namespace;
public function __construct(Client $client, $namespace = '') {
$this->client = $client;
$this->namespace = $namespace;
}
public function __call($name, array $args) {
$name = $this->namespace . $name;
$n = count($args);
if ($n > 0) {
if ($args[$n - 1] instanceof Closure) {
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback);
}
else if ($args[$n - 1] instanceof InvokeSettings) {
if (($n > 1) && ($args[$n - 2] instanceof Closure)) {
$settings = array_pop($args);
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback, $settings);
}
$settings = array_pop($args);
return $this->client->invoke($name, $args, $settings);
}
else if (($n > 1) && is_array($args[$n - 1]) &&
($args[$n - 2] instanceof Closure)) {
$settings = new InvokeSettings(array_pop($args));
$callback = array_pop($args);
return $this->client->invoke($name, $args, $callback, $settings);
}
}
return $this->client->invoke($name, $args);
}
public function __get($name) {
return new Proxy($this->client, $this->namespace . $name . '_');
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/RawReader.php *
* *
* hprose raw reader class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
class RawReader {
public $stream;
public function __construct(BytesIO $stream) {
$this->stream = $stream;
}
public function unexpectedTag($tag, $expectTags = '') {
if ($tag && $expectTags) {
return new Exception("Tag '" . $expectTags . "' expected, but '" . $tag . "' found in stream");
}
else if ($tag) {
return new Exception("Unexpected serialize tag '" . $tag . "' in stream");
}
else {
return new Exception('No byte found in stream');
}
}
public function readRaw() {
$ostream = new BytesIO();
$this->privateReadRaw($ostream);
return $ostream;
}
private function privateReadRaw(BytesIO $ostream, $tag = '') {
if ($tag == '') {
$tag = $this->stream->getc();
}
$ostream->write($tag);
switch ($tag) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case Tags::TagNull:
case Tags::TagEmpty:
case Tags::TagTrue:
case Tags::TagFalse:
case Tags::TagNaN:
break;
case Tags::TagInfinity:
$ostream->write($this->stream->getc());
break;
case Tags::TagInteger:
case Tags::TagLong:
case Tags::TagDouble:
case Tags::TagRef:
$this->readNumberRaw($ostream);
break;
case Tags::TagDate:
case Tags::TagTime:
$this->readDateTimeRaw($ostream);
break;
case Tags::TagUTF8Char:
$this->readUTF8CharRaw($ostream);
break;
case Tags::TagBytes:
$this->readBytesRaw($ostream);
break;
case Tags::TagString:
$this->readStringRaw($ostream);
break;
case Tags::TagGuid:
$this->readGuidRaw($ostream);
break;
case Tags::TagList:
case Tags::TagMap:
case Tags::TagObject:
$this->readComplexRaw($ostream);
break;
case Tags::TagClass:
$this->readComplexRaw($ostream);
$this->privateReadRaw($ostream);
break;
case Tags::TagError:
$this->privateReadRaw($ostream);
break;
default: throw $this->unexpectedTag($tag);
}
}
private function readNumberRaw(BytesIO $ostream) {
$s = $this->stream->readuntil(Tags::TagSemicolon) .
Tags::TagSemicolon;
$ostream->write($s);
}
private function readDateTimeRaw(BytesIO $ostream) {
$s = '';
do {
$tag = $this->stream->getc();
$s .= $tag;
} while ($tag != Tags::TagSemicolon &&
$tag != Tags::TagUTC);
$ostream->write($s);
}
private function readUTF8CharRaw(BytesIO $ostream) {
$ostream->write($this->stream->readString(1));
}
private function readBytesRaw(BytesIO $ostream) {
$len = $this->stream->readuntil(Tags::TagQuote);
$s = $len . Tags::TagQuote . $this->stream->read((int)$len) . Tags::TagQuote;
$this->stream->skip(1);
$ostream->write($s);
}
private function readStringRaw(BytesIO $ostream) {
$len = $this->stream->readuntil(Tags::TagQuote);
$s = $len . Tags::TagQuote . $this->stream->readString((int)$len) . Tags::TagQuote;
$this->stream->skip(1);
$ostream->write($s);
}
private function readGuidRaw(BytesIO $ostream) {
$ostream->write($this->stream->read(38));
}
private function readComplexRaw(BytesIO $ostream) {
$s = $this->stream->readuntil(Tags::TagOpenbrace) .
Tags::TagOpenbrace;
$ostream->write($s);
while (($tag = $this->stream->getc()) != Tags::TagClosebrace) {
$this->privateReadRaw($ostream, $tag);
}
$ostream->write($tag);
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Reader.php *
* *
* hprose reader class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use stdClass;
use Exception;
use ReflectionClass;
use SplFixedArray;
class Reader extends RawReader {
private $classref;
private $refer;
public function __construct(BytesIO $stream, $simple = false) {
parent::__construct($stream);
$this->classref = array();
$this->refer = $simple ? new FakeReaderRefer() : new RealReaderRefer();
}
public function unserialize() {
$tag = $this->stream->getc();
switch ($tag) {
case '0': return 0;
case '1': return 1;
case '2': return 2;
case '3': return 3;
case '4': return 4;
case '5': return 5;
case '6': return 6;
case '7': return 7;
case '8': return 8;
case '9': return 9;
case Tags::TagInteger: return $this->readIntegerWithoutTag();
case Tags::TagLong: return $this->readLongWithoutTag();
case Tags::TagDouble: return $this->readDoubleWithoutTag();
case Tags::TagNull: return null;
case Tags::TagEmpty: return '';
case Tags::TagTrue: return true;
case Tags::TagFalse: return false;
case Tags::TagNaN: return log(-1);
case Tags::TagInfinity: return $this->readInfinityWithoutTag();
case Tags::TagDate: return $this->readDateWithoutTag();
case Tags::TagTime: return $this->readTimeWithoutTag();
case Tags::TagBytes: return $this->readBytesWithoutTag();
case Tags::TagUTF8Char: return $this->readUTF8CharWithoutTag();
case Tags::TagString: return $this->readStringWithoutTag();
case Tags::TagGuid: return $this->readGuidWithoutTag();
case Tags::TagList: return $this->readListWithoutTag();
case Tags::TagMap: return $this->readMapWithoutTag();
case Tags::TagClass: $this->readClass(); return $this->readObject();
case Tags::TagObject: return $this->readObjectWithoutTag();
case Tags::TagRef: return $this->readRef();
case Tags::TagError: throw new Exception($this->privateReadString());
default: throw $this->unexpectedTag($tag);
}
}
private function unserializeKey() {
$tag = $this->stream->getc();
switch ($tag) {
case '0': return 0;
case '1': return 1;
case '2': return 2;
case '3': return 3;
case '4': return 4;
case '5': return 5;
case '6': return 6;
case '7': return 7;
case '8': return 8;
case '9': return 9;
case Tags::TagInteger: return $this->readIntegerWithoutTag();
case Tags::TagLong:
case Tags::TagDouble: return $this->readLongWithoutTag();
case Tags::TagNull: return 'null';
case Tags::TagEmpty: return '';
case Tags::TagTrue: return 'true';
case Tags::TagFalse: return 'false';
case Tags::TagNaN: return (string)log(-1);
case Tags::TagInfinity: return (string)$this->readInfinityWithoutTag();
case Tags::TagBytes: return $this->readBytesWithoutTag();
case Tags::TagUTF8Char: return $this->readUTF8CharWithoutTag();
case Tags::TagString: return $this->readStringWithoutTag();
case Tags::TagGuid: return $this->readGuidWithoutTag();
case Tags::TagRef: return (string)$this->readRef();
case Tags::TagError: throw new Exception($this->privateReadString());
default: throw $this->unexpectedTag($tag);
}
}
public function checkTag($expectTag, $tag = null) {
if ($tag === null) {
$tag = $this->stream->getc();
}
if ($tag != $expectTag) {
throw $this->unexpectedTag($tag, $expectTag);
}
}
public function checkTags($expectTags, $tag = null) {
if ($tag === null) {
$tag = $this->stream->getc();
}
if (!strchr($expectTags, $tag)) {
throw $this->unexpectedTag($tag, $expectTags);
}
return $tag;
}
public function readIntegerWithoutTag() {
return (int)($this->stream->readuntil(Tags::TagSemicolon));
}
public function readInteger() {
$tag = $this->stream->getc();
switch ($tag) {
case '0': return 0;
case '1': return 1;
case '2': return 2;
case '3': return 3;
case '4': return 4;
case '5': return 5;
case '6': return 6;
case '7': return 7;
case '8': return 8;
case '9': return 9;
case Tags::TagInteger: return $this->readIntegerWithoutTag();
default: throw $this->unexpectedTag($tag);
}
}
public function readLongWithoutTag() {
return $this->stream->readuntil(Tags::TagSemicolon);
}
public function readLong() {
$tag = $this->stream->getc();
switch ($tag) {
case '0': return '0';
case '1': return '1';
case '2': return '2';
case '3': return '3';
case '4': return '4';
case '5': return '5';
case '6': return '6';
case '7': return '7';
case '8': return '8';
case '9': return '9';
case Tags::TagInteger:
case Tags::TagLong: return $this->readLongWithoutTag();
default: throw $this->unexpectedTag($tag);
}
}
public function readDoubleWithoutTag() {
return (float)($this->stream->readuntil(Tags::TagSemicolon));
}
public function readDouble() {
$tag = $this->stream->getc();
switch ($tag) {
case '0': return 0.0;
case '1': return 1.0;
case '2': return 2.0;
case '3': return 3.0;
case '4': return 4.0;
case '5': return 5.0;
case '6': return 6.0;
case '7': return 7.0;
case '8': return 8.0;
case '9': return 9.0;
case Tags::TagInteger:
case Tags::TagLong:
case Tags::TagDouble: return $this->readDoubleWithoutTag();
case Tags::TagNaN: return log(-1);
case Tags::TagInfinity: return $this->readInfinityWithoutTag();
default: throw $this->unexpectedTag($tag);
}
}
public function readNaN() {
$this->checkTag(Tags::TagNaN);
return log(-1);
}
public function readInfinityWithoutTag() {
return (($this->stream->getc() === Tags::TagNeg) ? log(0) : -log(0));
}
public function readInfinity() {
$this->checkTag(Tags::TagInfinity);
return $this->readInfinityWithoutTag();
}
public function readNull() {
$this->checkTag(Tags::TagNull);
return null;
}
public function readEmpty() {
$this->checkTag(Tags::TagEmpty);
return '';
}
public function readBoolean() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagTrue: return true;
case Tags::TagFalse: return false;
default: throw $this->unexpectedTag($tag);
}
}
public function readDateWithoutTag() {
$ymd = $this->stream->read(8);
$hms = '000000';
$u = '000000';
$tag = $this->stream->getc();
if ($tag == Tags::TagTime) {
$hms = $this->stream->read(6);
$tag = $this->stream->getc();
if ($tag == Tags::TagPoint) {
$u = $this->stream->read(3);
$tag = $this->stream->getc();
if (($tag >= '0') && ($tag <= '9')) {
$u .= $tag . $this->stream->read(2);
$tag = $this->stream->getc();
if (($tag >= '0') && ($tag <= '9')) {
$this->stream->skip(2);
$tag = $this->stream->getc();
}
}
else {
$u .= '000';
}
}
}
if ($tag == Tags::TagUTC) {
$date = date_create_from_format('YmdHisu', $ymd.$hms.$u, timezone_open('UTC'));
}
else {
$date = date_create_from_format('YmdHisu', $ymd.$hms.$u);
}
$this->refer->set($date);
return $date;
}
public function readDate() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagNull: return null;
case Tags::TagDate: return $this->readDateWithoutTag();
case Tags::TagRef: return $this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
public function readTimeWithoutTag() {
$hms = $this->stream->read(6);
$u = '000000';
$tag = $this->stream->getc();
if ($tag == Tags::TagPoint) {
$u = $this->stream->read(3);
$tag = $this->stream->getc();
if (($tag >= '0') && ($tag <= '9')) {
$u .= $tag . $this->stream->read(2);
$tag = $this->stream->getc();
if (($tag >= '0') && ($tag <= '9')) {
$this->stream->skip(2);
$tag = $this->stream->getc();
}
}
else {
$u .= '000';
}
}
if ($tag == Tags::TagUTC) {
$time = date_create_from_format('!Hisu', $hms.$u, timezone_open('UTC'));
}
else {
$time = date_create_from_format('!Hisu', $hms.$u);
}
$this->refer->set($time);
return $time;
}
public function readTime() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagNull: return null;
case Tags::TagTime: return $this->readTimeWithoutTag();
case Tags::TagRef: return $this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
public function readBytesWithoutTag() {
$count = (int)($this->stream->readuntil(Tags::TagQuote));
$bytes = $this->stream->read($count);
$this->stream->skip(1);
$this->refer->set($bytes);
return $bytes;
}
public function readBytes() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagNull: return null;
case Tags::TagEmpty: return '';
case Tags::TagBytes: return $this->readBytesWithoutTag();
case Tags::TagRef: return $this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
public function readUTF8CharWithoutTag() {
return $this->stream->readString(1);
}
public function readUTF8Char() {
$this->checkTag(Tags::TagUTF8Char);
return $this->readUTF8CharWithoutTag();
}
private function privateReadStringWithoutTag() {
$len = (int)$this->stream->readuntil(Tags::TagQuote);
$s = $this->stream->readString($len);
$this->stream->skip(1);
return $s;
}
public function readStringWithoutTag() {
$s = $this->privateReadStringWithoutTag();
$this->refer->set($s);
return $s;
}
private function privateReadString() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagUTF8Char: return $this->readUTF8CharWithoutTag();
case Tags::TagString: return $this->readStringWithoutTag();
case Tags::TagRef: return (string)$this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
public function readString() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagNull: return null;
case Tags::TagEmpty: return '';
case Tags::TagUTF8Char: return $this->readUTF8CharWithoutTag();
case Tags::TagString: return $this->readStringWithoutTag();
case Tags::TagRef: return $this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
public function readGuidWithoutTag() {
$this->stream->skip(1);
$s = $this->stream->read(36);
$this->stream->skip(1);
$this->refer->set($s);
return $s;
}
public function readGuid() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagNull: return null;
case Tags::TagGuid: return $this->readGuidWithoutTag();
case Tags::TagRef: return $this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
public function readListWithoutTag() {
$list = array();
$this->refer->set($list);
$count = (int)$this->stream->readuntil(Tags::TagOpenbrace);
for ($i = 0; $i < $count; ++$i) {
$list[$i] = $this->unserialize();
}
$this->stream->skip(1);
return $list;
}
public function readList() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagNull: $result = null; return $result;
case Tags::TagList: return $this->readListWithoutTag();
case Tags::TagRef: return $this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
public function readMapWithoutTag() {
$map = array();
$this->refer->set($map);
$count = (int)$this->stream->readuntil(Tags::TagOpenbrace);
for ($i = 0; $i < $count; ++$i) {
$key = $this->unserializeKey();
$map[$key] = $this->unserialize();
}
$this->stream->skip(1);
return $map;
}
public function readMap() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagNull: $result = null; return $result;
case Tags::TagMap: return $this->readMapWithoutTag();
case Tags::TagRef: return $this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
public function readObjectWithoutTag() {
$index = (int)$this->stream->readuntil(Tags::TagOpenbrace);
list($classname, $props) = $this->classref[$index];
if ($classname == 'stdClass') {
$object = new stdClass();
$this->refer->set($object);
foreach ($props as $prop) {
$object->$prop = $this->unserialize();
}
}
else {
$reflector = new ReflectionClass($classname);
if ($reflector->getConstructor() === null) {
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
$object = $reflector->newInstanceWithoutConstructor();
}
else {
$object = new $classname();
}
}
else {
$object = $reflector->newInstance();
}
$this->refer->set($object);
foreach ($props as $prop) {
$value = $this->unserialize();
if ($reflector->hasProperty($prop)) {
$property = $reflector->getProperty($prop);
$property->setAccessible(true);
$property->setValue($object, $value);
}
else {
$p = strtoupper($prop[0]) . substr($prop, 1);
if ($reflector->hasProperty($p)) {
$property = $reflector->getProperty($p);
$property->setAccessible(true);
$property->setValue($object, $value);
}
else {
$object->$prop = $value;
}
}
}
}
$this->stream->skip(1);
return $object;
}
public function readObject() {
$tag = $this->stream->getc();
switch ($tag) {
case Tags::TagNull: return null;
case Tags::TagClass: $this->readclass(); return $this->readObject();
case Tags::TagObject: return $this->readObjectWithoutTag();
case Tags::TagRef: return $this->readRef();
default: throw $this->unexpectedTag($tag);
}
}
protected function readClass() {
$classname = ClassManager::getClass($this->privateReadStringWithoutTag());
$count = (int)$this->stream->readuntil(Tags::TagOpenbrace);
$props = new SplFixedArray($count);
for ($i = 0; $i < $count; ++$i) {
$props[$i] = $this->privateReadString();
}
$this->stream->skip(1);
$this->classref[] = array($classname, $props);
}
protected function readRef() {
return $this->refer->read((int)$this->stream->readuntil(Tags::TagSemicolon));
}
public function reset() {
$this->classref = array();
$this->refer->reset();
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/ReaderRefer.php *
* *
* hprose reader reference interface for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
interface ReaderRefer {
public function set($val);
public function read($index);
public function reset();
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/RealReaderRefer.php *
* *
* hprose RealReaderRefer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class RealReaderRefer implements ReaderRefer {
private $ref;
public function __construct() {
$this->reset();
}
public function set($val) {
$this->ref[] = $val;
}
public function read($index) {
return $this->ref[$index];
}
public function reset() {
$this->ref = array();
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/RealWriterRefer.php *
* *
* hprose RealWriterRefer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use SplObjectStorage;
class RealWriterRefer implements WriterRefer {
private $oref;
private $sref = array();
private $refcount = 0;
public function __construct() {
$this->oref = new SplObjectStorage();
}
private function writeRef(BytesIO $stream, $index) {
$stream->write(Tags::TagRef . $index . Tags::TagSemicolon);
return true;
}
public function set($val) {
if (is_string($val)) {
$this->sref[$val] = $this->refcount;
}
elseif (is_object($val)) {
$this->oref->attach($val, $this->refcount);
}
$this->refcount++;
}
public function write(BytesIO $stream, $val) {
if (is_string($val) && isset($this->sref[$val])) {
return $this->writeRef($stream, $this->sref[$val]);
}
elseif (is_object($val) && isset($this->oref[$val])) {
return $this->writeRef($stream, $this->oref[$val]);
}
return false;
}
public function reset() {
$this->oref = new \SplObjectStorage();
$this->sref = array();
$this->refcount = 0;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/ResultMode.php *
* *
* hprose ResultMode enum for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class ResultMode {
const Normal = 0;
const Serialized = 1;
const Raw = 2;
const RawWithEndTag = 3;
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Service.php *
* *
* hprose service class for php 5.3+ *
* *
* LastModified: Jul 21, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use stdClass;
use ErrorException;
use Exception;
use Throwable;
use ArrayObject;
use SplQueue;
use Hprose\TimeoutException;
abstract class Service extends HandlerManager {
private static $magicMethods = array(
"__construct",
"__destruct",
"__call",
"__callStatic",
"__get",
"__set",
"__isset",
"__unset",
"__sleep",
"__wakeup",
"__toString",
"__invoke",
"__set_state",
"__clone"
);
private $calls = array();
private $names = array();
private $filters = array();
protected $userFatalErrorHandler = null;
public $onBeforeInvoke = null;
public $onAfterInvoke = null;
public $onSendError = null;
public $errorDelay = 10000;
public $errorTypes;
public $simple = false;
public $debug = false;
public $passContext = false;
// for push service
protected $timer = null;
public $timeout = 120000;
public $heartbeat = 3000;
public $onSubscribe = null;
public $onUnsubscribe = null;
private $topics = array();
private $nextid = 0;
public function __construct() {
parent::__construct();
$this->errorTypes = error_reporting();
register_shutdown_function(array($this, 'fatalErrorHandler'));
$this->addMethod('getNextId', $this, '#', array('simple' => true));
}
public function getNextId() {
return ($this->nextid < 0x7FFFFFFF) ? $this->nextid++ : $this->nextid = 0;
}
public function fatalErrorHandler() {
if (!is_callable($this->userFatalErrorHandler)) return;
$e = error_get_last();
if ($e == null) return;
switch ($e['type']) {
case E_ERROR:
case E_PARSE:
case E_USER_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR: {
$error = new ErrorException($e['message'], 0, $e['type'], $e['file'], $e['line']);
@ob_end_clean();
$userFatalErrorHandler = $this->userFatalErrorHandler;
call_user_func($userFatalErrorHandler, $error);
}
}
}
public final function getTimeout() {
return $this->timeout;
}
public final function setTimeout($value) {
$this->timeout = $value;
}
public final function getHeartbeat() {
return $this->heartbeat;
}
public final function setHeartbeat($value) {
$this->heartbeat = $value;
}
public final function getErrorDelay() {
return $this->errorDelay;
}
public final function setErrorDelay($value) {
$this->errorDelay = $value;
}
public final function getErrorTypes() {
return $this->errorTypes;
}
public final function setErrorTypes($value) {
$this->errorTypes = $value;
}
public final function isDebugEnabled() {
return $this->debug;
}
public final function setDebugEnabled($value = true) {
$this->debug = $value;
}
public final function isSimple() {
return $this->simple;
}
public final function setSimple($value = true) {
$this->simple = $value;
}
public final function isPassContext() {
return $this->passContext;
}
public final function setPassContext($value = true) {
$this->passContext = $value;
}
public final function getFilter() {
if (empty($this->filters)) {
return null;
}
return $this->filters[0];
}
public final function setFilter(Filter $filter) {
$this->filters = array();
if ($filter !== null) {
$this->filters[] = $filter;
}
}
public final function addFilter(Filter $filter) {
if ($filter !== null) {
if (empty($this->filters)) {
$this->filters = array($filter);
}
else {
$this->filters[] = $filter;
}
}
}
public final function removeFilter(Filter $filter) {
if (empty($this->filters)) {
return false;
}
$i = array_search($filter, $this->filters);
if ($i === false || $i === null) {
return false;
}
$this->filters = array_splice($this->filters, $i, 1);
return true;
}
protected function nextTick($callback) {
$callback();
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function callService(array $args, stdClass $context) {
if ($context->oneway) {
$this->nextTick(function() use ($args, $context) {
try {
call_user_func_array($context->method, $args);
}
catch (Exception $e) {}
catch (Throwable $e) {}
});
if ($context->async) {
call_user_func($args[count($args) - 1], null);
}
return null;
}
return call_user_func_array($context->method, $args);
}
private function inputFilter($data, stdClass $context) {
for ($i = count($this->filters) - 1; $i >= 0; $i--) {
$data = $this->filters[$i]->inputFilter($data, $context);
}
return $data;
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function outputFilter($data, stdClass $context) {
for ($i = 0, $n = count($this->filters); $i < $n; $i++) {
$data = $this->filters[$i]->outputFilter($data, $context);
}
return $data;
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function sendError($error, stdClass $context) {
if (is_string($error)) {
$error = new Exception($error);
}
try {
if ($this->onSendError !== null) {
$onSendError = $this->onSendError;
$e = call_user_func_array($onSendError, array(&$error, $context));
if ($e instanceof Exception || $e instanceof Throwable) {
$error = $e;
}
}
}
catch (Exception $e) {
$error = $e;
}
$stream = new BytesIO();
$writer = new Writer($stream, true);
$stream->write(Tags::TagError);
$writer->writeString($this->debug ? $error->getTraceAsString() : $error->getMessage());
return $stream;
}
public function endError($error, stdClass $context) {
$stream = $this->sendError($error, $context);
$stream->write(Tags::TagEnd);
$data = $stream->toString();
$stream->close();
return $data;
}
private function beforeInvoke($name, array &$args, stdClass $context) {
try {
$self = $this;
if ($this->onBeforeInvoke !== null) {
$onBeforeInvoke = $this->onBeforeInvoke;
$value = call_user_func_array($onBeforeInvoke, array($name, &$args, $context->byref, $context));
if ($value instanceof Exception || $value instanceof Throwable) {
throw $value;
}
if (Future\isFuture($value)) {
return $value->then(function($value) use ($self, $name, $args, $context) {
if ($value instanceof Exception || $value instanceof Throwable) {
throw $value;
}
return $self->invoke($name, $args, $context);
})->then(null, function($error) use ($self, $context) {
return $self->sendError($error, $context);
});
}
}
return $this->invoke($name, $args, $context)->then(null, function($error) use ($self, $context) {
return $self->sendError($error, $context);
});
}
catch (Exception $error) {
return $this->sendError($error, $context);
}
}
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ function invokeHandler($name, array &$args, stdClass $context) {
if (array_key_exists('*', $this->calls) &&
($context->method === $this->calls['*']->method)) {
$args = array($name, $args);
}
$passContext = $context->passContext;
if ($passContext === null) {
$passContext = $this->passContext;
}
if ($context->async) {
$self = $this;
return Future\promise(function($resolve, $reject) use ($self, $passContext, &$args, $context) {
if ($passContext) $args[] = $context;
$args[] = function($value) use ($resolve, $reject) {
if ($value instanceof Exception || $value instanceof Throwable) {
$reject($value);
}
else {
$resolve($value);
}
};
$self->callService($args, $context);
});
}
else {
if ($passContext) $args[] = $context;
return Future\toPromise($this->callService($args, $context));
}
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function invoke($name, array &$args, stdClass $context) {
$invokeHandler = $this->invokeHandler;
$self = $this;
return $invokeHandler($name, $args, $context)
->then(function($value) use ($self, $name, &$args, $context) {
if ($value instanceof Exception || $value instanceof Throwable) {
throw $value;
}
return $self->afterInvoke($name, $args, $context, $value);
});
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function afterInvoke($name, array $args, stdClass $context, $result) {
if ($context->async && is_callable($args[count($args) - 1])) {
unset($args[count($args) - 1]);
}
if ($context->passContext && ($args[count($args) - 1] === $context)) {
unset($args[count($args) - 1]);
}
if ($this->onAfterInvoke !== null) {
$onAfterInvoke = $this->onAfterInvoke;
$value = call_user_func_array($onAfterInvoke, array($name, &$args, $context->byref, &$result, $context));
if ($value instanceof Exception || $value instanceof Throwable) {
throw $value;
}
if (Future\isFuture($value)) {
$self = $this;
return $value->then(function($value) use ($self, $args, $context, $result) {
if ($value instanceof Exception || $value instanceof Throwable) {
throw $value;
}
return $self->doOutput($args, $context, $result);
});
}
}
return $this->doOutput($args, $context, $result);
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function doOutput(array $args, stdClass $context, $result) {
$mode = $context->mode;
$simple = $context->simple;
if ($simple === null) {
$simple = $this->simple;
}
if ($mode === ResultMode::RawWithEndTag || $mode == ResultMode::Raw) {
return $result;
}
$stream = new BytesIO();
$writer = new Writer($stream, $simple);
$stream->write(Tags::TagResult);
if ($mode === ResultMode::Serialized) {
$stream->write($result);
}
else {
$writer->reset();
$writer->serialize($result);
}
if ($context->byref) {
$stream->write(Tags::TagArgument);
$writer->reset();
$writer->writeArray($args);
}
$data = $stream->toString();
$stream->close();
return $data;
}
private function doInvoke(BytesIO $stream, stdClass $context) {
$results = array();
$reader = new Reader($stream);
do {
$reader->reset();
$name = $reader->readString();
$alias = strtolower($name);
$cc = new stdClass();
foreach ($context as $key => $value) {
$cc->$key = $value;
}
$call = isset($this->calls[$alias]) ?
$this->calls[$alias] : $this->call['*'];
if ($call) {
foreach ($call as $key => $value) {
$cc->$key = $value;
}
}
$args = array();
$cc->byref = false;
$tag = $stream->getc();
if ($tag === Tags::TagList) {
$reader->reset();
$args = $reader->readListWithoutTag();
$tag = $stream->getc();
if ($tag === Tags::TagTrue) {
$cc->byref = true;
$tag = $stream->getc();
}
}
if ($tag !== Tags::TagEnd && $tag !== Tags::TagCall) {
$data = $stream->toString();
throw new Exception("Unknown tag: $tag\r\nwith following data: $data");
}
if ($call) {
$results[] = $this->beforeInvoke($name, $args, $cc);
}
else {
$results[] = $this->sendError(new Exception("Can\'t find this function $name()."), $cc);
}
} while($tag === Tags::TagCall);
return Future\reduce($results, function($stream, $result) {
$stream->write($result);
return $stream;
}, new BytesIO())->then(function($stream) {
$stream->write(Tags::TagEnd);
$data = $stream->toString();
$stream->close();
return $data;
});
}
protected function doFunctionList() {
$stream = new BytesIO();
$writer = new Writer($stream, true);
$stream->write(Tags::TagFunctions);
$writer->writeArray($this->names);
$stream->write(Tags::TagEnd);
$data = $stream->toString();
$stream->close();
return $data;
}
protected function delay($interval, $data) {
$seconds = floor($interval);
$nanoseconds = ($interval - $seconds) * 1000000000;
time_nanosleep($seconds, $nanoseconds);
return Future\value($data);
}
/*
This method is a private method.
But PHP 5.3 can't call private method in closure,
so we comment the private keyword.
*/
/*private*/ function delayError($error, $context) {
$err = $this->endError($error, $context);
if ($this->errorDelay > 0) {
return $this->delay($this->errorDelay, $err);
}
return Future\value($err);
}
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ function beforeFilterHandler($request, stdClass $context) {
$self = $this;
try {
$afterFilterHandler = $this->afterFilterHandler;
$response = $afterFilterHandler($this->inputFilter($request, $context), $context)
->then(null, function($error) use ($self, $context) {
return $self->delayError($error, $context);
});
}
catch (Exception $error) {
$response = $this->delayError($error, $context);
}
return $response->then(function($value) use ($self, $context) {
return $self->outputFilter($value, $context);
});
}
/*
This method is a protected method.
But PHP 5.3 can't call protected method in closure,
so we comment the protected keyword.
*/
/*protected*/ function afterFilterHandler($request, stdClass $context) {
$stream = new BytesIO($request);
try {
switch ($stream->getc()) {
case Tags::TagCall: {
$data = $this->doInvoke($stream, $context);
$stream->close();
return $data;
}
case Tags::TagEnd: {
$stream->close();
return Future\value($this->doFunctionList());
}
default: throw new Exception("Wrong Request: \r\n$request");
}
}
catch (Exception $e) {
$stream->close();
return Future\error($e);
}
}
public function defaultHandle($request, stdClass $context) {
$error = null;
set_error_handler(function($errno, $errstr, $errfile, $errline) use (&$error) {
$error = new \ErrorException($errstr, 0, $errno, $errfile, $errline);
}, $this->errorTypes);
ob_start();
ob_implicit_flush(0);
$context->clients = $this;
$beforeFilterHandler = $this->beforeFilterHandler;
$response = $beforeFilterHandler($request, $context);
return $response->then(function($result) use (&$error, $context) {
@ob_end_clean();
restore_error_handler();
if ($error === null) {
return $result;
}
return $this->endError($error, $context);
});
}
private static function getDeclaredOnlyMethods($class) {
$result = get_class_methods($class);
if (($parentClass = get_parent_class($class)) !== false) {
$inherit = get_class_methods($parentClass);
$result = array_diff($result, $inherit);
}
return array_diff($result, self::$magicMethods);
}
public function addFunction($func, $alias = '', array $options = array()) {
if (!is_callable($func)) {
throw new Exception('Argument func must be callable.');
}
if (is_array($alias) && empty($options)) {
$options = $alias;
$alias = '';
}
if (empty($alias)) {
if (is_string($func)) {
$alias = $func;
}
elseif (is_array($func)) {
$alias = $func[1];
}
else {
throw new Exception('Need an alias');
}
}
$name = strtolower($alias);
if (!array_key_exists($name, $this->calls)) {
$this->names[] = $alias;
}
$call = new stdClass();
$call->method = $func;
$call->mode = isset($options['mode']) ? $options['mode'] : ResultMode::Normal;
$call->simple = @$options['simple'];
$call->oneway = !!@$options['oneway'];
$call->async = !!@$options['async'];
$call->passContext = @$options['passContext'];
$this->calls[$name] = $call;
}
public function addAsyncFunction($func,
$alias = '',
array $options = array()) {
if (is_array($alias) && empty($options)) {
$options = $alias;
$alias = '';
}
$options['async'] = true;
$this->addFunction($func, $alias, $options);
}
public function addMissingFunction($func, array $options = array()) {
$this->addFunction($func, '*', $options);
}
public function addAsyncMissingFunction($func, array $options = array()) {
$this->addAsyncFunction($func, '*', $options);
}
public function addFunctions(array $funcs,
array $aliases = array(),
array $options = array()) {
if (!empty($aliases) && empty($options) && (array_keys($funcs) != array_key($aliases))) {
$options = $aliases;
$aliases = array();
}
$count = count($aliases);
if ($count == 0) {
foreach ($funcs as $func) {
$this->addFunction($func, '', $options);
}
}
elseif ($count == count($funcs)) {
foreach ($funcs as $i => $func) {
$this->addFunction($func, $aliases[$i], $options);
}
}
else {
throw new Exception('The count of functions is not matched with aliases');
}
}
public function addAsyncFunctions(array $funcs,
array $aliases = array(),
array $options = array()) {
if (!empty($aliases) && empty($options) && (array_keys($funcs) != array_key($aliases))) {
$options = $aliases;
$aliases = array();
}
$options['async'] = true;
$this->addFunctions($funcs, $aliases, $options);
}
public function addMethod($method,
$scope,
$alias = '',
array $options = array()) {
$func = array($scope, $method);
$this->addFunction($func, $alias, $options);
}
public function addAsyncMethod($method,
$scope,
$alias = '',
array $options = array()) {
$func = array($scope, $method);
$this->addAsyncFunction($func, $alias, $options);
}
public function addMissingMethod($method, $scope, array $options = array()) {
$this->addMethod($method, $scope, '*', $options);
}
public function addAsyncMissingMethod($method, $scope, array $options = array()) {
$this->addAsyncMethod($method, $scope, '*', $options);
}
public function addMethods($methods,
$scope,
$aliases = array(),
array $options = array()) {
$aliasPrefix = '';
if (is_string($aliases)) {
$aliasPrefix = $aliases;
if ($aliasPrefix !== '') {
$aliasPrefix .= '_';
}
$aliases = array();
}
else if (!empty($aliases) && empty($options) && (array_keys($methods) != array_key($aliases))) {
$options = $aliases;
$aliases = array();
}
if (empty($aliases)) {
foreach ($methods as $k => $method) {
$aliases[$k] = $aliasPrefix . $method;
}
}
if (count($methods) != count($aliases)) {
throw new Exception('The count of methods is not matched with aliases');
}
foreach($methods as $k => $method) {
$func = array($scope, $method);
if (is_callable($func)) {
$this->addFunction($func, $aliases[$k], $options);
}
}
}
public function addAsyncMethods($methods,
$scope,
$aliases = array(),
array $options = array()) {
$aliasPrefix = '';
if (is_string($aliases)) {
$aliasPrefix = $aliases;
if ($aliasPrefix !== '') {
$aliasPrefix .= '_';
}
$aliases = array();
}
else if (!empty($aliases) && empty($options) && (array_keys($methods) != array_key($aliases))) {
$options = $aliases;
$aliases = array();
}
if (empty($aliases)) {
foreach ($methods as $k => $method) {
$aliases[$k] = $aliasPrefix . $method;
}
}
if (count($methods) != count($aliases)) {
throw new Exception('The count of methods is not matched with aliases');
}
foreach($methods as $k => $method) {
$func = array($scope, $method);
if (is_callable($func)) {
$this->addAsyncFunction($func, $aliases[$k], $options);
}
}
}
public function addInstanceMethods($object,
$class = '',
$aliasPrefix = '',
array $options = array()) {
if ($class == '') {
$class = get_class($object);
}
$this->addMethods(self::getDeclaredOnlyMethods($class),
$object, $aliasPrefix, $options);
}
public function addAsyncInstanceMethods($object,
$class = '',
$aliasPrefix = '',
array $options = array()) {
if ($class == '') {
$class = get_class($object);
}
$this->addAsyncMethods(self::getDeclaredOnlyMethods($class),
$object, $aliasPrefix, $options);
}
public function addClassMethods($class,
$scope = '',
$aliasPrefix = '',
array $options = array()) {
if ($scope == '') {
$scope = $class;
}
$this->addMethods(self::getDeclaredOnlyMethods($class),
$scope, $aliasPrefix, $options);
}
public function addAsyncClassMethods($class,
$scope = '',
$aliasPrefix = '',
array $options = array()) {
if ($scope == '') {
$scope = $class;
}
$this->addAsyncMethods(self::getDeclaredOnlyMethods($class),
$scope, $aliasPrefix, $options);
}
public function add() {
$args_num = func_num_args();
$args = func_get_args();
switch ($args_num) {
case 1: {
if (is_callable($args[0])) {
$this->addFunction($args[0]);
return;
}
elseif (is_array($args[0])) {
$this->addFunctions($args[0]);
return;
}
elseif (is_object($args[0])) {
$this->addInstanceMethods($args[0]);
return;
}
elseif (is_string($args[0])) {
$this->addClassMethods($args[0]);
return;
}
break;
}
case 2: {
if (is_callable($args[0]) && is_string($args[1])) {
$this->addFunction($args[0], $args[1]);
return;
}
elseif (is_string($args[0])) {
if (is_string($args[1]) && !is_callable(array($args[1], $args[0]))) {
if (class_exists($args[1])) {
$this->addClassMethods($args[0], $args[1]);
}
else {
$this->addClassMethods($args[0], '', $args[1]);
}
}
else {
$this->addMethod($args[0], $args[1]);
}
return;
}
elseif (is_array($args[0])) {
if (is_array($args[1])) {
$this->addFunctions($args[0], $args[1]);
}
else {
$this->addMethods($args[0], $args[1]);
}
return;
}
elseif (is_object($args[0])) {
$this->addInstanceMethods($args[0], $args[1]);
return;
}
break;
}
case 3: {
if (is_callable($args[0]) && $args[1] == '' && is_string($args[2])) {
$this->addFunction($args[0], $args[2]);
return;
}
elseif (is_string($args[0]) && is_string($args[2])) {
if (is_string($args[1]) && !is_callable(array($args[1], $args[0]))) {
$this->addClassMethods($args[0], $args[1], $args[2]);
}
else {
$this->addMethod($args[0], $args[1], $args[2]);
}
return;
}
elseif (is_array($args[0])) {
if ($args[1] == '' && is_array($args[2])) {
$this->addFunctions($args[0], $args[2]);
}
else {
$this->addMethods($args[0], $args[1], $args[2]);
}
return;
}
elseif (is_object($args[0])) {
$this->addInstanceMethods($args[0], $args[1], $args[2]);
return;
}
break;
}
}
throw new Exception('Wrong arguments');
}
public function addAsync() {
$args_num = func_num_args();
$args = func_get_args();
switch ($args_num) {
case 1: {
if (is_callable($args[0])) {
$this->addAsyncFunction($args[0]);
return;
}
elseif (is_array($args[0])) {
$this->addAsyncFunctions($args[0]);
return;
}
elseif (is_object($args[0])) {
$this->addAsyncInstanceMethods($args[0]);
return;
}
elseif (is_string($args[0])) {
$this->addAsyncClassMethods($args[0]);
return;
}
break;
}
case 2: {
if (is_callable($args[0]) && is_string($args[1])) {
$this->addAsyncFunction($args[0], $args[1]);
return;
}
elseif (is_string($args[0])) {
if (is_string($args[1]) && !is_callable(array($args[1], $args[0]))) {
if (class_exists($args[1])) {
$this->addAsyncClassMethods($args[0], $args[1]);
}
else {
$this->addAsyncClassMethods($args[0], '', $args[1]);
}
}
else {
$this->addAsyncMethod($args[0], $args[1]);
}
return;
}
elseif (is_array($args[0])) {
if (is_array($args[1])) {
$this->addAsyncFunctions($args[0], $args[1]);
}
else {
$this->addAsyncMethods($args[0], $args[1]);
}
return;
}
elseif (is_object($args[0])) {
$this->addAsyncInstanceMethods($args[0], $args[1]);
return;
}
break;
}
case 3: {
if (is_callable($args[0]) && $args[1] == '' && is_string($args[2])) {
$this->addAsyncFunction($args[0], $args[2]);
return;
}
elseif (is_string($args[0]) && is_string($args[2])) {
if (is_string($args[1]) && !is_callable(array($args[1], $args[0]))) {
$this->addAsyncClassMethods($args[0], $args[1], $args[2]);
}
else {
$this->addAsyncMethod($args[0], $args[1], $args[2]);
}
return;
}
elseif (is_array($args[0])) {
if ($args[1] == '' && is_array($args[2])) {
$this->addAsyncFunctions($args[0], $args[2]);
}
else {
$this->addAsyncMethods($args[0], $args[1], $args[2]);
}
return;
}
elseif (is_object($args[0])) {
$this->addAsyncInstanceMethods($args[0], $args[1], $args[2]);
return;
}
break;
}
}
throw new Exception('Wrong arguments');
}
// for push service
private function checkPushService() {
if ($this->timer === null) {
throw new Exception(get_class($this) . " can't support push service.");
}
}
public function getTopics($topic) {
if (empty($this->topics[$topic])) {
throw new Exception('topic "' + $topic + '" is not published.');
}
return $this->topics[$topic];
}
public function delTimer(ArrayObject $topics, $id) {
$t = $topics[$id];
if (isset($t->timer)) {
$this->timer->clearTimeout($t->timer);
unset($t->timer);
}
}
public function offline(ArrayObject $topics, $topic, $id) {
$this->delTimer($topics, $id);
$messages = $topics[$id]->messages;
unset($topics[$id]);
foreach ($messages as $message) {
$message->detector->resolve(false);
}
$onUnsubscribe = $this->onUnsubscribe;
if (is_callable($onUnsubscribe)) {
call_user_func($onUnsubscribe, $topic, $id, $this);
}
}
public function setTimer(ArrayObject $topics, $topic, $id) {
$t = $topics[$id];
if (!isset($t->timer)) {
$self = $this;
$t->timer = $this->timer->setTimeout(function()
use ($self, $topics, $topic, $id) {
$self->offline($topics, $topic, $id);
}, $t->heartbeat);
}
}
public function resetTimer(ArrayObject $topics, $topic, $id) {
$this->delTimer($topics, $id);
$this->setTimer($topics, $topic, $id);
}
public function setRequestTimer($topic, $id, $request, $timeout) {
if ($timeout > 0) {
$self = $this;
$topics = $this->getTopics($topic);
$future = new Future();
$timer = $this->timer->setTimeout(function() use ($future) {
$future->reject(new TimeoutException('timeout'));
}, $timeout);
$request->whenComplete(function() use ($self, $timer) {
$self->timer->clearTimeout($timer);
})->fill($future);
return $future->catchError(function($e) use ($self, $topics, $topic, $id) {
$t = $topics[$id];
if ($e instanceof TimeoutException) {
$checkoffline = function() use ($self, $t, &$checkoffline, $topics, $topic, $id) {
$t->timer = $self->timer->setTimeout($checkoffline, $t->heartbeat);
if ($t->count < 0) {
$self->offline($topics, $topic, $id);
}
else {
--$t->count;
}
};
$checkoffline();
}
else {
--$t->count;
}
});
}
return $request;
}
public function publish($topic, array $options = array()) {
$this->checkPushService();
if (is_array($topic)) {
foreach ($topic as $t) {
$this->publish($t, $options);
}
return;
}
$self = $this;
$timeout = isset($options['timeout']) ? $options['timeout'] : $this->timeout;
$heartbeat = isset($options['heartbeat']) ? $options['heartbeat'] : $this->heartbeat;
$this->topics[$topic] = new ArrayObject();
$this->addFunction(function($id) use ($self, $topic, $timeout, $heartbeat) {
$topics = $self->getTopics($topic);
if (isset($topics[$id])) {
if ($topics[$id]->count < 0) {
$topics[$id]->count = 0;
}
$messages = $topics[$id]->messages;
if (!empty($messages)) {
$message = $messages->shift();
$message->detector->resolve(true);
$self->resetTimer($topics, $topic, $id);
return $message->result;
}
else {
$self->delTimer($topics, $id);
$topics[$id]->count++;
}
}
else {
$topics[$id] = new stdClass();
$topics[$id]->messages = new SplQueue();
$topics[$id]->count = 1;
$topics[$id]->heartbeat = $heartbeat;
$onSubscribe = $self->onSubscribe;
if (is_callable($onSubscribe)) {
call_user_func($onSubscribe, $topic, $id, $self);
}
}
if (isset($topics[$id]->request)) {
$topics[$id]->request->resolve(null);
}
$request = new Future();
$request->complete(function() use ($topics, $id) {
$topics[$id]->count--;
});
$topics[$id]->request = $request;
return $self->setRequestTimer($topic, $id, $request, $timeout);
}, $topic);
}
private function internalPush($topic, $id, $result) {
$topics = $this->getTopics($topic);
if (!isset($topics[$id])) {
return Future\value(false);
}
if (isset($topics[$id]->request)) {
$topics[$id]->request->resolve($result);
unset($topics[$id]->request);
return Future\value(true);
}
else {
$detector = new Future();
$message = new stdClass();
$message->detector = $detector;
$message->result = $result;
$topics[$id]->messages->push($message);
$this->setTimer($topics, $topic, $id);
return $detector;
}
}
public function idlist($topic) {
return array_keys($this->getTopics($topic)->getArrayCopy());
}
public function exist($topic, $id) {
$topics = $this->getTopics($topic);
return isset($topics[$id]);
}
public function broadcast($topic, $result, $callback = null) {
$this->checkPushService();
$this->multicast($topic, $this->idlist($topic), $result, $callback);
}
public function multicast($topic, $ids, $result, $callback = null) {
$this->checkPushService();
if (!is_callable($callback)) {
foreach ($ids as $id) {
$this->internalPush($topic, $id, $result);
}
return;
}
$sent = array();
$unsent = array();
$n = count($ids);
$count = $n;
$check = function($id) use (&$sent, &$unsent, &$count, $callback) {
return function($success) use ($id, &$sent, &$unsent, &$count, $callback) {
if ($success) {
$sent[] = $id;
}
else {
$unsent[] = $id;
}
if (--$count === 0) {
call_user_func($callback, $sent, $unsent);
}
};
};
for ($i = 0; $i < $n; ++$i) {
$id = $ids[$i];
if ($id !== null) {
$this->internalPush($topic, $id, $result)->then($check($id));
}
else {
--$count;
}
}
}
public function unicast($topic, $id, $result, $callback = null) {
$this->checkPushService();
$detector = $this->internalPush($topic, $id, $result);
if (is_callable($callback)) {
$detector->then($callback);
}
}
// push($topic, $result)
// push($topic, $ids, $result)
// push($topic, $id, $result)
public function push($topic) {
$this->checkPushService();
$args = func_get_args();
$argc = func_num_args();
$id = null;
$result = null;
if (($argc < 2) || ($argc > 3)) {
throw new Exception('Wrong number of arguments');
}
if ($argc === 2) {
$result = $args[1];
}
else {
$id = $args[1];
$result = $args[2];
}
if ($id === null) {
$topics = $this->getTopics($topic);
$iterator = $topics->getIterator();
while($iterator->valid()) {
$id = $iterator->key();
$this->internalPush($topic, $id, $result);
$iterator->next();
}
}
elseif (is_array($id)) {
$ids = $id;
foreach ($ids as $id) {
$this->internalPush($topic, $id, $result);
}
}
else {
$this->internalPush($topic, $id, $result);
}
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/Client.php *
* *
* hprose socket client class for php 5.3+ *
* *
* LastModified: Jul 12, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
use stdClass;
use Exception;
class Client extends \Hprose\Client {
private $hdtrans;
private $fdtrans;
public $fullDuplex = false;
public $readBuffer = 8192;
public $writeBuffer = 8192;
public $maxPoolSize = 10;
public $options = null;
public function __construct($uris = null, $async = true) {
parent::__construct($uris, $async);
$this->hdtrans = new HalfDuplexTransporter($this, $async);
$this->fdtrans = new FullDuplexTransporter($this, $async);
}
public function __destruct() {
try {
$this->loop();
}
catch (\Exception $e) {
}
}
public function isFullDuplex() {
return $this->fullDuplex;
}
public function setFullDuplex($fullDuplex) {
$this->fullDuplex = $fullDuplex;
}
public function getReadBuffer() {
return $this->readBuffer;
}
public function setReadBuffer($size) {
$this->readBuffer = $size;
}
public function getWriteBuffer() {
return $this->writeBuffer;
}
public function setWriteBuffer($size) {
$this->writeBuffer = $size;
}
public function getMaxPoolSize() {
return $this->maxPoolSize;
}
public function setMaxPoolSize($maxPoolSize) {
if ($maxPoolSize < 1) throw new Exception("maxPoolSize must be great than 0");
$this->maxPoolSize = $maxPoolSize;
}
protected function sendAndReceive($request, stdClass $context) {
if ($this->fullDuplex) {
return $this->fdtrans->sendAndReceive($request, $context);
}
return $this->hdtrans->sendAndReceive($request, $context);
}
public function getOptions() {
return $this->options;
}
public function setOptions(array $options) {
$this->options = $options;
}
public function set($key, $value) {
$this->options[$key] = $value;
return $this;
}
public function loop() {
if ($this->fullDuplex) {
$this->fdtrans->loop();
}
else {
$this->hdtrans->loop();
}
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/DataBuffer.php *
* *
* hprose socket DataBuffer class for php 5.3+ *
* *
* LastModified: Jul 12, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
class DataBuffer {
public $index;
public $buffer;
public $length;
public $id;
public function __construct($index, $buffer, $length, $id = null) {
$this->index = $index;
$this->buffer = $buffer;
$this->length = $length;
$this->id = $id;
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/FullDuplexTransporter.php *
* *
* hprose socket FullDuplexTransporter class for php 5.3+ *
* *
* LastModified: Jul 12, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
class FullDuplexTransporter extends Transporter {
private $id = 0;
private function getId() {
return $this->id++;
}
protected function appendHeader($request, $id = null) {
if ($id === null) {
$id = $this->getId();
}
return pack("NN", strlen($request) | 0x80000000, $id) . $request;
}
protected function createRequest($index, $request) {
$id = $this->getId();
$buffer = $this->appendHeader($request, $id);
return new DataBuffer($index, $buffer, strlen($buffer), $id);
}
protected function afterWrite($request, $stream, $o) {
$response = new DataBuffer($request->index, '', 0, $request->id);
$stream_id = (integer)$stream;
unset($o->requests[$stream_id]);
if (empty($o->queue[$stream_id])) {
$o->queue[$stream_id] = array();
$o->readpool[] = $stream;
}
$o->queue[$stream_id][$request->id] = $response;
}
protected function asyncReadError($o, $stream, $index) {
$stream_id = (integer)$stream;
foreach ($o->queue[$stream_id] as $response) {
$index = $response->index;
$o->results[$index]->reject($this->getLastError('response read error'));
$this->free($o, $index);
}
unset($o->queue[$stream_id]);
unset($o->responses[$stream_id]);
fclose($stream);
$this->removeStream($stream, $o->readpool);
$this->removeStream($stream, $o->writepool);
}
private function getHeaderInfo($stream) {
$header = $this->readHeader($stream, 8);
if ($header === false) return false;
list(, $length, $id) = unpack('N*', $header);
$length &= 0x7FFFFFFF;
return array($length, $id);
}
protected function getBodyLength($stream) {
$headerInfo = $this->getHeaderInfo($stream);
if ($headerInfo === false) return false;
return $headerInfo[0];
}
protected function getResponse($stream, $o) {
$stream_id = (integer)$stream;
if (isset($o->responses[$stream_id])) {
$response = $o->responses[$stream_id];
}
else {
$headerInfo = $this->getHeaderInfo($stream);
if ($headerInfo === false) return false;
$id = $headerInfo[1];
$response = $o->queue[$stream_id][$id];
$response->length = $headerInfo[0];
$o->responses[$stream_id] = $response;
}
return $response;
}
protected function afterRead($stream, $o, $response) {
$stream_id = (integer)$stream;
unset($o->queue[$stream_id][$response->id]);
if (empty($o->queue[$stream_id])) {
$this->removeStream($stream, $o->readpool);
}
}
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/HalfDuplexTransporter.php *
* *
* hprose socket HalfDuplexTransporter class for php 5.3+ *
* *
* LastModified: Jul 12, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
class HalfDuplexTransporter extends Transporter {
protected function appendHeader($request) {
return pack("N", strlen($request)) . $request;
}
protected function createRequest($index, $request) {
$buffer = $this->appendHeader($request);
return new DataBuffer($index, $buffer, strlen($buffer));
}
protected function afterWrite($request, $stream, $o) {
$stream_id = (integer)$stream;
$o->responses[$stream_id] = new DataBuffer($request->index, '', 0);
$o->readpool[] = $stream;
unset($o->requests[$stream_id]);
$this->removeStream($stream, $o->writepool);
}
protected function asyncReadError($o, $stream, $index) {
$o->results[$index]->reject($this->getLastError('response read error'));
$this->free($o, $index);
unset($o->responses[(integer)$stream]);
fclose($stream);
$this->removeStream($stream, $o->readpool);
}
protected function getBodyLength($stream) {
$header = $this->readHeader($stream, 4);
if ($header === false) return false;
list(, $length) = unpack('N', $header);
return $length;
}
protected function getResponse($stream, $o) {
$stream_id = (integer)$stream;
$response = $o->responses[$stream_id];
if ($response->length === 0) {
$length = $this->getBodyLength($stream);
if ($length === false) return false;
$response->length = $length;
}
return $response;
}
protected function afterRead($stream, $o, $response) {
if ($o->current < $o->count) {
$o->writepool[] = $stream;
}
$this->removeStream($stream, $o->readpool);
}
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Socket/Transporter.php *
* *
* hprose socket Transporter class for php 5.3+ *
* *
* LastModified: Jul 12, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose\Socket;
use stdClass;
use Exception;
use ErrorException;
use Hprose\Future;
use Hprose\TimeoutException;
abstract class Transporter {
private $client;
private $requests = array();
private $timeouts = array();
private $deadlines = array();
private $results = array();
private $stream = null;
private $async;
protected abstract function appendHeader($request);
protected abstract function createRequest($index, $request);
protected abstract function afterWrite($request, $stream, $o);
protected abstract function getBodyLength($stream);
protected abstract function asyncReadError($o, $stream, $index);
protected abstract function getResponse($stream, $o);
protected abstract function afterRead($stream, $o, $response);
public function __construct(Client $client, $async) {
$this->client = $client;
$this->async = $async;
}
public function __destruct() {
if ($this->stream !== null) fclose($this->stream);
}
protected function getLastError($error) {
$e = error_get_last();
if ($e === null) {
return new Exception($error);
}
else {
return new ErrorException($e['message'], 0, $e['type'], $e['file'], $e['line']);
}
}
protected function removeStream($stream, &$pool) {
$index = array_search($stream, $pool, true);
if ($index !== false) {
unset($pool[$index]);
}
}
protected function readHeader($stream, $n) {
$header = '';
do {
$buffer = @fread($stream, $n - strlen($header));
$header .= $buffer;
} while (($buffer !== false) && (strlen($header) < $n));
if ($buffer === false) {
return false;
}
return $header;
}
protected function asyncWrite($stream, $o) {
$stream_id = (integer)$stream;
if (isset($o->requests[$stream_id])) {
$request = $o->requests[$stream_id];
}
else {
if ($o->current < $o->count) {
$request = $this->createRequest($o->current, $o->buffers[$o->current]);
$o->requests[$stream_id] = $request;
unset($o->buffers[$o->current]);
$o->current++;
}
else {
$this->removeStream($stream, $o->writepool);
return;
}
}
$sent = @fwrite($stream, $request->buffer, $request->length);
if ($sent === false) {
$o->results[$request->index]->reject($this->getLastError('request write error'));
}
if ($sent < $request->length) {
$request->buffer = substr($request->buffer, $sent);
$request->length -= $sent;
}
else {
$this->afterWrite($request, $stream, $o);
}
}
private function free($o, $index) {
unset($o->results[$index]);
unset($o->timeouts[$index]);
unset($o->deadlines[$index]);
unset($o->buffers[$index]);
}
private function asyncRead($stream, $o) {
$response = $this->getResponse($stream, $o);
if ($response === false) {
$this->asyncReadError($o, $stream, $response->index);
return;
}
$remaining = $response->length - strlen($response->buffer);
$buffer = @fread($stream, $remaining);
if ($buffer === false) {
$this->asyncReadError($o, $stream, $response->index);
return;
}
$response->buffer .= $buffer;
if (strlen($response->buffer) === $response->length) {
$result = $o->results[$response->index];
$this->free($o, $response->index);
$stream_id = (integer)$stream;
unset($o->responses[$stream_id]);
$this->afterRead($stream, $o, $response);
$result->resolve($response->buffer);
}
}
private function checkTimeout($o) {
foreach ($o->deadlines as $index => $deadline) {
if (microtime(true) > $deadline) {
$o->results[$index]->reject(new TimeoutException("timeout"));
$this->free($o, $index);
}
}
}
private function createPool($client, $o) {
$n = min(count($o->results), $client->maxPoolSize);
$pool = array();
$errno = 0;
$errstr = '';
$context = stream_context_create($client->options);
for ($i = 0; $i < $n; $i++) {
$scheme = parse_url($client->uri, PHP_URL_SCHEME);
if ($scheme == 'unix') {
$stream = fsockopen('unix://' . parse_url($client->uri, PHP_URL_PATH));
}
else {
$stream = @stream_socket_client(
$client->uri . '/' . $i,
$errno,
$errstr,
0,
STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_PERSISTENT,
$context
);
}
if (($stream !== false) &&
(@stream_set_blocking($stream, false) !== false)) {
@stream_set_read_buffer($stream, $client->readBuffer);
@stream_set_write_buffer($stream, $client->writeBuffer);
$pool[] = $stream;
}
}
if (empty($pool)) {
$e = new Exception($errstr, $errno);
foreach ($o->results as $result) {
$result->reject($e);
}
return false;
}
return $pool;
}
public function loop() {
$client = $this->client;
while (count($this->results) > 0) {
$this->checkTimeout($this);
$pool = $this->createPool($client, $this);
if ($pool === false) continue;
$o = new stdClass();
$o->current = 0;
$o->count = count($this->results);
$o->responses = array();
$o->requests = array();
$o->readpool = array();
$o->writepool = $pool;
$o->buffers = $this->buffers;
$o->timeouts = $this->timeouts;
$o->deadlines = $this->deadlines;
$o->results = $this->results;
$this->buffers = array();
$this->timeouts = array();
$this->deadlines = array();
$this->results = array();
while (count($o->results) > 0) {
$this->checkTimeout($o);
$read = array_values($o->readpool);
$write = array_values($o->writepool);
$except = null;
$timeout = max(0, min($o->deadlines) - microtime(true));
$tv_sec = floor($timeout);
$tv_usec = ($timeout - $tv_sec) * 1000;
$n = stream_select($read, $write, $except, $tv_sec, $tv_usec);
if ($n > 0) {
foreach ($write as $stream) $this->asyncWrite($stream, $o);
foreach ($read as $stream) $this->asyncRead($stream, $o);
}
}
}
}
public function asyncSendAndReceive($buffer, stdClass $context) {
$timeout = ($context->timeout / 1000);
$deadline = microtime(true) + $timeout;
$result = new Future();
$this->buffers[] = $buffer;
$this->timeouts[] = $timeout;
$this->deadlines[] = $deadline;
$this->results[] = $result;
return $result;
}
private function write($stream, $request) {
$buffer = $this->appendHeader($request);
$length = strlen($buffer);
while (true) {
$sent = @fwrite($stream, $buffer, $length);
if ($sent === false) {
return false;
}
if ($sent < $length) {
$buffer = substr($buffer, $sent);
$length -= $sent;
}
else {
return true;
}
}
}
private function read($stream) {
$length = $this->getBodyLength($stream);
if ($length === false) return false;
$response = '';
while (($remaining = $length - strlen($response)) > 0) {
$buffer = @fread($stream, $remaining);
if ($buffer === false) {
return false;
}
$response .= $buffer;
}
return $response;
}
public function syncSendAndReceive($buffer, stdClass $context) {
$client = $this->client;
$timeout = ($context->timeout / 1000);
$sec = floor($timeout);
$usec = ($timeout - $sec) * 1000;
$trycount = 0;
$errno = 0;
$errstr = '';
while ($trycount <= 1) {
if ($this->stream === null) {
$this->stream = @stream_socket_client(
$this->client->uri,
$errno,
$errstr,
$timeout,
STREAM_CLIENT_CONNECT,
stream_context_create($client->options));
if ($this->stream === false) {
throw new Exception($errstr, $errno);
}
}
$stream = $this->stream;
@stream_set_read_buffer($stream, $client->readBuffer);
@stream_set_write_buffer($stream, $client->writeBuffer);
if (@stream_set_timeout($stream, $sec, $usec) == false) {
if ($trycount > 0) {
throw $this->getLastError("unknown error");
}
$trycount++;
}
else {
break;
}
}
if ($this->write($stream, $buffer) === false) {
throw $this->getLastError("request write error");
}
$response = $this->read($stream, $buffer);
if ($response === false) {
throw $this->getLastError("response read error");
}
return $response;
}
public function sendAndReceive($buffer, stdClass $context) {
if ($this->async) {
return $this->asyncSendAndReceive($buffer, $context);
}
return $this->syncSendAndReceive($buffer, $context);
}
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Tags.php *
* *
* hprose tags enum for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
class Tags {
/* Serialize Tags */
const TagInteger = 'i';
const TagLong = 'l';
const TagDouble = 'd';
const TagNull = 'n';
const TagEmpty = 'e';
const TagTrue = 't';
const TagFalse = 'f';
const TagNaN = 'N';
const TagInfinity = 'I';
const TagDate = 'D';
const TagTime = 'T';
const TagUTC = 'Z';
const TagBytes = 'b';
const TagUTF8Char = 'u';
const TagString = 's';
const TagGuid = 'g';
const TagList = 'a';
const TagMap = 'm';
const TagClass = 'c';
const TagObject = 'o';
const TagRef = 'r';
/* Serialize Marks */
const TagPos = '+';
const TagNeg = '-';
const TagSemicolon = ';';
const TagOpenbrace = '{';
const TagClosebrace = '}';
const TagQuote = '"';
const TagPoint = '.';
/* Protocol Tags */
const TagFunctions = 'F';
const TagCall = 'C';
const TagResult = 'R';
const TagArgument = 'A';
const TagError = 'E';
const TagEnd = 'z';
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/TimeoutException.php *
* *
* hprose TimeoutException for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use Exception;
class TimeoutException extends Exception {}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/Writer.php *
* *
* hprose writer class for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
use stdClass;
use DateTime;
use Exception;
use ReflectionClass;
use ReflectionProperty;
use SplObjectStorage;
use Traversable;
class Writer {
public $stream;
private $classref = array();
private $propsref = array();
private $refer;
public function __construct(BytesIO $stream, $simple = false) {
$this->stream = $stream;
$this->refer = $simple ?
new FakeWriterRefer() :
new RealWriterRefer();
}
private static function isUTF8($s) {
return mb_detect_encoding($s, 'UTF-8', true) !== false;
}
private static function ustrlen($s) {
return strlen(iconv('UTF-8', 'UTF-16LE', $s)) >> 1;
}
private static function isList(array $a) {
$count = count($a);
return ($count === 0) ||
((isset($a[0]) || array_key_exists(0, $a)) && (($count === 1) ||
(isset($a[$count - 1]) || array_key_exists($count - 1, $a))));
}
public function serialize($val) {
if ($val === null) {
$this->writeNull();
}
elseif (is_scalar($val)) {
if (is_int($val)) {
if ($val >= 0 && $val <= 9) {
$this->stream->write((string)$val);
}
elseif ($val >= -2147483648 && $val <= 2147483647) {
$this->writeInteger($val);
}
else {
$this->writeLong((string)$val);
}
}
elseif (is_bool($val)) {
$this->writeBoolean($val);
}
elseif (is_float($val)) {
$this->writeDouble($val);
}
elseif (is_string($val)) {
if ($val === '') {
$this->writeEmpty();
}
elseif (strlen($val) < 4 &&
self::isUTF8($val) &&
self::ustrlen($val) == 1) {
$this->writeUTF8Char($val);
}
elseif (self::isUTF8($val)) {
$this->writeStringWithRef($val);
}
else {
$this->writeBytesWithRef($val);
}
}
}
elseif (is_array($val)) {
if (self::isList($val)) {
$this->writeArray($val);
}
else {
$this->writeAssocArray($val);
}
}
elseif (is_object($val)) {
if ($val instanceof BytesIO) {
$this->writeBytesIOWithRef($val);
}
elseif ($val instanceof DateTime) {
$this->writeDateTimeWithRef($val);
}
elseif ($val instanceof SplObjectStorage) {
$this->writeMapWithRef($val);
}
elseif ($val instanceof Traversable) {
$this->writeListWithRef($val);
}
elseif ($val instanceof stdClass) {
$this->writeStdClassWithRef($val);
}
else {
$this->writeObjectWithRef($val);
}
}
else {
throw new Exception('Not support to serialize this data');
}
}
public function writeInteger($int) {
$this->stream->write(Tags::TagInteger . $int . Tags::TagSemicolon);
}
public function writeLong($long) {
$this->stream->write(Tags::TagLong . $long . Tags::TagSemicolon);
}
public function writeDouble($double) {
if (is_nan($double)) {
$this->writeNaN();
}
elseif (is_infinite($double)) {
$this->writeInfinity($double > 0);
}
else {
$this->stream->write(Tags::TagDouble . $double . Tags::TagSemicolon);
}
}
public function writeNaN() {
$this->stream->write(Tags::TagNaN);
}
public function writeInfinity($positive = true) {
$this->stream->write(Tags::TagInfinity . ($positive ? Tags::TagPos : Tags::TagNeg));
}
public function writeNull() {
$this->stream->write(Tags::TagNull);
}
public function writeEmpty() {
$this->stream->write(Tags::TagEmpty);
}
public function writeBoolean($bool) {
$this->stream->write($bool ? Tags::TagTrue : Tags::TagFalse);
}
public function writeUTF8Char($char) {
$this->stream->write(Tags::TagUTF8Char . $char);
}
public function writeString($str) {
$this->refer->set($str);
$len = self::ustrlen($str);
$this->stream->write(Tags::TagString);
if ($len > 0) {
$this->stream->write((string)$len);
}
$this->stream->write(Tags::TagQuote . $str . Tags::TagQuote);
}
public function writeStringWithRef($str) {
if (!$this->refer->write($this->stream, $str)) {
$this->writeString($str);
}
}
public function writeBytes($bytes) {
$this->refer->set($bytes);
$len = strlen($bytes);
$this->stream->write(Tags::TagBytes);
if ($len > 0) {
$this->stream->write((string)$len);
}
$this->stream->write(Tags::TagQuote . $bytes . Tags::TagQuote);
}
public function writeBytesWithRef($bytes) {
if (!$this->refer->write($this->stream, $bytes)) {
$this->writeBytes($bytes);
}
}
public function writeBytesIO(BytesIO $bytes) {
$this->refer->set($bytes);
$len = $bytes->length();
$this->stream->write(Tags::TagBytes);
if ($len > 0) {
$this->stream->write((string)$len);
}
$this->stream->write(Tags::TagQuote . $bytes->toString() . Tags::TagQuote);
}
public function writeBytesIOWithRef(BytesIO $bytes) {
if (!$this->refer->write($this->stream, $bytes)) {
$this->writeBytesIO($bytes);
}
}
public function writeDateTime(DateTime $datetime) {
$this->refer->set($datetime);
if ($datetime->getOffset() == 0) {
$this->stream->write($datetime->format('\DYmd\THis.u\Z'));
}
else {
$this->stream->write($datetime->format('\DYmd\THis.u;'));
}
}
public function writeDateTimeWithRef(DateTime $datetime) {
if (!$this->refer->write($this->stream, $datetime)) {
$this->writeDateTime($datetime);
}
}
public function writeArray(array $array) {
$this->refer->set($array);
$count = count($array);
$this->stream->write(Tags::TagList);
if ($count > 0) {
$this->stream->write((string)$count);
}
$this->stream->write(Tags::TagOpenbrace);
for ($i = 0; $i < $count; $i++) {
$this->serialize($array[$i]);
}
$this->stream->write(Tags::TagClosebrace);
}
public function writeAssocArray(array $map) {
$this->refer->set($map);
$count = count($map);
$this->stream->write(Tags::TagMap);
if ($count > 0) {
$this->stream->write((string)$count);
}
$this->stream->write(Tags::TagOpenbrace);
foreach ($map as $key => $value) {
$this->serialize($key);
$this->serialize($value);
}
$this->stream->write(Tags::TagClosebrace);
}
public function writeList(Traversable $list) {
$this->refer->set($list);
$count = count($list);
$this->stream->write(Tags::TagList);
if ($count > 0) {
$this->stream->write((string)$count);
}
$this->stream->write(Tags::TagOpenbrace);
foreach ($list as $e) {
$this->serialize($e);
}
$this->stream->write(Tags::TagClosebrace);
}
public function writeListWithRef(Traversable $list) {
if (!$this->refer->write($this->stream, $list)) {
$this->writeList($list);
}
}
public function writeMap(SplObjectStorage $map) {
$this->refer->set($map);
$count = count($map);
$this->stream->write(Tags::TagMap);
if ($count > 0) {
$this->stream->write((string)$count);
}
$this->stream->write(Tags::TagOpenbrace);
foreach ($map as $o) {
$this->serialize($o);
$this->serialize($map[$o]);
}
$this->stream->write(Tags::TagClosebrace);
}
public function writeMapWithRef(SplObjectStorage $map) {
if (!$this->refer->write($this->stream, $map)) {
$this->writeMap($map);
}
}
public function writeStdClass(stdClass $obj) {
$this->refer->set($obj);
$vars = get_object_vars($obj);
$count = count($vars);
$this->stream->write(Tags::TagMap);
if ($count > 0) {
$this->stream->write((string)$count);
}
$this->stream->write(Tags::TagOpenbrace);
foreach ($vars as $key => $value) {
$this->serialize($key);
$this->serialize($value);
}
$this->stream->write(Tags::TagClosebrace);
}
public function writeStdClassWithRef(stdClass $obj) {
if (!$this->refer->write($this->stream, $obj)) {
$this->writeStdClass($obj);
}
}
public function writeObject($obj) {
$class = get_class($obj);
$alias = ClassManager::getClassAlias($class);
if (isset($this->classref[$alias])) {
$index = $this->classref[$alias];
}
else {
$reflector = new ReflectionClass($obj);
$props = $reflector->getProperties(
ReflectionProperty::IS_PUBLIC |
ReflectionProperty::IS_PROTECTED |
ReflectionProperty::IS_PRIVATE);
$index = $this->writeClass($alias, $props);
}
$this->refer->set($obj);
$props = $this->propsref[$index];
$this->stream->write(Tags::TagObject . $index . Tags::TagOpenbrace);
foreach ($props as $prop) {
$this->serialize($prop->getValue($obj));
}
$this->stream->write(Tags::TagClosebrace);
}
public function writeObjectWithRef($obj) {
if (!$this->refer->write($this->stream, $obj)) {
$this->writeObject($obj);
}
}
protected function writeClass($alias, array $props) {
$len = self::ustrlen($alias);
$this->stream->write(Tags::TagClass . $len .
Tags::TagQuote . $alias . Tags::TagQuote);
$count = count($props);
if ($count > 0) {
$this->stream->write((string)$count);
}
$this->stream->write(Tags::TagOpenbrace);
foreach ($props as $prop) {
$prop->setAccessible(true);
$name = $prop->getName();
$fl = ord($name[0]);
if ($fl >= ord('A') && $fl <= ord('Z')) {
$name = strtolower($name[0]) . substr($name, 1);
}
$this->writeString($name);
}
$this->stream->write(Tags::TagClosebrace);
$index = count($this->propsref);
$this->classref[$alias] = $index;
$this->propsref[] = $props;
return $index;
}
public function reset() {
$this->classref = array();
$this->propsref = array();
$this->refer->reset();
}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/WriterRefer.php *
* *
* hprose writer reference interface for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
interface WriterRefer {
public function set($val);
public function write(BytesIO $stream, $val);
public function reset();
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Hprose/functions.php *
* *
* some helper functions for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
namespace Hprose;
function deferred() {
return new Deferred();
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* Throwable.php *
* *
* Throwable for php 7- *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
if (!interface_exists("Throwable")) {
interface Throwable {
public function getMessage();
public function getCode();
public function getFile();
public function getLine();
public function getTrace();
public function getTraceAsString();
public function getPrevious();
public function __toString();
}
}
\ No newline at end of file
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* TypeError.php *
* *
* TypeError for php 7- *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
if (!class_exists('TypeError')) {
class TypeError extends Exception {}
}
<?php
/**********************************************************\
| |
| hprose |
| |
| Official WebSite: http://www.hprose.com/ |
| http://www.hprose.org/ |
| |
\**********************************************************/
/**********************************************************\
* *
* functions.php *
* *
* hprose functions for php 5.3+ *
* *
* LastModified: Jul 11, 2016 *
* Author: Ma Bingyao <andot@hprose.com> *
* *
\**********************************************************/
if (!function_exists('hprose_serialize')) {
function hprose_serialize($var, $simple = false) {
return \Hprose\Formatter::serialize($var, $simple);
}
}
if (!function_exists('hprose_unserialize')) {
function hprose_unserialize($data, $simple = false) {
return \Hprose\Formatter::unserialize($data, $simple);
}
}
<?php
$loader = include __DIR__ . '/../vendor/autoload.php';
<?php
class Person {
public $name;
public $age;
}
class FormatterTest extends PHPUnit_Framework_TestCase {
public function testInteger() {
for ($i = 0; $i <= 9; $i++) {
$s = hprose_serialize($i);
$this->assertEquals($s, $i . "");
$this->assertEquals(hprose_unserialize($s), $i);
}
$s = hprose_serialize(10);
$this->assertEquals($s, "i10;");
$this->assertEquals(hprose_unserialize($s), 10);
$s = hprose_serialize(-1);
$this->assertEquals($s, "i-1;");
$this->assertEquals(hprose_unserialize($s), -1);
$s = hprose_serialize(2147483647);
$this->assertEquals($s, "i2147483647;");
$this->assertEquals(hprose_unserialize($s), 2147483647);
$s = hprose_serialize(-2147483648);
$this->assertEquals($s, "i-2147483648;");
$this->assertEquals(hprose_unserialize($s), -2147483648);
$s = hprose_serialize(2147483648);
$this->assertEquals($s, "l2147483648;");
$this->assertEquals(hprose_unserialize($s), 2147483648);
$s = hprose_serialize(4294967295);
$this->assertEquals($s, "l4294967295;");
$this->assertEquals(hprose_unserialize($s), 4294967295);
}
public function testDouble() {
$s = hprose_serialize(1.1);
$this->assertEquals($s, "d1.1;");
$this->assertEquals(hprose_unserialize($s), 1.1);
$s = hprose_serialize(-3.141926);
$this->assertEquals($s, "d-3.141926;");
$s = hprose_serialize(log(-1));
$this->assertEquals($s, "N");
$this->assertEquals(is_nan(hprose_unserialize($s)), true);
$s = hprose_serialize(log(0));
$this->assertEquals($s, "I-");
$this->assertEquals(is_infinite(hprose_unserialize($s)), true);
$this->assertEquals(hprose_unserialize($s) < 0, true);
$s = hprose_serialize(-log(0));
$this->assertEquals($s, "I+");
$this->assertEquals(is_infinite(hprose_unserialize($s)), true);
$this->assertEquals(hprose_unserialize($s) > 0, true);
}
public function testBoolean() {
$s = hprose_serialize(true);
$this->assertEquals($s, "t");
$this->assertEquals(hprose_unserialize($s), true);
$s = hprose_serialize(false);
$this->assertEquals($s, "f");
$this->assertEquals(hprose_unserialize($s), false);
}
public function testNull() {
$s = hprose_serialize(NULL);
$this->assertEquals($s, "n");
$this->assertEquals(hprose_unserialize($s), NULL);
}
public function testEmpty() {
$s = hprose_serialize("");
$this->assertEquals($s, "e");
$this->assertEquals(hprose_unserialize($s), "");
}
public function testString() {
$s = hprose_serialize("A");
$this->assertEquals($s, "uA");
$this->assertEquals(hprose_unserialize($s), "A");
$s = hprose_serialize("你");
$this->assertEquals($s, "u你");
$this->assertEquals(hprose_unserialize($s), "你");
$s = hprose_serialize("你好");
$this->assertEquals($s, 's2"你好"');
$this->assertEquals(hprose_unserialize($s), "你好");
$bs = "";
for ($i = 0; $i < 255; $i++) $bs .= chr($i);
$s = hprose_serialize($bs);
$this->assertEquals($s, 'b255"' . $bs . '"');
$this->assertEquals(hprose_unserialize($s), $bs);
}
public function testArray() {
$s = hprose_serialize(array(1,2,3,4,5));
$this->assertEquals($s, 'a5{12345}');
$this->assertEquals(hprose_unserialize($s), array(1,2,3,4,5));
$s = hprose_serialize(array("name" => "tom", "age" => 18));
$this->assertEquals($s, 'm2{s4"name"s3"tom"s3"age"i18;}');
$this->assertEquals(hprose_unserialize($s), array("name" => "tom", "age" => 18));
}
public function testObject() {
$o = new stdClass();
$o->name = "tom";
$o->age = 18;
$s = hprose_serialize($o);
$this->assertEquals($s, 'm2{s4"name"s3"tom"s3"age"i18;}');
$this->assertEquals(hprose_unserialize($s), array("name" => "tom", "age" => 18));
$s = 'c6"People"2{s4"name"s3"age"}o0{s3"tom"i18;}';
$this->assertEquals(hprose_unserialize($s), $o);
}
public function testObject2() {
$o = new Person();
$o->name = "tom";
$o->age = 18;
$s = hprose_serialize($o);
$this->assertEquals($s, 'c6"Person"2{s4"name"s3"age"}o0{s3"tom"i18;}');
$this->assertEquals(hprose_unserialize($s), $o);
$s = 'c6"People"2{s4"name"s3"age"}o0{s3"tom"i18;}';
$this->assertNotEquals(hprose_unserialize($s), $o);
}
public function testReference() {
$o = new Person();
$o->name = "tom";
$o->age = 18;
$a = array($o, $o);
$s = hprose_serialize($a);
$this->assertEquals($s, 'a2{c6"Person"2{s4"name"s3"age"}o0{s3"tom"i18;}r3;}');
$this->assertEquals(hprose_unserialize($s), $a);
}
}
<?php
class Calculator {
public function add($a, $b) {
return $a + $b;
}
public function sub($a, $b) {
return $a - $b;
}
public function mul($a, $b) {
return $a * $b;
}
public function div($a, $b) {
return $a / $b;
}
}
class PromiseTest extends PHPUnit_Framework_TestCase {
public function testValue() {
$self = $this;
$promise = \Hprose\Future\value("hello");
$promise->done(function($result) use ($self) {
$self->assertEquals($result, "hello");
});
}
public function testError() {
$self = $this;
$promise = \Hprose\Future\error(new Exception("test"));
$promise->fail(function($reason) use ($self) {
$self->assertEquals($reason->getMessage(), "test");
});
}
public function testDeferredResolve() {
$self = $this;
$deferred = \Hprose\deferred();
$deferred->promise->done(function($result) use ($self) {
$self->assertEquals($result, "hello");
});
$deferred->resolve("hello");
}
public function testDeferredReject() {
$self = $this;
$deferred = \Hprose\deferred();
$deferred->promise->fail(function($reason) use ($self) {
$self->assertEquals($reason->getMessage(), "test");
});
$deferred->reject(new Exception("test"));
}
public function testIsFuture() {
$deferred = \Hprose\deferred();
$this->assertEquals(\Hprose\Future\isFuture($deferred->promise), true);
$this->assertEquals(\Hprose\Future\isFuture(new \Hprose\Future()), true);
$this->assertEquals(\Hprose\Future\isFuture(\Hprose\Future\value("hello")), true);
$this->assertEquals(\Hprose\Future\isFuture(\Hprose\Future\error(new Exception("test"))), true);
$this->assertEquals(\Hprose\Future\isFuture(0), false);
}
public function testSync() {
$self = $this;
$promise = \Hprose\Future\sync(function() {
return "hello";
});
$promise->done(function($result) use ($self) {
$self->assertEquals($result, "hello");
});
}
public function testPromise() {
$self = $this;
$promise = \Hprose\Future\promise(function($resolve, $reject) {
$resolve(100);
});
$promise->done(function($result) use ($self) {
$self->assertEquals($result, 100);
});
$promise = \Hprose\Future\promise(function($resolve, $reject) {
$reject(new Exception("test"));
});
$promise->fail(function($reason) use ($self) {
$self->assertEquals($reason->getMessage(), "test");
});
}
public function testToFuture() {
$self = $this;
$promise = \Hprose\Future\value(100);
$this->assertEquals($promise, \Hprose\Future\toFuture($promise));
\Hprose\Future\toFuture(100)->done(function($result) use ($self) {
$self->assertEquals($result, 100);
});
}
public function testAll() {
$self = $this;
$p1 = \Hprose\Future\value(100);
$p2 = \Hprose\Future\value(200);
$p3 = \Hprose\Future\value(300);
$all = \Hprose\Future\all(array($p1, $p2, $p3));
$all->done(function($result) use ($self) {
$self->assertEquals($result, array(100, 200, 300));
});
}
public function testJoin() {
$self = $this;
$p1 = \Hprose\Future\value(100);
$p2 = \Hprose\Future\value(200);
$p3 = \Hprose\Future\value(300);
$all = \Hprose\Future\join($p1, $p2, $p3);
$all->done(function($result) use ($self) {
$self->assertEquals($result, array(100, 200, 300));
});
}
public function testSettle() {
$self = $this;
$p1 = \Hprose\Future\value(100);
$p2 = \Hprose\Future\error(new Exception('test'));
$p = \Hprose\Future\settle(array($p1, $p2));
$p->done(function($result) use ($self) {
$self->assertEquals($result, array(
array(
"state" => "fulfilled",
"value" => 100
),
array(
"state" => "rejected",
"reason" => new Exception('test')
)
));
});
}
public function testRun() {
$self = $this;
$sum = function($a, $b) {
return $a + $b;
};
$p = \Hprose\Future\run($sum, \Hprose\Future\value(100), \Hprose\Future\value(200));
$p->done(function($result) use ($self) {
$self->assertEquals($result, 300);
});
}
public function testWarp() {
$self = $this;
$sum = \Hprose\Future\wrap(function($a, $b) {
return $a + $b;
});
$p = $sum(\Hprose\Future\value(100), \Hprose\Future\value(200));
$p->done(function($result) use ($self) {
$self->assertEquals($result, 300);
});
}
public function testWarp2() {
$self = $this;
$calculator = \Hprose\Future\wrap(new Calculator());
$p1 = $calculator->add(\Hprose\Future\value(100), \Hprose\Future\value(200));
$p1->done(function($result) use ($self) {
$self->assertEquals($result, 300);
});
$p2 = $calculator->sub(\Hprose\Future\value(100), \Hprose\Future\value(200));
$p2->done(function($result) use ($self) {
$self->assertEquals($result, -100);
});
}
public function testEach() {
$self = $this;
$array = array();
$n = 0;
for ($i = 0; $i < 100; $i++) {
$array[$i] = \Hprose\Future\value($i);
$n += $i;
}
$sum = 0;
\Hprose\Future\each($array, function($value) use (&$sum) {
$sum += $value;
})->done(function() use ($self, &$sum, $n) {
$self->assertEquals($sum, $n);
});
$a2 = \Hprose\Future\value($array);
$a2->each(function($value, $index) use ($self) {
$self->assertEquals($value, $index);
})->fail(function($reason) { throw $reason; });
}
public function testEvery() {
$self = $this;
$isBigEnough = function($element, $index, $array) {
return $element >= 10;
};
$a1 = array(12, \Hprose\Future\value(5), 8, \Hprose\Future\value(130), 44);
$a2 = array(12, \Hprose\Future\value(54), 18, \Hprose\Future\value(130), 44);
\Hprose\Future\every($a1, $isBigEnough)->done(function($result) use ($self) {
$self->assertEquals($result, false);
});
\Hprose\Future\every($a2, $isBigEnough)->done(function($result) use ($self) {
$self->assertEquals($result, true);
});
$a3 = \Hprose\Future\value($a1);
$a4 = \Hprose\Future\value($a2);
$a3->every($isBigEnough)->done(function($result) use ($self) {
$self->assertEquals($result, false);
});
$a4->every($isBigEnough)->done(function($result) use ($self) {
$self->assertEquals($result, true);
});
}
public function testSome() {
$self = $this;
$isBiggerThan10 = function($element, $index, $array) {
return $element >= 10;
};
$a1 = array(2, \Hprose\Future\value(5), 8, \Hprose\Future\value(1), 4);
$a2 = array(12, \Hprose\Future\value(5), 8, \Hprose\Future\value(1), 4);
\Hprose\Future\some($a1, $isBiggerThan10)->done(function($result) use ($self) {
$self->assertEquals($result, false);
});
\Hprose\Future\some($a2, $isBiggerThan10)->done(function($result) use ($self) {
$self->assertEquals($result, true);
});
$a3 = \Hprose\Future\value($a1);
$a4 = \Hprose\Future\value($a2);
$a3->some($isBiggerThan10)->done(function($result) use ($self) {
$self->assertEquals($result, false);
});
$a4->some($isBiggerThan10)->done(function($result) use ($self) {
$self->assertEquals($result, true);
});
}
public function testFilter() {
$self = $this;
$isBigEnough = function($element, $index, $array) {
return $element >= 10;
};
$a1 = array(12, \Hprose\Future\value(5), 8, \Hprose\Future\value(130), 44);
$a2 = \Hprose\Future\value($a1);
\Hprose\Future\filter($a1, $isBigEnough)->done(function($result) use ($self) {
$self->assertEquals($result, array(12, 130, 44));
});
\Hprose\Future\filter($a1, $isBigEnough, true)->done(function($result) use ($self) {
$self->assertEquals($result, array(0=>12, 3=>130, 4=>44));
});
$a2->filter($isBigEnough)->done(function($result) use ($self) {
$self->assertEquals($result, array(12, 130, 44));
});
$a2->filter($isBigEnough, true)->done(function($result) use ($self) {
$self->assertEquals($result, array(0=>12, 3=>130, 4=>44));
});
}
public function testMap() {
$self = $this;
$double = function($n) {
return $n * 2;
};
$a1 = array(\Hprose\Future\value(1), 4, \Hprose\Future\value(9));
$a2 = \Hprose\Future\value($a1);
\Hprose\Future\map($a1, "sqrt")->done(function($result) use ($self) {
$self->assertEquals($result, array(1, 2, 3));
});
\Hprose\Future\map($a1, $double)->done(function($result) use ($self) {
$self->assertEquals($result, array(2, 8, 18));
});
$a2->map("sqrt")->done(function($result) use ($self) {
$self->assertEquals($result, array(1, 2, 3));
});
$a2->map($double)->done(function($result) use ($self) {
$self->assertEquals($result, array(2, 8, 18));
});
}
public function testReduce() {
$self = $this;
$sum = function($a, $b) {
return $a + $b;
};
$a1 = array(\Hprose\Future\value(0), 1, \Hprose\Future\value(2), 3, \Hprose\Future\value(4));
$a2 = \Hprose\Future\value($a1);
\Hprose\Future\reduce($a1, $sum)->done(function($result) use ($self) {
$self->assertEquals($result, 10);
});
\Hprose\Future\reduce($a1, $sum, 10)->done(function($result) use ($self) {
$self->assertEquals($result, 20);
});
$a2->reduce($sum)->done(function($result) use ($self) {
$self->assertEquals($result, 10);
});
$a2->reduce($sum, 10)->done(function($result) use ($self) {
$self->assertEquals($result, 20);
});
}
public function testSearch() {
$self = $this;
$a1 = array(\Hprose\Future\value(0), 12, \Hprose\Future\value(24), 36, \Hprose\Future\value(48));
$a2 = \Hprose\Future\value($a1);
\Hprose\Future\search($a1, 24)->done(function($result) use ($self) {
$self->assertEquals($result, 2);
});
\Hprose\Future\search($a1, \Hprose\Future\value(36))->done(function($result) use ($self) {
$self->assertEquals($result, 3);
});
$a2->search(24)->done(function($result) use ($self) {
$self->assertEquals($result, 2);
});
$a2->search(\Hprose\Future\value(36))->done(function($result) use ($self) {
$self->assertEquals($result, 3);
});
}
public function testIncludes() {
$self = $this;
$a1 = array(\Hprose\Future\value(0), 12, \Hprose\Future\value(24), 36, \Hprose\Future\value(48));
$a2 = \Hprose\Future\value($a1);
\Hprose\Future\includes($a1, 21)->done(function($result) use ($self) {
$self->assertEquals($result, false);
});
\Hprose\Future\includes($a1, \Hprose\Future\value(36))->done(function($result) use ($self) {
$self->assertEquals($result, true);
});
$a2->includes(24)->done(function($result) use ($self) {
$self->assertEquals($result, true);
});
$a2->includes(\Hprose\Future\value(35))->done(function($result) use ($self) {
$self->assertEquals($result, false);
});
}
public function testDiff() {
$self = $this;
$assertEquals = \Hprose\Future\wrap(array($this, "assertEquals"));
$a1 = array(\Hprose\Future\value(0), 12, \Hprose\Future\value(24), 36, \Hprose\Future\value(48));
$a2 = array(\Hprose\Future\value(12), 2, \Hprose\Future\value(36), 48, \Hprose\Future\value(50));
\Hprose\Future\diff($a1, $a2)->done(function($result) use ($self) {
$self->assertEquals($result, array(0=>0, 2=>24));
});
\Hprose\Future\run('array_diff', \Hprose\Future\all($a1), \Hprose\Future\all($a2))->done(function($result) use ($self) {
$self->assertEquals($result, array(0=>0, 2=>24));
});
}
public function testFutureResolve() {
$self = $this;
$p = new \Hprose\Future();
$p->done(function($result) use ($self) {
$self->assertEquals($result, 100);
});
$p->resolve(100);
}
public function testFutureReject() {
$self = $this;
$p = new \Hprose\Future();
$p->fail(function($reason) use ($self) {
$self->assertEquals($reason->getMessage(), "test");
});
$p->reject(new Exception("test"));
}
public function testFutureInspect() {
$self = $this;
$p1 = \Hprose\Future\value(100);
$p2 = \Hprose\Future\reject(new Exception("test"));
$p3 = new \Hprose\Future();
$this->assertEquals($p1->inspect(), array('state' => 'fulfilled', 'value' => 100));
$this->assertEquals($p2->inspect(), array('state' => 'rejected', 'reason' => new Exception("test")));
$this->assertEquals($p3->inspect(), array('state' => 'pending'));
}
public function testFutureAlways() {
$self = $this;
$p1 = \Hprose\Future\value(100);
$p2 = \Hprose\Future\reject(new Exception("test"));
$p1->always(function($result) use ($self) {
$self->assertEquals($result, 100);
});
$p2->always(function($result) use ($self) {
$self->assertEquals($result, new Exception("test"));
});
}
public function testFutureTap() {
$self = $this;
$p = \Hprose\Future\value(100);
$p->tap('print_r')->done(function($result) use ($self) {
$self->assertEquals($result, 100);
});
}
public function testFutureSpread() {
$self = $this;
$sum = function($a, $b) { return $a + $b; };
$p = \Hprose\Future\value(array(100, 200));
$p->spread($sum)->done(function($result) use ($self) {
$self->assertEquals($result, 300);
});
}
public function testFutureGet() {
$self = $this;
$o = new \stdClass();
$o->name = "Tom";
$p = \Hprose\Future\value($o);
$p->name->done(function($result) use ($self) {
$self->assertEquals($result, "Tom");
});
}
}
<phpunit bootstrap="./Bootstrap.php" colors="true">
<testsuites>
<testsuite name="Hprose Test Suite">
<directory>.</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>..</directory>
<exclude>
<directory>../vendor/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
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 sign in to comment