1: <?php declare(strict_types = 1);
2:
3: namespace PHPStan\DependencyInjection;
4:
5: use Attribute;
6:
7: /**
8: * Generates concrete factory implementation based on the passed interface name.
9: *
10: * This looks at and compares constructor of the class with the attribute
11: * against the "create" method of the passed interface.
12: *
13: * It subtracts "create" parameters from the constructor parameters.
14: * And the rest is autowired from the dependency injection container.
15: *
16: * Works thanks to https://github.com/ondrejmirtes/composer-attribute-collector
17: * and AutowiredAttributeServicesExtension.
18: *
19: * @api
20: */
21: #[Attribute(flags: Attribute::TARGET_CLASS)]
22: final class GenerateFactory
23: {
24:
25: /**
26: * @api
27: * @param class-string $interface
28: * @param class-string $resultType
29: */
30: public function __construct(public string $interface, public ?string $resultType = null)
31: {
32: }
33:
34: }
35: