Skip to content

PHP7-ify Order Header classes, add `ServiceResponseInterface`

This PR PHP7-ifies the Order Header classes and introduces a new interface, ServiceReponseInterface. Sorry, this is a long PR but the changes are fairly small and straight forward.

Why ServiceResponseInterface?

Types in PHP7 still aren't great. Take the following snippet, for example:

public function __construct(AbstractServiceResponse $response = null) {
    ...
}

If we have class OrderServiceResponse extends AbstractServiceResponse { ... }, we should be able to throw an OrderServiceResponse at the constructor and be off to the races, right? Not according to the PHP linter. Subclass aren't taken into account when type-checking, so this generates an error in IntelliJ for mismatched types.

Interfaces to the rescue

We can specify an interface as a type for function arguments, and still get the benefits of code reuse from subclassing. It adds a mostly unnecessary file, but we can still get good type hinting and error checking without having to do much work. This PR is long because I switched the tests for all of the classes over to use the new interface so they would all pass at once.

Please review: @ahoffmann @weizhong-wang @lloyd-carter @KJOYNER

Merge request reports

Loading