Refactor: Reasonable model methods and properties are made static #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Many of the properties and methods of the
Model
class are instance properties for no particular reason. TheModel::$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: