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

[BUG] trait里的__construct无法切面AOP #6654

Open
onekb opened this issue Apr 4, 2024 · 2 comments
Open

[BUG] trait里的__construct无法切面AOP #6654

onekb opened this issue Apr 4, 2024 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@onekb
Copy link
Contributor

onekb commented Apr 4, 2024

图中的trait有一个__construct初始化方法,有个类use此trait后,如果对其AOP,是没法执行__construct的,不会执行红箭头代码
632e9c6d4c76050199526ed7de4f67d
27eacdd06b854e712d2606f84db99d5

把切入类注释掉后,正常输出“config”内容
281a464ff9d4a8881d0614d2ce3918e

@onekb onekb added the bug Something isn't working label Apr 4, 2024
@limingxinleo limingxinleo added this to the v3.2 milestone Apr 8, 2024
@assert6
Copy link
Member

assert6 commented May 9, 2024

开启aspect 看下runtime 里面的代理类, 这个不太好搞, trait 构造函数没法parent:: 调用, 要处理有点麻烦

@onekb
Copy link
Contributor Author

onekb commented May 9, 2024

<?php

declare (strict_types=1);
namespace EasyWeChat\OpenWork;

use EasyWeChat\Kernel\Contracts\AccessToken as AccessTokenInterface;
use EasyWeChat\Kernel\Contracts\Server as ServerInterface;
use EasyWeChat\Kernel\Exceptions\HttpException;
use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient;
use EasyWeChat\Kernel\HttpClient\Response;
use EasyWeChat\Kernel\Traits\InteractWithCache;
use EasyWeChat\Kernel\Traits\InteractWithClient;
use EasyWeChat\Kernel\Traits\InteractWithConfig;
use EasyWeChat\Kernel\Traits\InteractWithHttpClient;
use EasyWeChat\Kernel\Traits\InteractWithServerRequest;
use EasyWeChat\OpenWork\Contracts\Account as AccountInterface;
use EasyWeChat\OpenWork\Contracts\Application as ApplicationInterface;
use EasyWeChat\OpenWork\Contracts\SuiteTicket as SuiteTicketInterface;
use Overtrue\Socialite\Contracts\ProviderInterface as SocialiteProviderInterface;
use Overtrue\Socialite\Providers\OpenWeWork;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use function array_merge;
class Application implements ApplicationInterface
{
    use \Hyperf\Di\Aop\ProxyTrait;
    use \Hyperf\Di\Aop\PropertyHandlerTrait;
    function __construct(\EasyWeChat\Kernel\Contracts\Config|array $config)
    {
        $this->__handlePropertyHandler(__CLASS__);
    }
    use InteractWithCache;
    use InteractWithClient;
    use InteractWithConfig;
    use InteractWithHttpClient;
    use InteractWithServerRequest;
    protected ?ServerInterface $server = null;
    protected ?AccountInterface $account = null;
    protected ?Encryptor $encryptor = null;
    protected ?SuiteEncryptor $suiteEncryptor = null;
    protected ?SuiteTicketInterface $suiteTicket = null;
    protected ?AccessTokenInterface $accessToken = null;
    protected ?AccessTokenInterface $suiteAccessToken = null;
    protected ?AuthorizerAccessToken $authorizerAccessToken = null;
    public function getAccount() : AccountInterface
    {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants