File tree Expand file tree Collapse file tree 3 files changed +10
-13
lines changed Expand file tree Collapse file tree 3 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,6 @@ there is no breaking change for you so you do not have to do anything.
31
31
$result = $renderer->render($differ); // <-- this has been changed
32
32
```
33
33
34
- - If you call `Differ::getGroupedOpcodes()` by yourself,
35
- you must call `Differ::finalize()` before it.
36
-
37
34
- Add `RendererInterface::getResultForIdenticals()`.
38
35
`AbstractRenderer::getResultForIdenticals()` returns an empty string by default.
39
36
Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ public function getOptions(): array
198
198
*/
199
199
public function getOldNewComparison (): int
200
200
{
201
- return $ this ->oldNewComparison ;
201
+ return $ this ->finalize ()-> oldNewComparison ;
202
202
}
203
203
204
204
/**
@@ -223,6 +223,8 @@ public static function getInstance(): self
223
223
*/
224
224
public function getGroupedOpcodes (): array
225
225
{
226
+ $ this ->finalize ();
227
+
226
228
if (!empty ($ this ->groupedOpcodes )) {
227
229
return $ this ->groupedOpcodes ;
228
230
}
@@ -232,17 +234,17 @@ public function getGroupedOpcodes(): array
232
234
}
233
235
234
236
/**
235
- * Claim this class has settled down which means properties will not
236
- * be changed before doing diff calculations .
237
+ * Claim this class has settled down and we could calculate cached
238
+ * properties by current properties .
237
239
*
238
- * Properties will be re-propagated to other classes. This method must be
239
- * re-called after any property changed before doing calculations .
240
+ * This method must be called before accessing cached properties to
241
+ * make suer that you will not get a outdated cached value .
240
242
*
241
- * This method is called in AbstractRenderer::render() automatically.
243
+ * @internal
242
244
*
243
245
* @return self
244
246
*/
245
- public function finalize (): self
247
+ private function finalize (): self
246
248
{
247
249
if ($ this ->isCacheDirty ) {
248
250
$ this ->resetCachedResults ();
Original file line number Diff line number Diff line change @@ -111,10 +111,8 @@ public function getResultForIdenticals(): string
111
111
/**
112
112
* {@inheritdoc}
113
113
*/
114
- public function render (Differ $ differ ): string
114
+ final public function render (Differ $ differ ): string
115
115
{
116
- $ differ ->finalize ();
117
-
118
116
// the "no difference" situation may happen frequently
119
117
return $ differ ->getOldNewComparison () === 0
120
118
? $ this ->getResultForIdenticals ()
You can’t perform that action at this time.
0 commit comments