Skip to content

Commit 9fa89dd

Browse files
committed
Add RendererInterface::getResultForIdenticals()
Replacement for the deprecated AbstractRenderer::getIdenticalResult(). Signed-off-by: Jack Cherng <jfcherng@gmail.com>
1 parent b781125 commit 9fa89dd

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

UPGRADING/UPGRADING_v6.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ there is no breaking change for you so you do not have to do anything.
3434
- If you call `Differ::getGroupedOpcodes()` by yourself,
3535
you must call `Differ::finalize()` before it.
3636

37+
- Add `RendererInterface::getResultForIdenticals()`.
38+
`AbstractRenderer::getResultForIdenticals()` returns an empty string by default.
39+
40+
- Remove the deprecated `AbstractRenderer::getIdenticalResult()`.
41+
Use/implement the `AbstractRenderer::getResultForIdenticals()` instead.
42+
3743

3844
### Internal Breaking Changes
3945

src/Renderer/AbstractRenderer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,9 @@ public function getOptions(): array
101101
}
102102

103103
/**
104-
* Get the renderer result when the old and the new are the same.
105-
*
106-
* @return string
104+
* {@inheritdoc}
107105
*/
108-
public static function getIdenticalResult(): string
106+
public function getResultForIdenticals(): string
109107
{
110108
return '';
111109
}
@@ -119,7 +117,7 @@ public function render(Differ $differ): string
119117

120118
// the "no difference" situation may happen frequently
121119
return $differ->getOldNewComparison() === 0
122-
? static::getIdenticalResult()
120+
? $this->getResultForIdenticals()
123121
: $this->renderWoker($differ);
124122
}
125123

src/Renderer/Html/Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function renderWoker(Differ $differ): string
2828
$changes = $this->getChanges($differ);
2929

3030
if (empty($changes)) {
31-
return self::getIdenticalResult();
31+
return $this->getResultForIdenticals();
3232
}
3333

3434
$html = '<table class="diff diff-html diff-inline">';

src/Renderer/Html/Json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class Json extends AbstractHtml
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
public static function getIdenticalResult(): string
31+
public function getResultForIdenticals(): string
3232
{
3333
return '[]';
3434
}

src/Renderer/Html/SideBySide.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function renderWoker(Differ $differ): string
2828
$changes = $this->getChanges($differ);
2929

3030
if (empty($changes)) {
31-
return self::getIdenticalResult();
31+
return $this->getResultForIdenticals();
3232
}
3333

3434
$html = '<table class="diff diff-html diff-side-by-side">';

src/Renderer/RendererInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
*/
1212
interface RendererInterface
1313
{
14+
/**
15+
* Get the renderer result when the old and the new are the same.
16+
*
17+
* @return string
18+
*/
19+
public function getResultForIdenticals(): string;
20+
1421
/**
1522
* Render the differ and return the result.
1623
*

0 commit comments

Comments
 (0)