digitalrevolution/jbdiff 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digitalrevolution/jbdiff

最新稳定版本:1.2.2

Composer 安装命令:

composer require digitalrevolution/jbdiff

包简介

A diff library based on Jetbrains' implementation

README 文档

README

Minimum PHP Version PHPStan codecov Build Status

JBDiff

A multi-line diff calculation library based on Jetbrains' powerful IDE diff implementation.
https://github.com/JetBrains/intellij-community/tree/master/platform/util/diff/src/com/intellij/diff

Installation

composer require digitalrevolution/jbdiff

Usage

$textBefore:

switch ($strategy) { case RateLimiterConfig::FIXED_WINDOW: return new FixedWindow($this->redisService->getConnection(), $config); case RateLimiterConfig::SLIDING_WINDOW: return new SlidingWindow($this->redisService->getConnection(), $config); default: throw new RuntimeException('Invalid Strategy name.', RuntimeException::UNKNOWN); }

$textAfter:

return match ($strategy) { RateLimiterConfig::FIXED_WINDOW => new FixedWindow($this->redisService->getConnection(), $config), RateLimiterConfig::SLIDING_WINDOW => new SlidingWindow($this->redisService->getConnection(), $config), default => throw new RuntimeException('Invalid Strategy name.'), };

To create the diff:

use DR\JBDiff\ComparisonPolicy; use DR\JBDiff\JBDiff; // line block will contain all the information to partition the strings in removed, unchanged and added parts. $lineBlocks = (new JBDiff())->compare($textBefore, $textAfter, ComparisonPolicy::DEFAULT); // to iterate over the string parts $iterator = new LineBlockTextIterator($textBefore, $textAfter, $lineBlocks);

$iterator formatted to html: docs/example-default.png

with ComparisonPolicy::IGNORE_WHITESPACES docs/example-ignore-whitespace.png

Comparison policies

  • DEFAULT: the standard diff strategy and will take whitespace differences into account.
  • TRIM_WHITESPACES: will take leading and trailing whitespaces out of the diff.
  • IGNORE_WHITESPACES: will take all whitespace differences out of the diff.

Example

To run the example page, start

composer run example

The page will be available at http://localhost:8000/

docs/example-example.png

About us

At 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP and our several shops. Do you want to join us? We are looking for developers.

统计信息

  • 总下载量: 18.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固