Clarkson-Core icon indicating copy to clipboard operation
Clarkson-Core copied to clipboard

Objects::get_object() can't be force to return `Clarkson_Object`

Open jmslbam opened this issue 3 years ago • 0 comments

Objects::get_object() can't be forced to return Clarkson_Object because you can overwrite the the Object Type via the clarkson_core_create_object_callback filter.

The inline documentation gives an example that you could return the result of e.g. wc_get_order which is a WC_Order or in our case wc_get_product why this filter was initialy introduced for the use-case that @NielsdeBlaauw had. wc_get_product returns something base on WC_Product.

Method get_object: https://github.com/level-level/Clarkson-Core/blob/master/src/Objects.php#L168 Filter clarkson_core_create_object_callback https://github.com/level-level/Clarkson-Core/blob/master/src/Objects.php#L214-L241 Original Issue with explaination: https://github.com/level-level/Clarkson-Core/issues/131

Easy fix would be to remove the return type, other option would be that return type should be at least an object (since 7.2) https://www.php.net/manual/en/language.types.declarations.php

jmslbam avatar Feb 07 '22 14:02 jmslbam