Command: uname -a && php -v && composer info | grep hyperf && php --ri swoole
Linux promote.cache-dns.local 3.10.0-1062.4.3.el7.x86_64 #1 SMP Wed Nov 13 23:58:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
PHP 7.3.5 (cli) (built: May 6 2019 11:38:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies
Do not run Composer as root/super user! See https://getcomposer.org/root for details
hyperf/cache v2.0.0 A cache component for hyperf.
hyperf/command v2.0.0 Command for hyperf
hyperf/config v2.0.0 An independent component that provides configuration container.
hyperf/contract v2.0.0 The contracts of Hyperf.
hyperf/database v2.0.0 A flexible database library.
hyperf/db-connection v2.0.0 A hyperf db connection handler for hyperf/database.
hyperf/devtool v2.0.0 A Devtool for Hyperf.
hyperf/di v2.0.0 A DI for Hyperf.
hyperf/dispatcher v2.0.0 A HTTP Server for Hyperf.
hyperf/event v2.0.0 an event manager that implements PSR-14.
hyperf/exception-handler v2.0.0 Exception handler for hyperf
hyperf/framework v2.0.0 A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.
hyperf/guzzle v2.0.0 Swoole coroutine handler for guzzle
hyperf/http-message v2.0.0 microservice framework base on swoole
hyperf/http-server v2.0.0 A HTTP Server for Hyperf.
hyperf/logger v2.0.0 A logger component for hyperf.
hyperf/memory v2.0.0 An independent component that use to operate and manage memory.
hyperf/model-listener v2.0.0 A model listener for Hyperf.
hyperf/paginator v2.0.0 A paginator component for hyperf.
hyperf/pool v2.0.0 An independent universal connection pool component.
hyperf/process v2.0.0 A process component for hyperf.
hyperf/redis v2.0.0 A redis component for hyperf.
hyperf/server v2.0.0 A base server library for Hyperf.
hyperf/testing v2.0.0 Testing for hyperf
hyperf/utils v2.0.0 A tools package that could help developer solved the problem quickly.
swoole
Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.5.2
Built => Jun 26 2020 10:32:15
coroutine => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.0.2k-fips 26 Jan 2017
http2 => enabled
pcre => enabled
zlib => 1.2.7
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
Execute the command and paste the result below.
Command:
uname -a && php -v && composer info | grep hyperf && php --ri swoole
Description:
父类中 有一个变量
$tool
子类继承之后,使用了Inject
注解 ,然后获取时候,子类中获取到的$tool
是空的同理 @Value注解,在这种情况下也是获取不到配置的
Steps To Reproduce:
默认环境
hyperf-skeleton
新建一个三个类:Base
Foo
Tool
,在命名空间App\Test
下,三个的关系是 Foo 继承与Base ,Tool是依赖入住的对象,代码如下:Base 基类
}
<?php namespace App\Test; class Tool { protected $name = 'tool';
}
<?php namespace App\Test; use Hyperf\Config\Annotation\Value; use Hyperf\Di\Annotation\Inject;
/ / class Foo extends Base { /
@Value("devtool.generator.amqp") */ public $config;
/**
@var Tool */ public $tool;
public function query() { return [$this->config, $this->tool->getName()]; }
}
... public function index() { $foo = make(Foo::class); return [$foo->query()]; } ...
curl 127.0.0.1:9501