Relocate well known packages into alternative php namespaces to resolve conflict with google/protobuf - #37
Open
kafkiansky wants to merge 5 commits into
Open
Relocate well known packages into alternative php namespaces to resolve conflict with google/protobuf#37kafkiansky wants to merge 5 commits into
google/protobuf#37kafkiansky wants to merge 5 commits into
Conversation
…ve conflicts with google/protobuf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thesis is an alternative runtime, so its generated code must be able to live in the same project as the code generated by
google/protobuf. That was impossible as long as both generateGoogle\Protobuf\Any: the class names collide, which is whythesis/protobuf-known-typeshad to declareconflict: google/protobuf, and that conflict, in turn, made it impossible to use packages tied togoogle/protobuf(open-telemetry/*, for instance).This PR teaches the plugin to relocate well known packages into namespaces of its own.
The relocation table is
map.jsonin the repository root. It is bundled into the phar (box.json) and shipped with the composer package, so it applies no matter how the plugin is installed.{ "rules": [ {"from": "google.protobuf.*", "to": "thesis.google.protobuf.*"}, {"from": "google.rpc.Status", "to": "thesis.google.rpc.Status"} ] }Rules are written in terms of protobuf names, not PHP ones — the PHP namespace is derived from the rewritten name exactly the same way it is derived from a package.