Skip to content

Make java encoding static - #32

Merged
pavog merged 1 commit into
masterfrom
make-java-encoding-static
Nov 27, 2026
Merged

pavog merged 1 commit into
masterfrom
make-java-encoding-static

Conversation

@pavog

@pavog pavog commented Nov 27, 2026

Copy link
Copy Markdown
Member

Before, JavaEncoding was a singleton: callers had to use JavaEncoding::getInstance()->encode() and ->decode().
The class has no state, so the instance only added a step, and getInstance() had no visibility modifier.

This PR makes encode() and decode() static and removes getInstance() and the instance property.
The class is final, because there is nothing left to override.
The serializer, the deserializer and the tests call the static methods.
The README lists the change in the upgrade section.

Deliberate decisions:
The conversion code is unchanged, only the method signatures and their phpdoc changed.

Not covered:
The class stays in the Aternos\Nbt\String namespace.

Changes

  • make JavaEncoding::encode() and decode() static
  • remove JavaEncoding::getInstance()
  • make JavaEncoding final
  • list the change in the README

@pavog
pavog requested a review from KurtThiemann November 27, 2026 13:06
@pavog
pavog merged commit 7752cfa into master Nov 27, 2026
4 checks passed
@pavog
pavog deleted the make-java-encoding-static branch November 27, 2026 13:35
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