php - More Restrictive Child Interfaces -


i have particular use-case i'd child interface have constraints on return values parent interface not. so, example:

interface foointerface {     /**      * @return mixed      */     public function foo(); }  interface integeronlyfoointerface extends foointerface {     /**      * @return integer      */     public function foo(); } 

in example, integeronlyfoointerface return integers call foo(). because integers scalars, doesn't break contract inherited foointerface, , satisfies liskov substitution principle, integeronlyfoointerfaces may used anywhere requires foointerface instance without breaking in application.

there places i'd enforce integer return value part of code's contract, though, in places typehint integeronlyfoointerface.

this seems rather kludgy, though, , i'm wondering if i'm going problem wrong way, or if it's on up-and-up.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -