Skip to content

Implemented JavaSe9\Optional - #60

Merged
petrknap merged 1 commit into
mainfrom
java-bump
Oct 29, 2026
Merged

petrknap merged 1 commit into
mainfrom
java-bump

Conversation

@petrknap

@petrknap petrknap commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner
  • This pull request does not contain any breaking change.
  • I asked the AI to briefly summarize, use and improve the feature(s), and I'm okay with the output:

This pull request successfully expands the library's compatibility and feature parity from Java SE 8 to include Java SE 9 Optional methods (ifPresentOrElse and or), while maintaining strict alignment with official specifications and robust test coverage.


🌟 Key Changes & Highlights

  1. Java SE 9 Compliance Added:
  • Introduced the PetrKnap\Optional\JavaSe9\Optional interface, extending JavaSe8\Optional.
  • Implemented ifPresentOrElse(callable $action, callable $emptyAction) and or(callable $supplier) methods in the core Optional abstract class and OptionalOverrides trait.
  1. Testing Infrastructure Expansion:
  • Added tests/JavaSe9/OptionalTest.java and tests/JavaSe9/OptionalTestCase.php to dynamically test Java SE 9 behavior via translated PHPUnit assertions, mirroring the Java Se 8 testing approach.
  • Updated GitHub Actions workflow (java-test.yaml) to run test suites across both tests/JavaSe8 and tests/JavaSe9 matrix directories.
  1. Static Analysis & IDE Support:
  • Updated phpdoc_check.php with comprehensive assertions and generic type checks for ifPresentOrElse and or.
  • Added test coverage in IdeTest.php to ensure auto-completion and static analysis flow work properly.

🔍 Code Quality & Architecture Feedback

  • Interface Segregation: Separating JavaSe9\Optional from JavaSe8\Optional cleanly distinguishes features by their Java version specification.
  • Trait Support: OptionalOverrides correctly delegates the new or() method to ensure custom optional implementations maintain fluent return types (self).
  • Test Architecture: Reusing the Java-to-PHP assertion translation pattern via data providers (OptionalTestCase) guarantees behavioral sync with the upstream Java specification.

✅ Recommendation

Approve and Merge. The implementation is clean, well-tested, adheres to project conventions, and successfully broadens Java SE version compliance without introducing breaking changes.

@petrknap petrknap self-assigned this Oct 28, 2026
@petrknap petrknap added the enhancement New feature or request label Oct 28, 2026
@petrknap
petrknap marked this pull request as ready for review October 29, 2026 16:48
@petrknap
petrknap merged commit 212e762 into main Oct 29, 2026
4 checks passed
@petrknap
petrknap deleted the java-bump branch October 29, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant