1 | <?php |
||
67 | class ModuleConflictDetector |
||
68 | { |
||
69 | /** |
||
70 | * @var OverrideGraph |
||
71 | */ |
||
72 | private $overrideGraph; |
||
73 | |||
74 | /** |
||
75 | * @var bool[][] |
||
76 | */ |
||
77 | private $tokens = array(); |
||
78 | |||
79 | /** |
||
80 | * Creates a new conflict detector. |
||
81 | * |
||
82 | * @param OverrideGraph|null $overrideGraph The graph indicating which |
||
83 | * module is overridden by which |
||
84 | * other module. |
||
85 | */ |
||
86 | 73 | public function __construct(OverrideGraph $overrideGraph = null) |
|
90 | |||
91 | /** |
||
92 | * Claims a token for a module. |
||
93 | * |
||
94 | * @param int|string $token The claimed token. Can be any integer or |
||
95 | * string. |
||
96 | * @param string $moduleName The module name. |
||
97 | */ |
||
98 | 64 | public function claim($token, $moduleName) |
|
106 | |||
107 | /** |
||
108 | * Releases a module's claim for a token. |
||
109 | * |
||
110 | * @param int|string $token The claimed token. Can be any integer or |
||
111 | * string. |
||
112 | * @param string $moduleName The module name. |
||
113 | */ |
||
114 | 16 | public function release($token, $moduleName) |
|
118 | |||
119 | /** |
||
120 | * Checks the passed tokens for conflicts. |
||
121 | * |
||
122 | * If no tokens are passed, all tokens are checked. |
||
123 | * |
||
124 | * A conflict is returned for every token that is claimed by two modules |
||
125 | * that are not connected by an edge in the override graph. In other words, |
||
126 | * if two modules A and B claim the same token, an edge must exist from A |
||
127 | * to B (A is overridden by B) or from B to A (B is overridden by A). |
||
128 | * Otherwise a conflict is returned. |
||
129 | * |
||
130 | * @param int[]|string[]|null $tokens The tokens to check. If `null`, all |
||
|
|||
131 | * claimed tokens are checked for |
||
132 | * conflicts. You are advised to pass |
||
133 | * tokens if possible to improve the |
||
134 | * performance of the conflict detection. |
||
135 | * |
||
136 | * @return ModuleConflict[] The detected conflicts. |
||
137 | */ |
||
138 | 73 | public function detectConflicts(array $tokens = null) |
|
175 | } |
||
176 |