Skip to content

兼容php8.1和php8.2 #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed

兼容php8.1和php8.2 #380

wants to merge 6 commits into from

Conversation

tianyiw2013
Copy link

@tianyiw2013 tianyiw2013 commented Mar 26, 2022

不影响低版本PHP!!!

  • \src\Qiniu\Http\Header.php > During inheritance of ArrayAccess
  • \src\Qiniu\Config.php > Creation of dynamic property Qiniu\Config::$zone is deprecated
  • \src\Qiniu\Auth.php > strlen(): Passing null to parameter #1 ($string) of type string is deprecated

Auth.php > count($body)
Header.php > During inheritance of ArrayAccess
Header.php > count($this->data[$key] > 0)
@tianyiw2013 tianyiw2013 changed the title 修复bug和兼容php8.1 兼容php8.1 Apr 12, 2022
@qiniu-bot qiniu-bot added size/XS and removed size/S labels Apr 12, 2022
@tianyiw2013 tianyiw2013 changed the title 兼容php8.1 兼容php8.1 During inheritance of ArrayAccess Apr 12, 2022
@tianyiw2013 tianyiw2013 changed the title 兼容php8.1 During inheritance of ArrayAccess Fixed During inheritance of ArrayAccess with PHP8.1 Apr 12, 2022
@tianyiw2013
Copy link
Author

视而不见吗。。。

@bachue
Copy link
Contributor

bachue commented Apr 12, 2022

@tianyiw2013 我们内部会做审查的

@bachue bachue added the enhancement Anything around developer experience or feature request. label Apr 12, 2022
@coding-linheng
Copy link

合并一下啊,PHP8以后都会报错

@tianyiw2013
Copy link
Author

tianyiw2013 commented Apr 19, 2022

@cnmade

@tianyiw2013 我们内部会做审查的

一共就加了几行代码,看一眼不就审查完了吗,你们这审查流程是不是太复杂了?

@lihsai0
Copy link
Collaborator

lihsai0 commented Apr 20, 2022

@coding-linheng @tianyiw2013 您好,十分抱歉回复晚了。

目前 PHP SDK 支持的版本为 cURL extension, 5.3 - 5.6,7.0,确实也在考虑兼容 7.x, 8.x 的相关事宜。

但目前有几个事情还有困难:

  • 测试框架本身版本并不支持在高版本的 PHP 上运行,如果升级了测试框架又难以在低版本上运行测试。
  • PHP 8.x 其中有一项就是增强类型系统,如果加了类型,低版本用户将无法使用,而通过注释的方式去忽略这些警告,又抛弃了发现错误的可能。

基于以上原因,难以同时保证不同 PHP 版本用户的使用。

目前可能的一个途径是使用 PHPCompatibility 来完成这一兼容性问题,还在调研中。

由于还有其他工作内容,进度确实比较慢,还请海涵。🙏

@qiniu-bot qiniu-bot added size/S and removed size/XS labels Jul 7, 2022
@tianyiw2013 tianyiw2013 changed the title Fixed During inheritance of ArrayAccess with PHP8.1 兼容php8.1和php8.2 Jul 7, 2022
Copy link
Author

@tianyiw2013 tianyiw2013 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lihsai0 您好,麻烦审核一下!不影响旧版本PHP!!!

@lihsai0 lihsai0 mentioned this pull request Jul 12, 2022
@lihsai0
Copy link
Collaborator

lihsai0 commented Jul 12, 2022

@tianyiw2013 久等了。非常感谢您的 PR。

使用目前的测试用例测试下来,基本通过。
(测试 PHP 版本:5.4, 5.5, 5.6, 7.0, 7.1.33, 7.2.34, 7.3.33, 7.4.27, 8.0.17, 8.1.4, 8.2.0alph3)

主要修改内容:

  • 忽略 PHP 8.x 开始引入的大部分类型检查;

需要进一步修改,所以新建了一个 PR(#388):

  1. PR 中有部分 commit 没有修改内容,压缩为一个 commit 即可;
  2. 使用 phpcbf 格式化代码;
  3. src/Qiniu/Http/Client.php:134 需要判断参数 $strnull 直接返回 null(null 文件名场景);

@tianyiw2013
Copy link
Author

谢谢,我关闭该PR了

@tianyiw2013
Copy link
Author

@lihsai0
使用 phpcbf 格式化代码建议使用phpcbf --standard=PSR12参数
PSR12规范里,下面的代码是符合规范的😄

if (
    !is_null($body)
    && strlen($body) > 0
    && isset($headers["Content-Type"])
    && $headers["Content-Type"] != "application/octet-stream"
) {
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Anything around developer experience or feature request. size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants