Skip to content

Commit

Permalink
Merge branch 'master' into httpClient
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian authored Apr 20, 2021
2 parents 09021d6 + ce97db8 commit 8d09f63
Show file tree
Hide file tree
Showing 36 changed files with 84 additions and 110 deletions.
14 changes: 3 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ php:
- hhvm-3.24
- nightly
env:
- COMPOSER_OPTS=""
- COMPOSER_OPTS="--prefer-lowest"
- COMPOSER_OPTS="" XDEBUG_MODE="coverage"
- COMPOSER_OPTS="--prefer-lowest" XDEBUG_MODE="coverage"

matrix:
allow_failures:
Expand All @@ -29,14 +29,6 @@ before_install:

install:
# Build job specific tweaks
- >
if [ $(phpenv version-name) == "5.5" ]; then
rm ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
fi
- >
if [ $(phpenv version-name) != "hhvm-3.24" ] && [ $(phpenv version-name) != "nightly" ]; then
echo "xdebug.overload_var_dump = 0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
fi
- >
if { [ $(phpenv version-name) == "7.2" ] || [ $(phpenv version-name) == "7.3" ] || [ $(phpenv version-name) == "7.4" ] ; } && [ -v COMPOSER_OPTS ]; then
composer require --dev phpunit/phpunit "~5.7.27"
Expand All @@ -55,7 +47,7 @@ install:

script:
# Start Proxy
- sudo o_o &
- o_o &
# Unit Test
- test -z $ACCESS_KEY_ID -a -z $ACCESS_KEY_SECRET || composer test

Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 1.5.30 - 2021-03-22
- Fixed incompatibility in PHP 5.6 version.

## 1.5.29 - 2020-08-03
- Fixed RPC Signature.

Expand Down
6 changes: 3 additions & 3 deletions README-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Alibaba Cloud Client for PHP 是帮助 PHP 开发者管理凭据、发送请求
[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 的难度。


## 先决条件
Expand Down Expand Up @@ -139,7 +139,7 @@ try {

## 相关
* [阿里云服务 Regions & Endpoints][endpoints]
* [OpenAPI Explorer][open-api]
* [阿里云 OpenAPI 开发者门户][open-api]
* [Packagist][packagist]
* [Composer][composer]
* [Guzzle中文文档][guzzle-docs]
Expand All @@ -153,7 +153,7 @@ 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
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Alibaba Cloud Client for PHP is a client tool that helps PHP developers manage c
[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+.
Expand Down Expand Up @@ -139,7 +138,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]
Expand All @@ -153,7 +152,7 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install:

test_script:
# Start Proxy
- ps: Start-Process -FilePath o_o -NoNewWindow
- ps: o_o &
# Test
- cd %APPVEYOR_BUILD_FOLDER%
- vendor\bin\phpunit --colors=always
17 changes: 17 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -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;
});
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"drupal/coder": "^8.3",
"symfony/dotenv": "^3.4",
"league/climate": "^3.2.4",
"phpunit/phpunit": "^5.7.27",
"phpunit/phpunit": "^5.7.27|^6.1",
"monolog/monolog": "^1.24",
"composer/composer": "^1.8",
"mikey179/vfsstream": "^1.6",
Expand Down
1 change: 0 additions & 1 deletion src/Config/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -3797,4 +3797,3 @@
],
],
];

3 changes: 1 addition & 2 deletions src/Resolver/CallTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace AlibabaCloud\Client\Resolver;

use RuntimeException;
use ArgumentCountError;

/**
* Trait CallTrait
Expand Down Expand Up @@ -59,7 +58,7 @@ public function __call($name, $arguments)
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];
Expand Down
2 changes: 0 additions & 2 deletions tests/Feature/Credentials/AccessKeyCredentialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class AccessKeyCredentialTest extends TestCase
*/
public function setUp()
{
parent::setUp();
$regionId = 'cn-hangzhou';
$accessKeyId = \getenv('ACCESS_KEY_ID');
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
Expand All @@ -43,7 +42,6 @@ public function setUp()
*/
public function tearDown()
{
parent::tearDown();
AlibabaCloud::del($this->clientName);
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Feature/Credentials/BearerTokenCredentialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class BearerTokenCredentialTest extends TestCase
*/
public function setUp()
{
parent::setUp();
$regionId = 'cn-hangzhou';
$bearerToken =
'eyJhbGciOiJSUzI1NiIsImsyaWQiOiJlNE92NnVOUDhsMEY2RmVUMVhvek5wb1NBcVZLblNGRyIsImtpZCI6IkpDOXd4enJocUowZ3RhQ0V0MlFMVWZldkVVSXdsdEZodWk0TzFiaDY3dFUifQ.N3plS0w2cm83YzhtVzJqSkI0U0JIMldzNW45cFBOSWdNellvQ3VpZGV5NzRVOHNsMkJUWTVULzl3RDdkbzhHQkorM3dvclg1SGY1STZXL1FjaVhLVnc5ck5YeVNYanBuK2N6UkN1SnRRc3FRMGJIVTF4cVVjUDVRNUJpK2JsSWxZdlowZ2VWSzYvS2pzcVNjWHJLSlVvWkNnWE0wWGJZZ0NCVm1BUlNXS1plUnNzdnAvUmwwV01tSFFkWmlOMGtKV0o5TllQU3M0QU1aenpHVTdUY1BnYlhIVy9uTmdMY1JVSytROXlrPQ.kvZes7-6IU-xjOzK1goPPjODz1XLt73yCmDLSpRwzlz3d9A_uYvbQK0HHltVKo0K0dI0wJOfpCeOHJlrV0m4RI4bynL9ltl31rscPhQ-G4Ybqw4KXVBZCIzjSqzWcniIWnGWl-TpOy0Y7sAcJmp0Lg2ndu_shGqiTP6DTVBNV8f94mveHmRqouLxr2OKMvCyxTV1zUEJmC-JnZaljfNG-i483qG8Hm60CwAjM91FTGib3eXGzjJa3XOOY7zpZTrvahBYFpyrVhRuvDvRs6tLKVAL_7bYwCIo_tdh9rhRmFtyq0k2iykZQJmAIlDMt-VENP7hJTH62uUQzNLQ28ISTQ';
Expand All @@ -42,7 +41,6 @@ public function setUp()
*/
public function tearDown()
{
parent::tearDown();
AlibabaCloud::del($this->clientName);
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Feature/Credentials/EcsRamRoleCredentialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class EcsRamRoleCredentialTest extends TestCase
*/
public function setUp()
{
parent::setUp();
$regionId = 'cn-hangzhou';
$roleName = 'EcsRamRoleTest';
AlibabaCloud::ecsRamRoleClient($roleName)
Expand All @@ -45,7 +44,6 @@ public function setUp()
*/
public function tearDown()
{
parent::tearDown();
AlibabaCloud::del($this->clientName);
}

Expand Down
1 change: 0 additions & 1 deletion tests/Feature/Credentials/IniCredentialFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public static function testNoSecret()
*/
public function tearDown()
{
parent::tearDown();
AlibabaCloud::del('phpunit');
IniCredential::forgetLoadedCredentialsFile();
}
Expand Down
2 changes: 0 additions & 2 deletions tests/Feature/Credentials/RamRoleArnCredentialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class RamRoleArnCredentialTest extends TestCase
*/
public function setUp()
{
parent::setUp();
$regionId = 'cn-hangzhou';
$accessKeyId = \getenv('ACCESS_KEY_ID');
$accessKeySecret = \getenv('ACCESS_KEY_SECRET');
Expand Down Expand Up @@ -72,7 +71,6 @@ public function setUp()
*/
public function tearDown()
{
parent::tearDown();
AlibabaCloud::del($this->clientName);
}

Expand Down
2 changes: 0 additions & 2 deletions tests/Feature/Credentials/RsaKeyPairCredentialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class RsaKeyPairCredentialTest extends TestCase
*/
public function setUp()
{
parent::setUp();
$regionId = 'ap-northeast-1';
$publicKeyId = \AlibabaCloud\Client\env('PUBLIC_KEY_ID');
$privateKeyFile = VirtualRsaKeyPairCredential::privateKeyFileUrl();
Expand All @@ -42,7 +41,6 @@ public function setUp()
*/
public function tearDown()
{
parent::tearDown();
AlibabaCloud::del($this->clientName);
}

Expand Down
3 changes: 0 additions & 3 deletions tests/Feature/Product/RamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
use AlibabaCloud\Client\Exception\ClientException;
use PHPUnit\Framework\TestCase;


class RamTest extends TestCase
{
/**
* @throws ClientException
*/
public function setUp()
{
parent::setUp();

AlibabaCloud::accessKeyClient(\getenv('ACCESS_KEY_ID'), \getenv('ACCESS_KEY_SECRET'))
->asDefaultClient();
}
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/Request/ChainProviderRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public function testDefaultProviderOnIni()

protected function setUp()
{
parent::setUp();
AlibabaCloud::flush();
CredentialsProvider::flush();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class DistinguishSignatureAndCredentialErrorsTest extends TestCase
*/
public function setUp()
{
parent::setUp();

AlibabaCloud::accessKeyClient(\getenv('ACCESS_KEY_ID'), 'bad')
->regionId('cn-shanghai')
->asDefaultClient();
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/Request/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public function testAccept()
*/
protected function setUp()
{
parent::setUp();
AlibabaCloud::accessKeyClient(
\getenv('ACCESS_KEY_ID'),
\getenv('ACCESS_KEY_SECRET')
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/Request/RetryByClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class RetryByClientTest extends TestCase
{
protected function setUp()
{
parent::setUp();
AlibabaCloud::forgetHistory();
AlibabaCloud::rememberHistory();
}
Expand Down
11 changes: 5 additions & 6 deletions tests/Feature/Request/RetryByServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class RetryByServerTest extends TestCase
{
protected function setUp()
{
parent::setUp();
AlibabaCloud::forgetHistory();
AlibabaCloud::rememberHistory();
}
Expand All @@ -44,7 +43,7 @@ public function testNoRetry()
->timeout(30)
->request();
} catch (Exception $exception) {
self::assertTrue(Stringy::create($exception->getMessage())->contains('Action or Version'));
self::assertFalse(Stringy::create($exception->getMessage())->contains('Action or Version'));
self::assertEquals(1, AlibabaCloud::countHistory());
}
}
Expand All @@ -71,8 +70,8 @@ public function testRetryWithStrings()
->retryByServer(3, ['Action or Version'])
->request();
} catch (Exception $exception) {
self::assertTrue(Stringy::create($exception->getMessage())->contains('Action or Version'));
self::assertEquals(4, AlibabaCloud::countHistory());
self::assertFalse(Stringy::create($exception->getMessage())->contains('Action or Version'));
self::assertEquals(1, AlibabaCloud::countHistory());
}
}

Expand All @@ -98,7 +97,7 @@ public function testRetryWithStatusCode()
->retryByServer(3, [], [404])
->request();
} catch (Exception $exception) {
self::assertTrue(Stringy::create($exception->getMessage())->contains('Action or Version'));
self::assertFalse(Stringy::create($exception->getMessage())->contains('Action or Version'));
self::assertEquals(4, AlibabaCloud::countHistory());
}
}
Expand All @@ -125,7 +124,7 @@ public function testRetryWithFalse()
->retryByServer(3, [], [])
->request();
} catch (Exception $exception) {
self::assertTrue(Stringy::create($exception->getMessage())->contains('Action or Version'));
self::assertFalse(Stringy::create($exception->getMessage())->contains('Action or Version'));
self::assertEquals(1, AlibabaCloud::countHistory());
}
}
Expand Down
Loading

0 comments on commit 8d09f63

Please sign in to comment.