forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerateFactory.php
More file actions
31 lines (26 loc) · 837 Bytes
/
Copy pathGenerateFactory.php
File metadata and controls
31 lines (26 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php declare(strict_types = 1);
namespace PHPStan\DependencyInjection;
use Attribute;
/**
* Generates concrete factory implementation based on the passed interface name.
*
* This looks at and compares constructor of the class with the attribute
* against the "create" method of the passed interface.
*
* It subtracts "create" parameters from the constructor parameters.
* And the rest is autowired from the dependency injection container.
*
* Works thanks to https://github.com/ondrejmirtes/composer-attribute-collector
* and AutowiredAttributeServicesExtension.
*/
#[Attribute(flags: Attribute::TARGET_CLASS)]
final class GenerateFactory
{
/**
* @param class-string $interface
* @param class-string $resultType
*/
public function __construct(public string $interface, public ?string $resultType = null)
{
}
}