Your Name 8 months ago
parent f55d317bcc
commit 0bcfa563c0
  1. 12
      composer.json
  2. 2592
      composer.lock
  3. BIN
      public/static/frontend/message.png
  4. BIN
      public/static/frontend/record-bg.png
  5. 0
      vendor/adbario/php-dot-notation/LICENSE.md
  6. 6
      vendor/adbario/php-dot-notation/composer.json
  7. 34
      vendor/adbario/php-dot-notation/src/Dot.php
  8. 9
      vendor/adbario/php-dot-notation/src/helpers.php
  9. 40
      vendor/alibabacloud/client/CHANGELOG.md
  10. 0
      vendor/alibabacloud/client/CONTRIBUTING.md
  11. 2
      vendor/alibabacloud/client/LICENSE.md
  12. 2
      vendor/alibabacloud/client/NOTICE.md
  13. 27
      vendor/alibabacloud/client/README-zh-CN.md
  14. 23
      vendor/alibabacloud/client/README.md
  15. 0
      vendor/alibabacloud/client/UPGRADING.md
  16. 17
      vendor/alibabacloud/client/autoload.php
  17. 242
      vendor/alibabacloud/client/composer.json
  18. 0
      vendor/alibabacloud/client/src/Accept.php
  19. 2
      vendor/alibabacloud/client/src/AlibabaCloud.php
  20. 0
      vendor/alibabacloud/client/src/Clients/AccessKeyClient.php
  21. 0
      vendor/alibabacloud/client/src/Clients/BearerTokenClient.php
  22. 0
      vendor/alibabacloud/client/src/Clients/Client.php
  23. 0
      vendor/alibabacloud/client/src/Clients/EcsRamRoleClient.php
  24. 0
      vendor/alibabacloud/client/src/Clients/ManageTrait.php
  25. 0
      vendor/alibabacloud/client/src/Clients/RamRoleArnClient.php
  26. 0
      vendor/alibabacloud/client/src/Clients/RsaKeyPairClient.php
  27. 0
      vendor/alibabacloud/client/src/Clients/StsClient.php
  28. 0
      vendor/alibabacloud/client/src/Config/Config.php
  29. 1560
      vendor/alibabacloud/client/src/Config/Data.php
  30. 0
      vendor/alibabacloud/client/src/Credentials/AccessKeyCredential.php
  31. 0
      vendor/alibabacloud/client/src/Credentials/BearerTokenCredential.php
  32. 0
      vendor/alibabacloud/client/src/Credentials/CredentialsInterface.php
  33. 0
      vendor/alibabacloud/client/src/Credentials/EcsRamRoleCredential.php
  34. 0
      vendor/alibabacloud/client/src/Credentials/Ini/CreateTrait.php
  35. 0
      vendor/alibabacloud/client/src/Credentials/Ini/IniCredential.php
  36. 0
      vendor/alibabacloud/client/src/Credentials/Ini/OptionsTrait.php
  37. 0
      vendor/alibabacloud/client/src/Credentials/Providers/CredentialsProvider.php
  38. 4
      vendor/alibabacloud/client/src/Credentials/Providers/EcsRamRoleProvider.php
  39. 0
      vendor/alibabacloud/client/src/Credentials/Providers/Provider.php
  40. 0
      vendor/alibabacloud/client/src/Credentials/Providers/RamRoleArnProvider.php
  41. 0
      vendor/alibabacloud/client/src/Credentials/Providers/RsaKeyPairProvider.php
  42. 0
      vendor/alibabacloud/client/src/Credentials/RamRoleArnCredential.php
  43. 0
      vendor/alibabacloud/client/src/Credentials/Requests/AssumeRole.php
  44. 0
      vendor/alibabacloud/client/src/Credentials/Requests/GenerateSessionAccessKey.php
  45. 0
      vendor/alibabacloud/client/src/Credentials/RsaKeyPairCredential.php
  46. 0
      vendor/alibabacloud/client/src/Credentials/StsCredential.php
  47. 0
      vendor/alibabacloud/client/src/DefaultAcsClient.php
  48. 6
      vendor/alibabacloud/client/src/Encode.php
  49. 0
      vendor/alibabacloud/client/src/Exception/AlibabaCloudException.php
  50. 0
      vendor/alibabacloud/client/src/Exception/ClientException.php
  51. 4
      vendor/alibabacloud/client/src/Exception/ServerException.php
  52. 14
      vendor/alibabacloud/client/src/Filter/ApiFilter.php
  53. 7
      vendor/alibabacloud/client/src/Filter/ClientFilter.php
  54. 0
      vendor/alibabacloud/client/src/Filter/CredentialFilter.php
  55. 0
      vendor/alibabacloud/client/src/Filter/Filter.php
  56. 0
      vendor/alibabacloud/client/src/Filter/HttpFilter.php
  57. 4
      vendor/alibabacloud/client/src/Functions.php
  58. 7
      vendor/alibabacloud/client/src/Log/LogFormatter.php
  59. 0
      vendor/alibabacloud/client/src/Profile/DefaultProfile.php
  60. 0
      vendor/alibabacloud/client/src/Regions/EndpointProvider.php
  61. 0
      vendor/alibabacloud/client/src/Regions/LocationService.php
  62. 0
      vendor/alibabacloud/client/src/Regions/LocationServiceRequest.php
  63. 0
      vendor/alibabacloud/client/src/Release.php
  64. 62
      vendor/alibabacloud/client/src/Request/Request.php
  65. 8
      vendor/alibabacloud/client/src/Request/RoaRequest.php
  66. 2
      vendor/alibabacloud/client/src/Request/RpcRequest.php
  67. 32
      vendor/alibabacloud/client/src/Request/Traits/AcsTrait.php
  68. 0
      vendor/alibabacloud/client/src/Request/Traits/ClientTrait.php
  69. 0
      vendor/alibabacloud/client/src/Request/Traits/DeprecatedRoaTrait.php
  70. 0
      vendor/alibabacloud/client/src/Request/Traits/DeprecatedTrait.php
  71. 6
      vendor/alibabacloud/client/src/Request/Traits/RetryTrait.php
  72. 0
      vendor/alibabacloud/client/src/Request/UserAgent.php
  73. 0
      vendor/alibabacloud/client/src/Resolver/ActionResolverTrait.php
  74. 0
      vendor/alibabacloud/client/src/Resolver/ApiResolver.php
  75. 3
      vendor/alibabacloud/client/src/Resolver/CallTrait.php
  76. 0
      vendor/alibabacloud/client/src/Resolver/Roa.php
  77. 0
      vendor/alibabacloud/client/src/Resolver/Rpc.php
  78. 3
      vendor/alibabacloud/client/src/Resolver/VersionResolver.php
  79. 0
      vendor/alibabacloud/client/src/Result/Result.php
  80. 0
      vendor/alibabacloud/client/src/SDK.php
  81. 0
      vendor/alibabacloud/client/src/Signature/BearerTokenSignature.php
  82. 0
      vendor/alibabacloud/client/src/Signature/ShaHmac1Signature.php
  83. 0
      vendor/alibabacloud/client/src/Signature/ShaHmac256Signature.php
  84. 0
      vendor/alibabacloud/client/src/Signature/ShaHmac256WithRsaSignature.php
  85. 0
      vendor/alibabacloud/client/src/Signature/Signature.php
  86. 0
      vendor/alibabacloud/client/src/Signature/SignatureInterface.php
  87. 0
      vendor/alibabacloud/client/src/Support/Arrays.php
  88. 0
      vendor/alibabacloud/client/src/Support/Path.php
  89. 5
      vendor/alibabacloud/client/src/Support/Sign.php
  90. 47
      vendor/alibabacloud/client/src/Support/Stringy.php
  91. 4
      vendor/alibabacloud/client/src/Traits/ArrayAccessTrait.php
  92. 4
      vendor/alibabacloud/client/src/Traits/ClientTrait.php
  93. 0
      vendor/alibabacloud/client/src/Traits/DefaultRegionTrait.php
  94. 29
      vendor/alibabacloud/client/src/Traits/EndpointTrait.php
  95. 7
      vendor/alibabacloud/client/src/Traits/HasDataTrait.php
  96. 0
      vendor/alibabacloud/client/src/Traits/HistoryTrait.php
  97. 0
      vendor/alibabacloud/client/src/Traits/HttpTrait.php
  98. 37
      vendor/alibabacloud/client/src/Traits/LogTrait.php
  99. 0
      vendor/alibabacloud/client/src/Traits/MockTrait.php
  100. 0
      vendor/alibabacloud/client/src/Traits/ObjectAccessTrait.php
  101. Some files were not shown because too many files have changed in this diff Show More

@ -21,9 +21,9 @@
"topthink/think-image": "^1.0",
"topthink/think-captcha": "1.*",
"overtrue/wechat": "^3.3",
"tp5er/tp5-databackup": "dev-master",
"tp5er/tp5-databackup": "1.1.1",
"xaboy/form-builder": "^1.2",
"topthink/think-helper": "^1.0",
"topthink/think-helper": "^3.1.1",
"phpoffice/phpspreadsheet": "^1.6",
"jenssegers/date": "^3.4",
"mtdowling/cron-expression": "^1.2",
@ -34,7 +34,8 @@
"phpoffice/phpexcel": "^1.8",
"intervention/image": "^2.5",
"topthink/think-queue": "1.1.*",
"ext-json": "*"
"ext-json": "*",
"txthinking/mailer": "^2.0"
},
"autoload": {
"psr-4": {
@ -45,6 +46,9 @@
"think-path": "thinkphp"
},
"config": {
"preferred-install": "dist"
"preferred-install": "dist",
"allow-plugins": {
"topthink/think-installer": true
}
}
}

2592
composer.lock generated

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

@ -11,12 +11,12 @@
}
],
"require": {
"php": ">=5.5",
"php": "^5.5 || ^7.0 || ^8.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0|^6.0",
"squizlabs/php_codesniffer": "^3.0"
"phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5",
"squizlabs/php_codesniffer": "^3.6"
},
"autoload": {
"files": [

@ -29,14 +29,25 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
*/
protected $items = [];
/**
* The delimiter (alternative to a '.') to be used.
*
* @var string
*/
protected $delimiter = '.';
/**
* Create a new Dot instance
*
* @param mixed $items
* @param string $delimiter
*/
public function __construct($items = [])
public function __construct($items = [], $delimiter = '.')
{
$this->items = $this->getArrayItems($items);
$this->delimiter = strlen($delimiter) ? $delimiter : '.';
}
/**
@ -104,7 +115,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
}
$items = &$this->items;
$segments = explode('.', $key);
$segments = explode($this->delimiter, $key);
$lastSegment = array_pop($segments);
foreach ($segments as $segment) {
@ -148,6 +159,10 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
$items = $this->items;
}
if (!func_num_args()) {
$delimiter = $this->delimiter;
}
foreach ($items as $key => $value) {
if (is_array($value) && !empty($value)) {
$flatten = array_merge(
@ -179,13 +194,13 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
return $this->items[$key];
}
if (strpos($key, '.') === false) {
if (strpos($key, $this->delimiter) === false) {
return $default;
}
$items = $this->items;
foreach (explode('.', $key) as $segment) {
foreach (explode($this->delimiter, $key) as $segment) {
if (!is_array($items) || !$this->exists($items, $segment)) {
return $default;
}
@ -234,7 +249,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
continue;
}
foreach (explode('.', $key) as $segment) {
foreach (explode($this->delimiter, $key) as $segment) {
if (!is_array($items) || !$this->exists($items, $segment)) {
return false;
}
@ -446,7 +461,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
$items = &$this->items;
foreach (explode('.', $keys) as $key) {
foreach (explode($this->delimiter, $keys) as $key) {
if (!isset($items[$key]) || !is_array($items[$key])) {
$items[$key] = [];
}
@ -507,6 +522,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
* @param int|string $key
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($key)
{
return $this->has($key);
@ -518,6 +534,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
* @param int|string $key
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->get($key);
@ -529,6 +546,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
* @param int|string|null $key
* @param mixed $value
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
if (is_null($key)) {
@ -545,6 +563,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
*
* @param int|string $key
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
$this->delete($key);
@ -562,6 +581,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
* @param int|string|null $key
* @return int
*/
#[\ReturnTypeWillChange]
public function count($key = null)
{
return count($this->get($key));
@ -578,6 +598,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
*
* @return \ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->items);
@ -594,6 +615,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->items;

@ -11,13 +11,14 @@ use Adbar\Dot;
if (! function_exists('dot')) {
/**
* Create a new Dot object with the given items
* Create a new Dot object with the given items and optional delimiter
*
* @param mixed $items
* @param mixed $items
* @param string $delimiter
* @return \Adbar\Dot
*/
function dot($items)
function dot($items, $delimiter = '.')
{
return new Dot($items);
return new Dot($items, $delimiter);
}
}

@ -1,5 +1,45 @@
# CHANGELOG
## 1.5.32 - 2022-12-08
- Support PHP versions: From 5.5 up to 8.1
## 1.5.31 - 2021-05-13
- Deprecate `\GuzzleHttp\Psr7\parse_query` method
## 1.5.30 - 2021-03-22
- Fixed incompatibility in PHP 5.6 version.
## 1.5.29 - 2020-08-03
- Fixed RPC Signature.
## 1.5.28 - 2020-08-03
- Updated `endpoints`.
## 1.5.27 - 2020-07-17
- Fixed composer error config.
## 1.5.26 - 2020-07-17
- Validate RegionID/EndpointSuffix/Network.
## 1.5.25 - 2020-07-04
- Fixed ROA signature.
- Deprecated `LogFormatter`.
## 1.5.24 - 2020-06-04
- Fixed Resolve Host.
## 1.5.23 - 2020-05-22
- Optimized global product support.
## 1.5.22 - 2020-05-12
- Updated Endpoints.
## 1.5.21 - 2020-02-26
- Improved Nonce.
- Updated Endpoints.
## 1.5.20 - 2019-12-30
- Improved Docs.
- Updated Endpoints.

@ -1,4 +1,4 @@
Copyright 1999-2019 Alibaba Group Holding Ltd.
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

@ -2,7 +2,7 @@
<https://www.alibabacloud.com/>
Copyright 1999-2019 Alibaba Group. or its affiliates. All Rights Reserved.
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License.

@ -6,9 +6,8 @@
[![composer.lock](https://poser.pugx.org/alibabacloud/client/composerlock)](https://packagist.org/packages/alibabacloud/client)
[![Total Downloads](https://poser.pugx.org/alibabacloud/client/downloads)](https://packagist.org/packages/alibabacloud/client)
[![License](https://poser.pugx.org/alibabacloud/client/license)](https://packagist.org/packages/alibabacloud/client)
[![codecov](https://codecov.io/gh/aliyun/openapi-sdk-php-client/branch/master/graph/badge.svg)](https://codecov.io/gh/aliyun/openapi-sdk-php-client)
[![Travis Build Status](https://travis-ci.org/aliyun/openapi-sdk-php-client.svg?branch=master)](https://travis-ci.org/aliyun/openapi-sdk-php-client)
[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/qb8j3lhg8349k0hk/branch/master?svg=true)](https://ci.appveyor.com/project/aliyun/openapi-sdk-php-client/branch/master)
[![codecov](https://codecov.io/gh/aliyun/openapi-sdk-php-client/branch/master/graph/badge.svg?token=90Yd5Bne3S)](https://codecov.io/gh/aliyun/openapi-sdk-php-client)
[![PHP Version Require](http://poser.pugx.org/alibabacloud/client/require/php)](https://packagist.org/packages/alibabacloud/client)
![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg)
@ -17,8 +16,11 @@
Alibaba Cloud Client for PHP 是帮助 PHP 开发者管理凭据、发送请求的客户端工具,[Alibaba Cloud SDK for PHP][SDK] 由本工具提供底层支持。
## 使用诊断
[Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) 提供 OpenAPI 使用诊断服务,通过 `RequestID``报错信息` ,帮助开发者快速定位,为开发者提供解决方案。
## 在线示例
[API Explorer](https://api.aliyun.com) 提供在线调用阿里云产品,并动态生成 SDK 代码和快速检索接口等能力,能显著降低使用云 API 的难度。
[阿里云 OpenAPI 开发者门户]https://next.api.aliyun.com/) 提供在线调用阿里云产品,并动态生成 SDK 代码和快速检索接口等能力,能显著降低使用云 API 的难度。
## 先决条件
@ -46,7 +48,12 @@ use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->asDefaultClient();
```
## ROA 请求
## 请求
> 请求风格分为 `ROA``RPC`,不同产品风格不同,使用前,请参考产品文档。推荐使用 [Alibaba Cloud SDK for PHP][SDK] ,细节已被封装,无需关心风格。
### ROA 请求
```php
<?php
@ -77,7 +84,7 @@ try {
}
```
## RPC 请求
### RPC 请求
```php
<?php
@ -106,7 +113,7 @@ try {
## 文档
* [先决条件](/docs/zh-CN/0-Prerequisites.md)
* [安装](/docs/zh-CN/1-Installation.md)
* [客户端](/docs/zh-CN/2-Client.md)
* [客户端和凭证](/docs/zh-CN/2-Client.md)
* [请求](/docs/zh-CN/3-Request.md)
* [结果](/docs/zh-CN/4-Result.md)
* [区域](/docs/zh-CN/5-Region.md)
@ -131,7 +138,7 @@ try {
## 相关
* [阿里云服务 Regions & Endpoints][endpoints]
* [OpenAPI Explorer][open-api]
* [阿里云 OpenAPI 开发者门户][open-api]
* [Packagist][packagist]
* [Composer][composer]
* [Guzzle中文文档][guzzle-docs]
@ -141,11 +148,11 @@ try {
## 许可证
[Apache-2.0](/LICENSE.md)
版权所有 1999-2019 阿里巴巴集团
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
[SDK]: https://github.com/aliyun/openapi-sdk-php
[open-api]: https://api.aliyun.com
[open-api]: https://next.api.aliyun.com/
[latest-release]: https://github.com/aliyun/openapi-sdk-php-client
[guzzle-docs]: https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html
[composer]: https://getcomposer.org

@ -6,9 +6,8 @@ English | [简体中文](/README-zh-CN.md)
[![composer.lock](https://poser.pugx.org/alibabacloud/client/composerlock)](https://packagist.org/packages/alibabacloud/client)
[![Total Downloads](https://poser.pugx.org/alibabacloud/client/downloads)](https://packagist.org/packages/alibabacloud/client)
[![License](https://poser.pugx.org/alibabacloud/client/license)](https://packagist.org/packages/alibabacloud/client)
[![codecov](https://codecov.io/gh/aliyun/openapi-sdk-php-client/branch/master/graph/badge.svg)](https://codecov.io/gh/aliyun/openapi-sdk-php-client)
[![Travis Build Status](https://travis-ci.org/aliyun/openapi-sdk-php-client.svg?branch=master)](https://travis-ci.org/aliyun/openapi-sdk-php-client)
[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/qb8j3lhg8349k0hk/branch/master?svg=true)](https://ci.appveyor.com/project/aliyun/openapi-sdk-php-client/branch/master)
[![codecov](https://codecov.io/gh/aliyun/openapi-sdk-php-client/branch/master/graph/badge.svg?token=90Yd5Bne3S)](https://codecov.io/gh/aliyun/openapi-sdk-php-client)
[![PHP Version Require](http://poser.pugx.org/alibabacloud/client/require/php)](https://packagist.org/packages/alibabacloud/client)
![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg)
@ -16,10 +15,11 @@ English | [简体中文](/README-zh-CN.md)
Alibaba Cloud Client for PHP is a client tool that helps PHP developers manage credentials and send requests, [Alibaba Cloud SDK for PHP][SDK] dependency on this tool.
## Troubleshoot
[Troubleshoot](https://troubleshoot.api.aliyun.com/?source=github_sdk) Provide OpenAPI diagnosis service to help developers locate quickly and provide solutions for developers through `RequestID` or `error message`.
## Online Demo
[API Explorer](https://api.aliyun.com) provides the ability to call the cloud product OpenAPI online, and dynamically generate SDK Example code and quick retrieval interface, which can significantly reduce the difficulty of using the cloud API.
[Alibaba Cloud OpenAPI Developer Portal](https://next.api.aliyun.com/) provides the ability to call the cloud product OpenAPI online, and dynamically generate SDK Example code and quick retrieval interface, which can significantly reduce the difficulty of using the cloud API.
## Prerequisites
Your system will need to meet the [Prerequisites](/docs/en-US/0-Prerequisites.md), including having PHP >= 5.5. We highly recommend having it compiled with the cURL extension and cURL 7.16.2+.
@ -47,6 +47,11 @@ use AlibabaCloud\Client\AlibabaCloud;
AlibabaCloud::accessKeyClient('accessKeyId', 'accessKeySecret')->asDefaultClient();
```
## Request
> Request styles are divided into `ROA` and `RPC`. Different product styles are different. Please refer to the product documentation before using. It is recommended to use [Alibaba cloud SDK for PHP][SDK], the details have been encapsulated, and you do not need to care about the style.
### ROA Request
```php
<?php
@ -107,7 +112,7 @@ try {
## Documentation
* [Prerequisites](/docs/en-US/0-Prerequisites.md)
* [Installation](/docs/en-US/1-Installation.md)
* [Client](/docs/en-US/2-Client.md)
* [Client & Credentials](/docs/en-US/2-Client.md)
* [Request](/docs/en-US/3-Request.md)
* [Result](/docs/en-US/4-Result.md)
* [Region](/docs/en-US/5-Region.md)
@ -132,7 +137,7 @@ Please make sure to read the [Contributing Guide](/CONTRIBUTING.md) before makin
## References
* [Alibaba Cloud Regions & Endpoints][endpoints]
* [OpenAPI Explorer][open-api]
* [Alibaba Cloud OpenAPI Developer Portal][open-api]
* [Packagist][packagist]
* [Composer][composer]
* [Guzzle Documentation][guzzle-docs]
@ -142,11 +147,11 @@ Please make sure to read the [Contributing Guide](/CONTRIBUTING.md) before makin
## License
[Apache-2.0](/LICENSE.md)
Copyright 1999-2019 Alibaba Group Holding Ltd.
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.
[SDK]: https://github.com/aliyun/openapi-sdk-php
[open-api]: https://api.alibabacloud.com
[open-api]: https://next.api.aliyun.com/
[latest-release]: https://github.com/aliyun/openapi-sdk-php-client
[guzzle-docs]: http://docs.guzzlephp.org/en/stable/request-options.html
[composer]: https://getcomposer.org

@ -0,0 +1,17 @@
<?php
if (\file_exists(__DIR__ . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php')) {
require_once __DIR__ . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
}
spl_autoload_register(function ($class) {
$name = \str_replace('AlibabaCloud\\Client\\', '', $class);
$file = __DIR__ . \DIRECTORY_SEPARATOR . 'src' . \DIRECTORY_SEPARATOR . \str_replace('\\', \DIRECTORY_SEPARATOR, $name) . '.php';
if (\file_exists($file)) {
require_once $file;
return true;
}
return false;
});

@ -1,116 +1,134 @@
{
"name": "alibabacloud/client",
"homepage": "https://www.alibabacloud.com/",
"description": "Alibaba Cloud Client for PHP - Use Alibaba Cloud in your PHP project",
"keywords": [
"sdk",
"tool",
"cloud",
"client",
"aliyun",
"library",
"alibaba",
"alibabacloud"
],
"type": "library",
"license": "Apache-2.0",
"support": {
"source": "https://github.com/aliyun/openapi-sdk-php-client",
"issues": "https://github.com/aliyun/openapi-sdk-php-client/issues"
},
"authors": [
{
"name": "Alibaba Cloud SDK",
"email": "sdk-team@alibabacloud.com",
"homepage": "http://www.alibabacloud.com"
}
],
"require": {
"php": ">=5.5",
"ext-curl": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-openssl": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*",
"guzzlehttp/guzzle": "^6.3",
"danielstjules/stringy": "^3.1",
"mtdowling/jmespath.php": "^2.4",
"adbario/php-dot-notation": "^2.2",
"clagiordano/weblibs-configmanager": "^1.0"
},
"require-dev": {
"ext-spl": "*",
"ext-dom": "*",
"ext-pcre": "*",
"psr/cache": "^1.0",
"ext-sockets": "*",
"drupal/coder": "^8.3",
"symfony/dotenv": "^3.4",
"league/climate": "^3.2.4",
"phpunit/phpunit": "^4.8.35|^5.4.3",
"monolog/monolog": "^1.24",
"composer/composer": "^1.8",
"mikey179/vfsstream": "^1.6",
"symfony/var-dumper": "^3.4"
},
"suggest": {
"ext-sockets": "To use client-side monitoring"
},
"autoload": {
"psr-4": {
"AlibabaCloud\\Client\\": "src"
},
"files": [
"src/Functions.php"
]
},
"autoload-dev": {
"psr-4": {
"AlibabaCloud\\Client\\Tests\\": "tests/"
}
},
"config": {
"preferred-install": "dist",
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts-descriptions": {
"cs": "Tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.",
"cbf": "Automatically correct coding standard violations.",
"fixer": "Fixes code to follow standards.",
"test": "Run all tests.",
"unit": "Run Unit tests.",
"feature": "Run Feature tests.",
"clearCache": "Clear cache like coverage.",
"coverage": "Show Coverage html.",
"endpoints": "Update endpoints from OSS."
"name": "alibabacloud/client",
"homepage": "https://www.alibabacloud.com/",
"description": "Alibaba Cloud Client for PHP - Use Alibaba Cloud in your PHP project",
"keywords": [
"sdk",
"tool",
"cloud",
"client",
"aliyun",
"library",
"alibaba",
"alibabacloud"
],
"type": "library",
"license": "Apache-2.0",
"support": {
"source": "https://github.com/aliyun/openapi-sdk-php-client",
"issues": "https://github.com/aliyun/openapi-sdk-php-client/issues"
},
"authors": [
{
"name": "Alibaba Cloud SDK",
"email": "sdk-team@alibabacloud.com",
"homepage": "http://www.alibabacloud.com"
}
],
"require": {
"php": ">=5.5",
"ext-curl": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-openssl": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*",
"guzzlehttp/guzzle": "^6.3|^7.0",
"mtdowling/jmespath.php": "^2.5",
"adbario/php-dot-notation": "^2.4.1",
"clagiordano/weblibs-configmanager": "^1.0"
},
"require-dev": {
"ext-spl": "*",
"ext-dom": "*",
"ext-pcre": "*",
"psr/cache": "^1.0",
"ext-sockets": "*",
"drupal/coder": "^8.3",
"symfony/dotenv": "^3.4",
"league/climate": "^3.2.4",
"phpunit/phpunit": "^5.7|^6.6|^7.5|^8.5|^9.5",
"monolog/monolog": "^1.24",
"composer/composer": "^1.8",
"mikey179/vfsstream": "^1.6",
"symfony/var-dumper": "^3.4"
},
"suggest": {
"ext-sockets": "To use client-side monitoring"
},
"autoload": {
"psr-4": {
"AlibabaCloud\\Client\\": "src"
},
"scripts": {
"cs": "phpcs --standard=PSR2 -n ./",
"cbf": "phpcbf --standard=PSR2 -n ./",
"fixer": "php-cs-fixer fix ./",
"test": [
"phpunit --colors=always"
],
"unit": [
"@clearCache",
"phpunit --testsuite=Unit --colors=always"
],
"feature": [
"@clearCache",
"phpunit --testsuite=Feature --colors=always"
],
"coverage": "open cache/coverage/index.html",
"clearCache": "rm -rf cache/*",
"endpoints": [
"AlibabaCloud\\Client\\Regions\\LocationService::updateEndpoints",
"@fixer"
],
"release": [
"AlibabaCloud\\Client\\Release::release"
]
"files": [
"src/Functions.php"
]
},
"autoload-dev": {
"psr-4": {
"AlibabaCloud\\Client\\Tests\\": "tests/"
}
},
"config": {
"preferred-install": "dist",
"optimize-autoloader": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts-descriptions": {
"cs": "Tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.",
"cbf": "Automatically correct coding standard violations.",
"fixer": "Fixes code to follow standards.",
"test": "Run all tests.",
"unit": "Run Unit tests.",
"feature": "Run Feature tests.",
"clearCache": "Clear cache like coverage.",
"coverage": "Show Coverage html.",
"endpoints": "Update endpoints from OSS."
},
"scripts": {
"cs": "phpcs --standard=PSR2 -n ./",
"cbf": "phpcbf --standard=PSR2 -n ./",
"fixer": "php-cs-fixer fix ./",
"test": [
"phpunit --colors=always"
],
"test4HighVersion": [
"@clearCache",
"phpunit --testsuite=Test4HighVersion --colors=always"
],
"test4LowVersion": [
"@clearCache",
"phpunit --testsuite=Test4LowVersion --colors=always"
],
"unit4HighVersion": [
"@clearCache",
"phpunit --testsuite=Unit4HighVersion --colors=always"
],
"unit4LowVersion": [
"@clearCache",
"phpunit --testsuite=Unit4LowVersion --colors=always"
],
"feature4HighVersion": [
"@clearCache",
"phpunit --testsuite=Feature4HighVersion --colors=always"
],
"feature4LowVersion": [
"@clearCache",
"phpunit --testsuite=Feature4LowVersion --colors=always"
],
"coverage": "open cache/coverage/index.html",
"clearCache": "rm -rf cache/*",
"endpoints": [
"AlibabaCloud\\Client\\Regions\\LocationService::updateEndpoints",
"@fixer"
],
"release": [
"AlibabaCloud\\Client\\Release::release"
]
}
}

@ -30,7 +30,7 @@ class AlibabaCloud
/**
* Version of the Client
*/
const VERSION = '1.5.20';
const VERSION = '1.5.32';
/**
* This static method can directly call the specific service.

File diff suppressed because it is too large Load Diff

@ -3,7 +3,7 @@
namespace AlibabaCloud\Client\Credentials\Providers;
use Exception;
use Stringy\Stringy;
use AlibabaCloud\Client\Support\Stringy;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\Result\Result;
use Psr\Http\Message\ResponseInterface;
@ -112,7 +112,7 @@ class EcsRamRoleProvider extends Provider
try {
return RpcRequest::createClient()->request('GET', $url, $options);
} catch (GuzzleException $exception) {
if (Stringy::create($exception->getMessage())->contains('timed')) {
if (Stringy::contains($exception->getMessage(), 'timed')) {
$message = 'Timeout or instance does not belong to Alibaba Cloud';
} else {
$message = $exception->getMessage();

@ -42,7 +42,11 @@ class Encode
$string = '';
foreach ($this->data as $key => $value) {
$encode = rawurlencode($value);
$string .= "$key=$encode&";
if ($encode === '') {
$string .= "$key&";
} else {
$string .= "$key=$encode&";
}
}
if (0 < count($this->data)) {

@ -2,7 +2,7 @@
namespace AlibabaCloud\Client\Exception;
use Stringy\Stringy;
use AlibabaCloud\Client\Support\Stringy;
use RuntimeException;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\Result\Result;
@ -83,7 +83,7 @@ class ServerException extends AlibabaCloudException
private function distinguishSignatureErrors()
{
if ($this->result->getRequest()
&& Stringy::create($this->errorMessage)->contains($this->result->getRequest()->stringToSign())) {
&& Stringy::contains($this->errorMessage, $this->result->getRequest()->stringToSign())) {
$this->errorCode = 'InvalidAccessKeySecret';
$this->errorMessage = 'Specified Access Key Secret is not valid.';
}

@ -111,6 +111,13 @@ class ApiFilter
);
}
if (!preg_match("/^[a-zA-Z0-9_-]+$/", $endpointSuffix)) {
throw new ClientException(
'Invalid Endpoint Suffix',
SDK::INVALID_ARGUMENT
);
}
return $endpointSuffix;
}
@ -138,6 +145,13 @@ class ApiFilter
);
}
if (!preg_match("/^[a-zA-Z0-9_-]+$/", $network)) {
throw new ClientException(
'Invalid Network Suffix',
SDK::INVALID_ARGUMENT
);
}
return $network;
}

@ -35,6 +35,13 @@ class ClientFilter
);
}
if (!preg_match("/^[a-zA-Z0-9_-]+$/", $regionId)) {
throw new ClientException(
'Invalid Region ID',
SDK::INVALID_ARGUMENT
);
}
return strtolower($regionId);
}

@ -3,7 +3,7 @@
namespace AlibabaCloud\Client;
use Closure;
use Stringy\Stringy;
use AlibabaCloud\Client\Support\Stringy;
use League\CLImate\CLImate;
use AlibabaCloud\Client\Exception\ClientException;
@ -60,7 +60,7 @@ function inOpenBasedir($filename, $throwException = false)
function inDir($filename, array $dirs)
{
foreach ($dirs as $dir) {
if (!Stringy::create($dir)->endsWith(DIRECTORY_SEPARATOR)) {
if (!Stringy::endsWith($dir, DIRECTORY_SEPARATOR)) {
$dir .= DIRECTORY_SEPARATOR;
}

@ -10,11 +10,12 @@ use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* @deprecated Use GuzzleHttp\MessageFormatter.
* Class LogFormatter
*
* @package AlibabaCloud\Client\Log
*/
class LogFormatter extends MessageFormatter
class LogFormatter
{
/**
* @var float
@ -36,14 +37,14 @@ class LogFormatter extends MessageFormatter
*/
public function __construct($template)
{
parent::__construct($template);
// parent::__construct($template);
self::$logStartTime = microtime(true);
$this->template = $template;
$timezone = new DateTimeZone(date_default_timezone_get() ?: 'UTC');
if (PHP_VERSION_ID < 70100) {
self::$ts = DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), $timezone);
} else {
self::$ts = new DateTime(null, $timezone);
self::$ts = new DateTime('now', $timezone);
}
}

@ -2,35 +2,35 @@
namespace AlibabaCloud\Client\Request;
use Exception;
use ArrayAccess;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Uri;
use GuzzleHttp\Middleware;
use AlibabaCloud\Client\SDK;
use GuzzleHttp\HandlerStack;
use AlibabaCloud\Client\Encode;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Filter\Filter;
use AlibabaCloud\Client\Result\Result;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Promise\PromiseInterface;
use AlibabaCloud\Client\Credentials\Providers\CredentialsProvider;
use AlibabaCloud\Client\Encode;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Filter\ApiFilter;
use AlibabaCloud\Client\Log\LogFormatter;
use AlibabaCloud\Client\Traits\HttpTrait;
use GuzzleHttp\Exception\GuzzleException;
use AlibabaCloud\Client\Filter\HttpFilter;
use AlibabaCloud\Client\Traits\RegionTrait;
use AlibabaCloud\Client\Filter\ClientFilter;
use AlibabaCloud\Client\Filter\Filter;
use AlibabaCloud\Client\Filter\HttpFilter;
use AlibabaCloud\Client\Request\Traits\AcsTrait;
use AlibabaCloud\Client\Traits\ArrayAccessTrait;
use AlibabaCloud\Client\Traits\ObjectAccessTrait;
use AlibabaCloud\Client\Request\Traits\RetryTrait;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Request\Traits\ClientTrait;
use AlibabaCloud\Client\Request\Traits\DeprecatedTrait;
use AlibabaCloud\Client\Credentials\Providers\CredentialsProvider;
use AlibabaCloud\Client\Request\Traits\RetryTrait;
use AlibabaCloud\Client\Result\Result;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\Traits\ArrayAccessTrait;
use AlibabaCloud\Client\Traits\HttpTrait;
use AlibabaCloud\Client\Traits\ObjectAccessTrait;
use AlibabaCloud\Client\Traits\RegionTrait;
use ArrayAccess;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\MessageFormatter;
use GuzzleHttp\Middleware;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\ResponseInterface;
/**
* Class Request
@ -113,7 +113,7 @@ abstract class Request implements ArrayAccess
$this->options['timeout'] = self::TIMEOUT;
// Turn on debug mode based on environment variable.
if (strtolower(\AlibabaCloud\Client\env('DEBUG')) === 'sdk') {
if (null !== \AlibabaCloud\Client\env('DEBUG') && strtolower(\AlibabaCloud\Client\env('DEBUG')) === 'sdk') {
$this->options['debug'] = true;
}
@ -317,9 +317,15 @@ abstract class Request implements ArrayAccess
$this->resolveParameter();
if (isset($this->options['form_params'])) {
$this->options['form_params'] = \GuzzleHttp\Psr7\parse_query(
Encode::create($this->options['form_params'])->toString()
);
if (function_exists('\GuzzleHttp\Psr7\parse_query')) {
$this->options['form_params'] = \GuzzleHttp\Psr7\parse_query(
Encode::create($this->options['form_params'])->toString()
);
} else {
$this->options['form_params'] = \GuzzleHttp\Psr7\Query::parse(
Encode::create($this->options['form_params'])->toString()
);
}
}
$this->mergeOptionsIntoClient();
@ -382,7 +388,7 @@ abstract class Request implements ArrayAccess
if (AlibabaCloud::getLogger()) {
$stack->push(Middleware::log(
AlibabaCloud::getLogger(),
new LogFormatter(AlibabaCloud::getLogFormat())
new MessageFormatter(AlibabaCloud::getLogFormat())
));
}

@ -3,7 +3,7 @@
namespace AlibabaCloud\Client\Request;
use Exception;
use Stringy\Stringy;
use AlibabaCloud\Client\Support\Stringy;
use RuntimeException;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\Encode;
@ -98,9 +98,7 @@ class RoaRequest extends Request
*/
private function encodeBody(array $params)
{
$stringy = Stringy::create($this->options['headers']['Content-Type']);
if ($stringy->contains('application/json', false)) {
if (Stringy::contains($this->options['headers']['Content-Type'], 'application/json', false)) {
$this->options['body'] = json_encode($params);
$this->options['headers']['Content-MD5'] = base64_encode(md5($this->options['body'], true));
@ -125,7 +123,7 @@ class RoaRequest extends Request
$signature = $this->httpClient()->getSignature();
$this->options['headers']['x-acs-signature-method'] = $signature->getMethod();
$this->options['headers']['x-acs-signature-nonce'] = Sign::uuid($this->product . $this->realRegionId());
$this->options['headers']['x-acs-signature-nonce'] = Sign::uuid($this->product . $this->action);
$this->options['headers']['x-acs-signature-version'] = $signature->getVersion();
if ($signature->getType()) {
$this->options['headers']['x-acs-signature-type'] = $signature->getType();

@ -80,7 +80,7 @@ class RpcRequest extends Request
$this->options['query']['Format'] = $this->format;
$this->options['query']['SignatureMethod'] = $signature->getMethod();
$this->options['query']['SignatureVersion'] = $signature->getVersion();
$this->options['query']['SignatureNonce'] = Sign::uuid($this->product . $this->realRegionId());
$this->options['query']['SignatureNonce'] = Sign::uuid($this->product . $this->action);
$this->options['query']['Timestamp'] = gmdate($this->dateTimeFormat);
$this->options['query']['Action'] = $this->action;
if ($this->credential()->getAccessKeyId()) {

@ -2,14 +2,14 @@
namespace AlibabaCloud\Client\Request\Traits;
use GuzzleHttp\Psr7\Uri;
use AlibabaCloud\Client\SDK;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Request\Request;
use AlibabaCloud\Client\Filter\ApiFilter;
use AlibabaCloud\Client\Regions\LocationService;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
use AlibabaCloud\Client\Filter\ApiFilter;
use AlibabaCloud\Client\Regions\LocationService;
use AlibabaCloud\Client\Request\Request;
use AlibabaCloud\Client\SDK;
use GuzzleHttp\Psr7\Uri;
/**
* Trait AcsTrait
@ -200,8 +200,24 @@ trait AcsTrait
$host = $this->endpointMap[$region_id];
}
if (!$host) {
$this->hostResolver($host, $region_id);
}
}
/**
* @codeCoverageIgnore
*
* @param string $host
* @param string $region_id
*
* @throws ClientException
* @throws ServerException
*/
private function hostResolver(&$host, $region_id)
{
// 2. Find host by rules.
if (!$host && $this->endpointRegional !== null) {
if ($this->endpointRegional !== null) {
$host = AlibabaCloud::resolveHostByRule($this);
}
@ -234,6 +250,10 @@ trait AcsTrait
return AlibabaCloud::getDefaultRegionId();
}
if ($this->product && AlibabaCloud::isGlobalProduct($this->product)) {
return 'global';
}
throw new ClientException("Missing required 'RegionId' for Request", SDK::INVALID_REGION_ID);
}
}

@ -3,7 +3,7 @@
namespace AlibabaCloud\Client\Request\Traits;
use Exception;
use Stringy\Stringy;
use AlibabaCloud\Client\Support\Stringy;
use AlibabaCloud\Client\Result\Result;
use AlibabaCloud\Client\Filter\ClientFilter;
use AlibabaCloud\Client\Exception\ClientException;
@ -109,7 +109,7 @@ trait RetryTrait
}
foreach ($this->serverRetryStrings as $message) {
if (Stringy::create($result->getBody())->contains($message)) {
if (Stringy::contains($result->getBody(), $message)) {
$this->serverRetry--;
return true;
@ -137,7 +137,7 @@ trait RetryTrait
}
foreach ($this->clientRetryStrings as $message) {
if (Stringy::create($exception->getMessage())->contains($message)) {
if (Stringy::contains($exception->getMessage(), $message)) {
$this->clientRetry--;
return true;

@ -3,7 +3,6 @@
namespace AlibabaCloud\Client\Resolver;
use RuntimeException;
use ArgumentCountError;
/**
* Trait CallTrait
@ -59,7 +58,7 @@ trait CallTrait
private function getCallArguments($name, array $arguments, $index = 0)
{
if (!isset($arguments[$index])) {
throw new ArgumentCountError("Missing arguments to method $name");
throw new \InvalidArgumentException("Missing arguments to method $name");
}
return $arguments[$index];

@ -18,6 +18,7 @@ abstract class VersionResolver
* @param array $arguments
*
* @return mixed
* @throws ClientException
*/
public static function __callStatic($name, $arguments)
{
@ -61,7 +62,7 @@ abstract class VersionResolver
{
$array = \explode('\\', \get_class($this));
if (isset($array[1])) {
if (is_array($array) && isset($array[1])) {
return $array[1];
}

@ -111,6 +111,9 @@ class Sign
ksort($parameters);
$canonicalized = '';
foreach ($parameters as $key => $value) {
if ($value === null || $value === '') {
continue;
}
$canonicalized .= '&' . self::percentEncode($key) . '=' . self::percentEncode($value);
}
@ -135,6 +138,6 @@ class Sign
*/
public static function uuid($salt)
{
return md5($salt . uniqid(md5(microtime(true)), true));
return md5($salt . uniqid(md5(microtime(true)), true)) . microtime();
}
}

@ -0,0 +1,47 @@
<?php
namespace AlibabaCloud\Client\Support;
/**
* Class Stringy
*
* @package AlibabaCloud\Client\Support
*/
class Stringy
{
private static function _value($value, $default = '')
{
return null === $value ? $default : $value;
}
/**
* @param string $str
* @param string $substr
*
* @return bool
*/
public static function contains($str, $substr)
{
return false !== strpos(self::_value($str), self::_value($substr));
}
/**
* @param string $str
* @param string $substr
*
* @return bool
*/
public static function endsWith($str, $substr)
{
$str = self::_value($str);
$substr = self::_value($substr);
$length = \strlen($substr);
if (!$length) {
return true;
}
return substr($str, -$length) === $substr;
}
}

@ -17,6 +17,7 @@ trait ArrayAccessTrait
*
* @return mixed|null
*/
#[\ReturnTypeWillChange]
public function & offsetGet($offset)
{
if (isset($this->data[$offset])) {
@ -32,6 +33,7 @@ trait ArrayAccessTrait
* @param string $offset
* @param string|mixed $value
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->data[$offset] = $value;
@ -42,6 +44,7 @@ trait ArrayAccessTrait
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->data[$offset]);
@ -50,6 +53,7 @@ trait ArrayAccessTrait
/**
* @param string $offset
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->data[$offset]);

@ -182,14 +182,14 @@ trait ClientTrait
*/
public static function accessKeyClient($accessKeyId, $accessKeySecret)
{
if (strpos($accessKeyId, ' ') !== false) {
if (null === $accessKeyId || strpos($accessKeyId, ' ') !== false) {
throw new ClientException(
'AccessKey ID format is invalid',
SDK::INVALID_ARGUMENT
);
}
if (strpos($accessKeySecret, ' ') !== false) {
if (null === $accessKeySecret || strpos($accessKeySecret, ' ') !== false) {
throw new ClientException(
'AccessKey Secret format is invalid',
SDK::INVALID_ARGUMENT

@ -2,15 +2,15 @@
namespace AlibabaCloud\Client\Traits;
use InvalidArgumentException;
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Config\Config;
use AlibabaCloud\Client\Request\Request;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Filter\ApiFilter;
use AlibabaCloud\Client\Filter\HttpFilter;
use AlibabaCloud\Client\Filter\ClientFilter;
use AlibabaCloud\Client\Filter\HttpFilter;
use AlibabaCloud\Client\Regions\LocationService;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Request\Request;
use InvalidArgumentException;
/**
* Help developers set up and get host.
@ -53,6 +53,21 @@ trait EndpointTrait
return $domain;
}
/**
* @param $productCode
*
* @return bool
*/
public static function isGlobalProduct($productCode)
{
$global = LocationService::GLOBAL_REGION;
if (self::resolveHostByStatic($productCode, $global)) {
return true;
}
$productCode = null !== $productCode? strtolower($productCode) : null;
return (bool)Config::get("endpoints.{$productCode}.{$global}");
}
/**
* @param string $product
* @param string $regionId
@ -99,14 +114,14 @@ trait EndpointTrait
*/
public static function resolveHostByRule(Request $request)
{
$regionId = $request->realRegionId();
$network = $request->network ?: 'public';
$suffix = $request->endpointSuffix;
$network = $request->network ?: 'public';
$suffix = $request->endpointSuffix;
if ($network === 'public') {
$network = '';
}
if ($request->endpointRegional === 'regional') {
$regionId = $request->realRegionId();
return "{$request->product}{$suffix}{$network}.{$regionId}.aliyuncs.com";
}

@ -131,6 +131,7 @@ trait HasDataTrait
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($key)
{
return $this->dot->has($key);
@ -143,6 +144,7 @@ trait HasDataTrait
*
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->dot->offsetGet($key);
@ -154,6 +156,7 @@ trait HasDataTrait
* @param int|string|null $key
* @param mixed $value
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
$this->dot->offsetSet($key, $value);
@ -164,6 +167,7 @@ trait HasDataTrait
*
* @param int|string $key
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
$this->delete($key);
@ -192,6 +196,7 @@ trait HasDataTrait
*
* @return int
*/
#[\ReturnTypeWillChange]
public function count($key = null)
{
return $this->dot->count($key);
@ -202,6 +207,7 @@ trait HasDataTrait
*
* @return ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return $this->dot->getIterator();
@ -212,6 +218,7 @@ trait HasDataTrait
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->dot->jsonSerialize();

@ -2,6 +2,8 @@
namespace AlibabaCloud\Client\Traits;
use DateTime;
use DateTimeZone;
use Exception;
use Psr\Log\LoggerInterface;
@ -17,11 +19,21 @@ trait LogTrait
*/
private static $logger;
/**
* @var float
*/
private static $logStartTime = 0;
/**
* @var string
*/
private static $logFormat;
/**
* @var DateTime
*/
private static $ts;
/**
* @return LoggerInterface
*/
@ -37,7 +49,14 @@ trait LogTrait
*/
public static function setLogger(LoggerInterface $logger)
{
self::$logger = $logger;
self::$logger = $logger;
self::$logStartTime = microtime(true);
$timezone = new DateTimeZone(date_default_timezone_get() ?: 'UTC');
if (PHP_VERSION_ID < 70100) {
self::$ts = DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), $timezone);
} else {
self::$ts = new DateTime('now', $timezone);
}
}
/**
@ -45,8 +64,14 @@ trait LogTrait
*/
public static function getLogFormat()
{
return self::$logFormat
$template = self::$logFormat
?: '"{method} {uri} HTTP/{version}" {code} {cost} {hostname} {pid}';
return str_replace(
['{pid}', '{cost}', '{start_time}'],
[getmypid(), self::getCost(), self::$ts->format('Y-m-d H:i:s.u')],
$template
);
}
/**
@ -61,4 +86,12 @@ trait LogTrait
{
self::$logFormat = $formatter;
}
/**
* @return float|mixed
*/
private static function getCost()
{
return microtime(true) - self::$logStartTime;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save