swoft-cloud / swoft-component

📦 This is a repository of centralized management of all swoft core components
https://www.swoft.org
Apache License 2.0
96 stars 107 forks source link

Resolve inject type from reflection property type for php 7.4 #579

Open lifinsky opened 4 years ago

lifinsky commented 4 years ago

https://github.com/swoft-cloud/swoft-component/blob/b60c4f5b539567f7092bacd9e0cd41ed883717af/src/bean/src/Annotation/Parser/InjectParser.php#L50

https://www.php.net/manual/reflectionproperty.gettype.php For example:

/**
 * @Inject()
 */
private SomeInterface $someProperty;

Instead of

/**
 * @Inject(SomeInterface::class)
 */
private SomeInterface $someProperty;

Or more ugly

/**
 * @var SomeInterface
 */
private SomeInterface $someProperty;