Skip to content

Commit c3a5116

Browse files
Support PHP8.2 (#110)
* Officially support PHP8.2 * Drop `OPENSSL_SSLV23_PADDING` test cases, because it was removed via openssl3 see openssl/openssl#14216, openssl/openssl#14283, shivammathur/setup-php#658 * Add `SECURITY.md` guideline and mentioning that TSRC is the right place for the security issues
1 parent c34b781 commit c3a5116

File tree

14 files changed

+129
-43
lines changed

14 files changed

+129
-43
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
.gitignore export-ignore
55
/docs/ export-ignore
66
/phpstan.neon.dist export-ignore
7+
/phpstan.v7.1.neon export-ignore
8+
/phpstan.v8.2.neon export-ignore
79
/phpunit.xml.dist export-ignore
810
/tests/ export-ignore
911
/Makefile export-ignore

.github/workflows/ci.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ on: [push, pull_request]
44

55
jobs:
66
ci:
7+
defaults:
8+
run:
9+
shell: bash
710
name: CI
811
strategy:
912
fail-fast: false
1013
matrix:
11-
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
14+
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
1215
os: [ubuntu-latest, macOS-latest, windows-latest]
1316
runs-on: ${{ matrix.os }}
1417
steps:
1518
- name: Set git config
16-
shell: bash
1719
run: |
1820
git config --global core.autocrlf false
1921
git config --global core.symlinks true
2022
if: runner.os == 'Windows'
2123

22-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2325

2426
- name: Setup PHP${{ matrix.php-version }}@${{ matrix.os }}
2527
uses: shivammathur/setup-php@v2
@@ -33,12 +35,12 @@ jobs:
3335

3436
- name: Get composer cache directory
3537
id: composer-cache
36-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
38+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3739

3840
- name: Cache dependencies on PHP(=7.1)@${{ matrix.os }}
3941
if: matrix.php-version == '7.1'
4042
id: dependencies-cache-71
41-
uses: actions/cache@v2
43+
uses: actions/cache@v3
4244
with:
4345
path: ${{ steps.composer-cache.outputs.dir }}
4446
key: ${{ matrix.os }}-php${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
@@ -48,7 +50,7 @@ jobs:
4850
- name: Cache dependencies on PHP(=7.2)@${{ matrix.os }}
4951
if: matrix.php-version == '7.2'
5052
id: dependencies-cache-72
51-
uses: actions/cache@v2
53+
uses: actions/cache@v3
5254
with:
5355
path: ${{ steps.composer-cache.outputs.dir }}
5456
key: ${{ matrix.os }}-php${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
@@ -58,7 +60,7 @@ jobs:
5860
- name: Cache dependencies on PHP(>7.2)@${{ matrix.os }}
5961
if: matrix.php-version > 7.2
6062
id: dependencies-cache
61-
uses: actions/cache@v2
63+
uses: actions/cache@v3
6264
with:
6365
path: ${{ steps.composer-cache.outputs.dir }}
6466
key: ${{ matrix.os }}-php-${{ hashFiles('**/composer.lock') }}
@@ -68,7 +70,24 @@ jobs:
6870
- name: Install dependencies
6971
run: composer install --no-interaction --no-progress
7072

71-
- run: vendor/bin/phpstan analyse --no-progress
73+
- name: Environments
74+
run: |
75+
openssl version
76+
php --ri openssl
77+
php --ri libxml
78+
php --ri curl
79+
80+
- run: vendor/bin/phpstan analyse --no-progress --memory-limit=-1 -c phpstan.v7.1.neon
81+
if: matrix.php-version == '7.1'
82+
id: phpstan-php-7_1
83+
84+
- run: vendor/bin/phpstan analyse --no-progress --memory-limit=-1
85+
if: 7.1 < matrix.php-version && matrix.php-version < 8.2
86+
id: phpstan-php-7_2-8_1
87+
88+
- run: vendor/bin/phpstan analyse --no-progress --memory-limit=-1 -c phpstan.v8.2.neon
89+
if: matrix.php-version == '8.2'
90+
id: phpstan-php-8_2
7291

7392
- run: |
7493
make keygen

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# 变更历史
22

3+
## [1.4.7](../../compare/v1.4.6...v1.4.7) - 2022-12-05
4+
5+
- 对PHP8.2的官方支持,如下PHP8.2的特性需要被提及:
6+
- ext-openssl 有若干调整,已知在 `OpenSSL3.0` 上,常量 `RSA_SSLV23_PADDING` 被删除(详细可阅读 openssl/openssl#14216, openssl/openssl#14283),PHP做了兼容处理,如果扩展依赖的是`OpenSSL3.0`,则对应的`OPENSSL_SSLV23_PADDING`常量将不存在,进而影响到了「非对称加解密混合填充模式的测试用例」的覆盖(详情可阅读 shivammathur/setup-php#658)。本类库并不支持此填充模式,删除对`OPENSSL_SSLV23_PADDING`的测试断言,向前兼容;
7+
- 对象动态属性的废弃提示([Deprecate dynamic properties](https://wiki.php.net/rfc/deprecate_dynamic_properties)),本类库实例构造的是`ArrayIterator`的一个“伪”动态属性结构体,对象属性访问实则访问的是`ArrayObject`内置`__storage`属性,形似动态属性实则不是;此废弃提示对本类库本身无影响;
8+
39
## [1.4.6](../../compare/v1.4.5...v1.4.6) - 2022-08-19
410

511
- 取消 `APIv2` 上的`trigger_error`提醒,以消除不必要的恐慌;

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
### 功能介绍
1717

18-
1. 微信支付 APIv2 和 APIv3 的 Guzzle HTTP 客户端,支持 [同步](#同步请求)[异步](#异步请求) 发送请求,并自动进行请求签名和应答验签
18+
1. 微信支付 APIv2 和 APIv3 的 Guzzle HTTP 客户端,支持 [同步](#同步请求) [异步](#异步请求) 发送请求,并自动进行请求签名和应答验签
1919

2020
1. [链式实现的 URI Template](#链式-uri-template)
2121

@@ -25,7 +25,7 @@
2525

2626
## 项目状态
2727

28-
当前版本为 `1.4.6` 测试版本。
28+
当前版本为 `1.4.7` 测试版本。
2929
项目版本遵循 [语义化版本号](https://semver.org/lang/zh-CN/)
3030
如果你使用的版本 `<=v1.3.2`,升级前请参考 [升级指南](UPGRADING.md)
3131

@@ -36,7 +36,7 @@
3636
+ Guzzle 7.0,PHP >= 7.2.5
3737
+ Guzzle 6.5,PHP >= 7.1.2
3838

39-
项目已支持 PHP 8。我们推荐使用目前处于 [Active Support](https://www.php.net/supported-versions.php) 阶段的 PHP 8.0 和 Guzzle 7。
39+
我们推荐使用目前处于 [Active Support](https://www.php.net/supported-versions.php) 阶段的 PHP 8 和 Guzzle 7。
4040

4141
## 安装
4242

SECURITY.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 1.x | :white_check_mark: |
8+
9+
## Reporting a Vulnerability
10+
11+
Please do not open GitHub issues or pull requests - this makes the problem immediately visible to everyone, including malicious actors.
12+
13+
Security issues in this open source project can be safely reported to [TSRC](https://security.tencent.com).
14+
15+
## 报告漏洞
16+
17+
请不要使用 GitHub issues 或 pull request —— 这会让漏洞立即暴露给所有人,包括恶意人员。
18+
19+
请将本开源项目的安全问题报告给 [腾讯安全应急响应中心](https://security.tencent.com).
20+
21+
---
22+
23+
另外,你可能需要关注影响本SDK运行时行为的主要的PHP扩展缺陷列表:
24+
25+
+ [OpenSSL](https://www.openssl.org/news/vulnerabilities.html)
26+
+ [libxml2](https://gitlab.gnome.org/GNOME/libxml2/-/blob/master/NEWS)
27+
+ [curl](https://curl.se/docs/security.html)
28+
29+
当你准备在报告安全问题时,请先对照如上列表,确认是否存在已知运行时环境安全问题。
30+
当你尝试升级主要扩展至最新版本之后,如若问题依旧存在,请将本开源项目的安全问题报告给 [TSRC腾讯安全应急响应中心](https://security.tencent.com),致谢。

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wechatpay/wechatpay",
3-
"version": "1.4.6",
3+
"version": "1.4.7",
44
"description": "[A]Sync Chainable WeChatPay v2&v3's OpenAPI SDK for PHP",
55
"type": "library",
66
"keywords": [

phpstan.v7.1.neon

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
includes:
2+
- phpstan.neon.dist
3+
parameters:
4+
ignoreErrors:
5+
-
6+
message: "#^Cannot access offset 'v2/pay/micropay' on WeChatPay\\\\BuilderChainable\\.$#"
7+
count: 1
8+
path: tests/BuilderTest.php
9+
10+
-
11+
message: "#^Cannot access offset 'v2/pay/refundquery' on WeChatPay\\\\BuilderChainable\\.$#"
12+
count: 1
13+
path: tests/BuilderTest.php
14+
15+
-
16+
message: "#^Parameter \\#2 \\$array of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) expects array\\|ArrayAccess, array\\<string, string\\>\\|false given\\.$#"
17+
count: 1
18+
path: tests/BuilderTest.php
19+
20+
-
21+
message: "#^Parameter \\#2 \\$array of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) expects array\\|ArrayAccess, array\\<string, string\\>\\|false given\\.$#"
22+
count: 1
23+
path: tests/ClientDecoratorTest.php
24+
25+
-
26+
message: "#^Parameter \\#2 \\$array of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) expects array\\|ArrayAccess, array\\<string, string\\>\\|false given\\.$#"
27+
count: 1
28+
path: tests/Crypto/AesEcbTest.php
29+
30+
-
31+
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|null given\\.$#"
32+
count: 1
33+
path: tests/Crypto/HashTest.php
34+
35+
-
36+
message: "#^Parameter \\#2 \\$string of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertRegExp\\(\\) expects string, string\\|null given\\.$#"
37+
count: 1
38+
path: tests/Crypto/HashTest.php
39+

phpstan.v8.2.neon

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- phpstan.neon.dist
3+
parameters:
4+
ignoreErrors:
5+
-
6+
message: "#^Access to an undefined property.*WeChatPay\\\\BuilderChainable\\:\\:\\$v3\\.$#"
7+
count: 1
8+
path: tests/BuilderTest.php

src/ClientDecoratorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface ClientDecoratorInterface
1414
/**
1515
* @var string - This library version
1616
*/
17-
public const VERSION = '1.4.6';
17+
public const VERSION = '1.4.7';
1818

1919
/**
2020
* @var string - The HTTP transfer `xml` based protocol

tests/BuilderTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ public function testFactory(string $mchid, $privateKey, $publicKey, string $mchS
7878
self::assertIsArray($map);
7979
self::assertNotEmpty($map);
8080

81-
self::assertArrayHasKey(BuilderChainable::class, is_array($map) ? $map : []);
81+
self::assertArrayHasKey(BuilderChainable::class, $map);
8282
if (method_exists($this, 'assertContainsEquals')) {
83-
$this->assertContainsEquals(BuilderChainable::class, is_array($map) ? $map : []);
83+
$this->assertContainsEquals(BuilderChainable::class, $map);
8484
}
8585

8686
self::assertInstanceOf(ArrayAccess::class, $instance);
@@ -90,7 +90,7 @@ public function testFactory(string $mchid, $privateKey, $publicKey, string $mchS
9090

9191
self::assertIsArray($traits);
9292
self::assertNotEmpty($traits);
93-
self::assertContains(\WeChatPay\BuilderTrait::class, is_array($traits) ? $traits : []);
93+
self::assertContains(\WeChatPay\BuilderTrait::class, $traits);
9494

9595
self::assertInstanceOf(BuilderChainable::class, $instance->v3);
9696
/** @phpstan-ignore-next-line */
@@ -100,9 +100,7 @@ public function testFactory(string $mchid, $privateKey, $publicKey, string $mchS
100100
/** @phpstan-ignore-next-line */
101101
self::assertInstanceOf(BuilderChainable::class, $instance->v3->marketing->busifavor->users['{openid}/coupons/{coupon_code}']->appids['{appid}']);
102102

103-
/** @phpstan-ignore-next-line */
104103
self::assertInstanceOf(BuilderChainable::class, $instance['v2/pay/micropay']);
105-
/** @phpstan-ignore-next-line */
106104
self::assertInstanceOf(BuilderChainable::class, $instance['v2/pay/refundquery']);
107105

108106
self::assertInstanceOf(BuilderChainable::class, $instance->chain('what_ever_endpoints/with-anyDepths_segments/also/contains/{uri_template}/{blah}/blah/'));

0 commit comments

Comments
 (0)