Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Reasonable model methods and properties are made static #18

Draft
wants to merge 4 commits into
base: release/2.0.0
Choose a base branch
from

Conversation

JasonTheAdams
Copy link
Member

Many of the properties and methods of the Model class are instance properties for no particular reason. The Model::$properties property, for example, is an instance property. But it's really only meant to be defined by the class and then consistent across all subclass instances. In fact, making the properties dynamic on a per-instance basis is an anti-pattern to the model itself, as it's no longer a clearly defined set of data.

The side-effect of these being instance bound is that an instance is required in order to do basic things such as know a model's properties, check if a property is valid, and so forth.

This PR switches a number of properties and methods to be static. Basically those that can be. It updates the interfaces and the Model class itself.

Accessing a static method from an instance (e.g. $model->hasProperty() is supported in PHP and backwards compatible, but the interfaces and property/method overloading obviously aren't. As such, this is a major change and slated for a 2.0.0 release.

To do in this PR:

  • Update the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant