我有两个插件 Analytify 和 Loginpress。在 Loginpress 插件中,当我将社交登录配置为 Google(以 Google 身份登录)时,出现以下错误:
致命错误:未捕获错误:Google\Auth\HttpHandler\HttpHandlerFactory::build():参数 #1 ($client) 必须是 ?GuzzleHttp\ClientInterface、Analytify\GuzzleHttp\Client 类型,在 C:\Users 中调用\WPB\本地站点 nalytify-google-login pp\public\wp-content\plugins\wp-analytify\lib\Google-GA4 endor\google piclient\src\Client.php 第 220 行 在 C:\Users\WPB\Local Sites nalytify-google-login pp\public\wp-content\plugins\loginpress-pro ddons\social-login\sdk\google-client endor\google uth\src\ HttpHandler\HttpHandlerFactory.php 第 34 行
我通过将 Analytify\GuzzleHttp\Client 更改为 GuzzleHttp\Client 来解决此问题,其中已声明的类已出现。使用 php-scoper 将命名空间添加到 analytify 插件中,scoper-inc.php 代码为:
<?php
declare (strict_types=1);
namespace Analytify;
// scoper.inc.php
use Analytify\Isolated\Symfony\Component\Finder\Finder;
return [
'prefix' => 'Analytify',
// string|null
'output-dir' => null,
// string|null
'finders' => [],
// list<Finder>
'patchers' => [],
// list<callable(string $filePath, string $prefix, string $contents): string>
'exclude-files' => [],
// list<string>
'exclude-namespaces' => ['Google\\', 'Grpc\\', 'Composer\\'],
// list<string|regex>
'exclude-constants' => [],
// list<string|regex>
'exclude-classes' => [],
// list<string|regex>
'exclude-functions' => [],
// list<string|regex>
'expose-global-constants' => \true,
// bool
'expose-global-classes' => \true,
// bool
'expose-global-functions' => \true,
// bool
'expose-namespaces' => [],
// list<string|regex>
'expose-constants' => [],
// list<string|regex>
'expose-classes' => [],
// list<string|regex>
'expose-functions' => [],
];
现在我需要有关以下问题的指导:我必须在哪个插件中解决命名空间问题以及如何在 Analytify 中解决该问题?
当我将命名空间添加到 Loginpress 时,它自己的功能分解是单独的问题。此外,当我卸载 Analytfiy 时,我的登录 Google 开始正常工作。但我需要这两个插件。
问题已解决。我首先更新了库。其次,我排除了以下命名空间作为 php-scoper 中的命名空间:
'exclude-namespaces' => ['Google\\', 'Grpc\\', 'Composer\\', 'GuzzleHttp\\', 'Monolog\\', 'Psr\\']
现在我的插件与社交登录插件没有冲突问题,问题已解决。