Closed garak closed 1 year ago
I think ideally the properties would reflect the types from the Packagist API, in terms of whether they are nullable or not. I'm not sure making everything nullable would be an ideal solution.
If you've found an instance of a property that isn't nullable in this SDK where the Packagist API's equivalent is, we would welcome a PR to make that property nullable.
I agree about keeping consistency between API types and internal PHP class types-
I think the problem here is all internal and it's about the consistency of types: the one assigned to the class (that match the API) and the ones resulting in the fromArray
method call (totally unchecked).
I can propose a PR to add a check.
Method
fromArray
of class AbstractResult is not checking for values when assigning them to properties. As a result, any non-nullable property of a child class can raise a TypeError (like the one mentioned in the subject forPackage
class)A possible solution could be making all properties nullable. A better solution could be adding a check inside
fromArray
method, checking that the value is not null before assigning it.