Skip to content

[Feature][BC break] Allow creating diffs from array and shift URL generation to DiffEntry #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025

Conversation

IonBazan
Copy link
Owner

@IonBazan IonBazan commented Apr 16, 2025

These changes are to make it easier to reuse this project as dependency as demonstrated in https://github.com/lyrixx/composer-diff. If you haven't checked it out yet, I strongly recommend you to do so - it's very useful if you don't have access to your PHP interpreter locally.

From user-perspective, there are no behavior changes except for json formatter. This refactoring is just opening up some classes to make it easier to integrate with this project.

  • Shift UrlGenerator logic calls from Formatters to DiffEntry - this dramatically reduces complexity of each formatter and makes them more consistent. It also allows using DiffEntry objects in other applications.
  • Allows generating the diff from pre-existing array and not just files - this actually could make it easier to test but also allows the web version to use a simpler API
  • DiffEntry is now much more powerful - it allows to fetch all details like versions, licenses and URLs in a really simple way.
  • BC break: DiffEntry now requires passing $urlGenerator before $direct (should be fine if you haven't provided the second argument.
  • BC break: Using custom URL generators requires calling PackageDiff::setUrlGenerator() but the call is optional - it uses default GeneratorContainer out of the box.
  • BC break: licenses key in json formatter is now an array instead of string|null @giggsey you might need to adjust your flows if you rely on this key

Note: All classes in this project are to be treated as internal as no BC promise is provided so far and they might change without prior notice. Backward compatibility is mostly provided for user-facing components like CLI arguments and formatters output.

As always, all PHP versions from 5.3 all the way to 8.5+ are supported and 100% code coverage is maintained.

@IonBazan IonBazan self-assigned this Apr 16, 2025
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (347c63c) to head (7692708).

Additional details and impacted files
@@             Coverage Diff             @@
##                main       #43   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       241       242    +1     
===========================================
  Files             21        21           
  Lines            704       696    -8     
===========================================
- Hits             704       696    -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@IonBazan IonBazan merged commit 5eb28ba into main Apr 18, 2025
40 checks passed
@IonBazan IonBazan deleted the feature/web-refactor branch April 18, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant