radiate-framework / framework

A WordPress plugin and theme framework
https://radiate-framework.github.io/
MIT License
4 stars 0 forks source link

Model Traits #113

Open BenRutlandWeb opened 3 years ago

BenRutlandWeb commented 3 years ago

Is your feature request related to a problem? Please describe. To get the post featured image requires adding boilerplate methods that could be used as a trait

Describe the solution you'd like A trait for things such as the post featured image and author. HasFeaturedImage

Describe alternatives you've considered Adding the methods to the base class

Additional context Perhaps a trait for HasAuthor, HasFeaturedImage, HasAttachment etc.

BenRutlandWeb commented 3 years ago

An issue with this is the developer may create an extending model which would then return the incorrect model. I.e.

Director model extends User model.

Movie::author() method return an instance of User not Director.

The developer would be required to override the traits to change the subclass returned.

BenRutlandWeb commented 2 years ago

Is this solved by PHP8.1 #[\ReturnTypeWillChange]?