1.8 KiB
Upgrading to v6
For Simple Users
If you only use the DiffHelper
and built-in Renderer
s,
there is no breaking change for you so you do not have to do anything.
Breaking Changes for Normal Users
-
The
Diff
class has been renamed asDiffer
. It should be relatively easy to adapt to this by changing the class name. -
The term
template
has been renamed asrenderer
. Some examples are:- Method
DiffHelper::getRenderersInfo()
- Method
DiffHelper::getAvailableRenderers()
- Constant
RendererConstant::RENDERER_TYPES
- Constant
AbstractRenderer::IS_TEXT_RENDERER
- Method
-
Now a
Renderer
has arender()
method, but aDiffer
does not. (because it makes more sense saying a renderer would render something) If you use those classes by yourself, it should be written like below.use Jfcherng\Diff\Differ; use Jfcherng\Diff\Factory\RendererFactory; $differ = new Differ(explode("\n", $old), explode("\n", $new), $diffOptions); $renderer = RendererFactory::make($rendererName, $rendererOptions); $result = $renderer->render($differ); // <-- this line has been changed
Breaking Changes for Customized Renderer Developers
-
Remove the deprecated
AbstractRenderer::getIdenticalResult()
and addRendererInterface::getResultForIdenticals()
. The returned value will be directly used before actually starting to calculate diff if we find that the two strings are the same.AbstractRenderer::getResultForIdenticals()
returns an empty string by default. -
Now a
Renderer
should implementprotected function renderWorker(Differ $differ): string
rather than the previouspublic function render(): string
. Note that$this->diff
no longer works inRenderer
s as it is now injected as a parameter toRenderer::renderWorker()
.