1.8 KiB
Upgrading to v6
For Simple Users
If you only use the DiffHelper and built-in Renderers,
there is no breaking change for you so you do not have to do anything.
Breaking Changes for Normal Users
-
The
Diffclass has been renamed asDiffer. It should be relatively easy to adapt to this by changing the class name. -
The term
templatehas been renamed asrenderer. Some examples are:- Method
DiffHelper::getRenderersInfo() - Method
DiffHelper::getAvailableRenderers() - Constant
RendererConstant::RENDERER_TYPES - Constant
AbstractRenderer::IS_TEXT_RENDERER
- Method
-
Now a
Rendererhas arender()method, but aDifferdoes 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
Renderershould implementprotected function renderWorker(Differ $differ): stringrather than the previouspublic function render(): string. Note that$this->diffno longer works inRenderers as it is now injected as a parameter toRenderer::renderWorker().