PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.5.0
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.5.0
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
betterdocs / includes / Dependencies / DI / Definition / InstanceDefinition.php

InstanceDefinition.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.5.0, at includes/Dependencies/DI/Definition/InstanceDefinition.php

70 lines 1.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 WPDeveloper\BetterDocs\Dependencies\DI\Definition;
6
7 /**
8 * Defines injections on an existing class instance.
9 *
10 * @since 5.0
11 * @author Matthieu Napoli <matthieu@mnapoli.fr>
12 */
13 class InstanceDefinition implements Definition
14 {
15 /**
16 * Instance on which to inject dependencies.
17 *
18 * @var object
19 */
20 private $instance;
21
22 /**
23 * @var ObjectDefinition
24 */
25 private $objectDefinition;
26
27 /**
28 * @param object $instance
29 */
30 public function __construct($instance, ObjectDefinition $objectDefinition)
31 {
32 $this->instance = $instance;
33 $this->objectDefinition = $objectDefinition;
34 }
35
36 public function getName() : string
37 {
38 // Name are superfluous for instance definitions
39 return '';
40 }
41
42 public function setName(string $name)
43 {
44 // Name are superfluous for instance definitions
45 }
46
47 /**
48 * @return object
49 */
50 public function getInstance()
51 {
52 return $this->instance;
53 }
54
55 public function getObjectDefinition() : ObjectDefinition
56 {
57 return $this->objectDefinition;
58 }
59
60 public function replaceNestedDefinitions(callable $replacer)
61 {
62 $this->objectDefinition->replaceNestedDefinitions($replacer);
63 }
64
65 public function __toString()
66 {
67 return 'Instance';
68 }
69 }
70