Skip to content
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

请求Qiniu/Enum/SplitUploadVersion.php取消继承QiniuEnum #422

Open
CNBroderick opened this issue Nov 21, 2023 · 2 comments
Open

请求Qiniu/Enum/SplitUploadVersion.php取消继承QiniuEnum #422

CNBroderick opened this issue Nov 21, 2023 · 2 comments

Comments

@CNBroderick
Copy link

请求原因

  1. PHP 5.6,下升级七牛SDK 7.0.4 到 最新版本7.11.0后,调用上传文件接口时,出现错误。

  2. QiniuEnum 除了 SplitUploadVersion 以外,没有任何类依赖。

错误原因

QiniuEnum继承了一个外部的Enum导致错误:找不到类。

QiniuEnum 看似很简洁,实则无比沉重,里面又继承了Enum:php-enum在此Enum中,还会引入依赖 sebastianbergmann/comparator

解决办法

经过多次引入和修改,都没有能够使 QiniuEnum 正常的工作,最后放弃了继承 QiniuEnum 并 更改 SplitUploadVersion 为以下代码才正常工作。

<?php

namespace Qiniu\Enum;

final class SplitUploadVersion
{
    const V1 = 'v1';
    const V2 = 'v2';

    public static function from($value) {
        if($value === self::V1) return self::V1;
        if($value === self::V2) return self::V2;

        return null;
    }
}
@lihsai0
Copy link
Collaborator

lihsai0 commented Nov 21, 2023

@CNBroderick
是在人工管理依赖嘛?PHP 5.6.40 通过 Composer 安装 SDK 没有复现「找不到类」的错误。

@CNBroderick
Copy link
Author

@CNBroderick 是在人工管理依赖嘛?PHP 5.6.40 通过 Composer 安装 SDK 没有复现「找不到类」的错误。

是的,因为是早期的ThinkPHP3框架的项目,所以得需要人工引入。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants