PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.0
Defender Security – Malware Scanner, Login Security & Firewall v5.7.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / lib / packages / DI / Definition / ObjectDefinition / MethodInjection.php

MethodInjection.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.0, at lib/packages/DI/Definition/ObjectDefinition/MethodInjection.php

77 lines 1.7 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 WPMU_DEV\Defender\Vendor\DI\Definition\ObjectDefinition;
6
7 use WPMU_DEV\Defender\Vendor\DI\Definition\Definition;
8
9 /**
10 * Describe an injection in an object method.
11 *
12 * @author Matthieu Napoli <[email protected]>
13 */
14 class MethodInjection implements Definition
15 {
16 /**
17 * @param mixed[] $parameters
18 */
19 public function __construct(
20 private string $methodName,
21 private array $parameters = [],
22 ) {
23 }
24
25 public static function constructor(array $parameters = []) : self
26 {
27 return new self('__construct', $parameters);
28 }
29
30 public function getMethodName() : string
31 {
32 return $this->methodName;
33 }
34
35 /**
36 * @return mixed[]
37 */
38 public function getParameters() : array
39 {
40 return $this->parameters;
41 }
42
43 /**
44 * Replace the parameters of the definition by a new array of parameters.
45 */
46 public function replaceParameters(array $parameters) : void
47 {
48 $this->parameters = $parameters;
49 }
50
51 public function merge(self $definition) : void
52 {
53 // In case of conflicts, the current definition prevails.
54 $this->parameters += $definition->parameters;
55 }
56
57 public function getName() : string
58 {
59 return '';
60 }
61
62 public function setName(string $name) : void
63 {
64 // The name does not matter for method injections
65 }
66
67 public function replaceNestedDefinitions(callable $replacer) : void
68 {
69 $this->parameters = array_map($replacer, $this->parameters);
70 }
71
72 public function __toString() : string
73 {
74 return sprintf('method(%s)', $this->methodName);
75 }
76 }
77