Skip to content

Improve robustness: exception consistency, defensive parsing, type safety#17

Merged
loevgaard merged 2 commits into2.xfrom
feature/robustness-improvements
Apr 13, 2026
Merged

Improve robustness: exception consistency, defensive parsing, type safety#17
loevgaard merged 2 commits into2.xfrom
feature/robustness-improvements

Conversation

@loevgaard
Copy link
Copy Markdown
Member

Summary

  • NoResultException now implements ExceptionInterface, fixing a gap where it couldn't be caught via the SDK's catch-all interface
  • ParcelShop::createFromStdClass() uses null-coalescing defaults for optional SOAP properties (Streetname2, Telephone, DistanceMetersAsTheCrowFlies), preventing crashes on incomplete responses
  • Type narrowing via casts and instanceof checks across Client, ParcelShop, and OpeningHours reduces PHPStan baseline from 88 → 83 errors
  • Consistent getSoapClient() usage in Client::parseException() instead of direct property access
  • Extracted mapParcelShops() helper with proper stdClass type checks
  • Simplified Client catch blocks — GLS uses SOAP faults (500) for normal "not found" scenarios

Test plan

  • All existing tests pass (11 tests, 64 assertions)
  • New test: NoResultExceptionTest verifies ExceptionInterface contract
  • New test: ParcelShopTest::it_parses_class_with_missing_optional_properties
  • PHPStan passes at max level with reduced baseline
  • ECS code style passes
  • Backwards compatibility check passes (no public API changes)

…fety

- NoResultException now implements ExceptionInterface (fixes catch-all gap)
- ParcelShop::createFromStdClass() uses null-coalescing for optional SOAP
  properties (Streetname2, Telephone, DistanceMetersAsTheCrowFlies)
- Type narrowing via casts and instanceof checks in Client, ParcelShop,
  and OpeningHours to reduce PHPStan baseline (88 → 83 errors)
- Consistent getSoapClient() usage in Client::parseException()
- Extract mapParcelShops() helper with proper stdClass type checks
- Simplify Client catch blocks (GLS uses 500 for "not found" scenarios)
- Add tests for missing optional properties and exception interface
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 84.44444% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.98%. Comparing base (fdf589d) to head (917d34b).
⚠️ Report is 3 commits behind head on 2.x.

Files with missing lines Patch % Lines
src/Client/Client.php 75.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x      #17      +/-   ##
============================================
+ Coverage     75.71%   83.98%   +8.26%     
+ Complexity       79       74       -5     
============================================
  Files            10       10              
  Lines           210      206       -4     
============================================
+ Hits            159      173      +14     
+ Misses           51       33      -18     

☔ 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.

…entFactory

- OpeningHoursTest: createFromStdClass parsing and constructor
- ResponseTest: 200, 404, 500 status code parsing
- ExceptionTest: all 5 exception classes implement ExceptionInterface
- SoapClientFactoryTest: creates SoapClient with and without options
- Remove standalone NoResultExceptionTest (consolidated into ExceptionTest)

Test count: 11 → 22, assertions: 64 → 97
@loevgaard loevgaard merged commit d87753c into 2.x Apr 13, 2026
24 checks passed
@loevgaard loevgaard deleted the feature/robustness-improvements branch April 13, 2026 09:52
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