PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / scope-vendor / php-di / php-di / src / Definition / Helper / AutowireDefinitionHelper.php

AutowireDefinitionHelper.php in The Innovative Form Builder – IvyForms 1.5.1, at backend/scope-vendor/php-di/php-di/src/Definition/Helper/AutowireDefinitionHelper.php

73 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace IvyForms\Vendor\DI\Definition\Helper;
6
7 use IvyForms\Vendor\DI\Definition\AutowireDefinition;
8
9 /**
10 * Helps defining how to create an instance of a class using autowiring.
11 *
12 * @author Matthieu Napoli <[email protected]>
13 */
14 class AutowireDefinitionHelper extends CreateDefinitionHelper
15 {
16 const DEFINITION_CLASS = AutowireDefinition::class;
17
18 /**
19 * Defines a value for a specific argument of the constructor.
20 *
21 * This method is usually used together with annotations or autowiring, when a parameter
22 * is not (or cannot be) type-hinted. Using this method instead of constructor() allows to
23 * avoid defining all the parameters (letting them being resolved using annotations or autowiring)
24 * and only define one.
25 *
26 * @param string|int $parameter Parameter name of position for which the value will be given.
27 * @param mixed $value Value to give to this parameter.
28 *
29 * @return $this
30 */
31 public function constructorParameter($parameter, $value)
32 {
33 $this->constructor[$parameter] = $value;
34
35 return $this;
36 }
37
38 /**
39 * Defines a method to call and a value for a specific argument.
40 *
41 * This method is usually used together with annotations or autowiring, when a parameter
42 * is not (or cannot be) type-hinted. Using this method instead of method() allows to
43 * avoid defining all the parameters (letting them being resolved using annotations or
44 * autowiring) and only define one.
45 *
46 * If multiple calls to the method have been configured already (e.g. in a previous definition)
47 * then this method only overrides the parameter for the *first* call.
48 *
49 * @param string $method Name of the method to call.
50 * @param string|int $parameter Parameter name of position for which the value will be given.
51 * @param mixed $value Value to give to this parameter.
52 *
53 * @return $this
54 */
55 public function methodParameter(string $method, $parameter, $value)
56 {
57 // Special case for the constructor
58 if ($method === '__construct') {
59 $this->constructor[$parameter] = $value;
60
61 return $this;
62 }
63
64 if (! isset($this->methods[$method])) {
65 $this->methods[$method] = [0 => []];
66 }
67
68 $this->methods[$method][0][$parameter] = $value;
69
70 return $this;
71 }
72 }
73