Skip to content

Remove type hinting from required parameters, use exceptions

This PR removes the type hinting from setters that are "required". This only touches what I believe are the minimally required parameters, and only for objects that have varying input from Magento.

But why??

PHP's bonkers type checker considers any input not of the explicitly hinted type to be wrong, and this causes a fatal error. Because this is a fatal error, the app dies, which prevents us from getting any useful information bubbled up from code downstream. A concrete example: a logic error caused us to not set a shipping address for store pickup orders. Since we were passing null, PHP's type checker said "NOPE." and everything died. Had we not been type checking, that null would have made its way to CBS, which would have given us an actual error (either in the form of an exception or failure in the response) to log. On the other hand, it is somewhat useful to check what we're passing to CBS, so this takes the middle ground and throws and exception before PHP has the chance to completely kill the process.

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

Merge request reports