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

Summary for ActiveRecord #308

Open
11 of 13 tasks
Tigrov opened this issue May 3, 2024 · 4 comments
Open
11 of 13 tasks

Summary for ActiveRecord #308

Tigrov opened this issue May 3, 2024 · 4 comments
Assignees
Labels
type:enhancement Enhancement

Comments

@Tigrov
Copy link
Member

Tigrov commented May 3, 2024

  • 1. Rename BaseActiveRecord class to AbstractActiveRecord
  • 2. Make AbstractActiveRecord class implements only ActiveRecordInterface
  • 3. Move other interfaces to ActiveRecord class
  • 4. Move implementation of the interfaces to traits
  • 5. Move $properties with magic methods __get(), __set(), __isset(), __unset() to MagicPropertiesTrait and use it in ActiveRecord class
  • 6. Access to properties values inside AbstractActiveRecord via $this->$name only
  • 7. To get a relation query instance of ActiveQueryInterface use method with prefix get and suffix Query, e.g. getOrderQuery(): ActiveQueryInterface instead of getOrder(): ActiveQueryInterface
  • 8. To get a relation value use method with prefix get, e.g. getOrder(): ActiveRecordInterface|null
  • 9. Rename method getRelation(): ActiveQueryInterface to relationQuery(): ActiveQueryInterface
  • 10. Add method to get a value of relation relation(string $name): ActiveRecordInterface|null {return $this->related[$name] ?? null;}
  • 11. Split magical and non-magical implementations
  • 12. Test traits and concrete implementations separately
  • 13. Update documentation
@xepozz
Copy link
Contributor

xepozz commented May 14, 2024

Great ideas, especially with naming for relations. I have a question:
What's the reason to rename attributes to properties?

@Tigrov
Copy link
Member Author

Tigrov commented May 15, 2024

What's the reason to rename attributes to properties?

It was discussed that there is confusion between the $attributes AR property and PHP's #[Attribute].

But it's a good question. Now this looks doubtful due to major changes and needs to be discussed again. Due to the renaming of public methods whose names contain attribute.

@vjik
Copy link
Member

vjik commented May 18, 2024

But it's a good question. Now this looks doubtful due to major changes and needs to be discussed again. Due to the renaming of public methods whose names contain attribute.

Are there any pitfalls here? Rename methods also it looks logically.

@Tigrov
Copy link
Member Author

Tigrov commented May 19, 2024

Are there any pitfalls here? Rename methods also it looks logically.

Discussion about renaming $attributes moved to #343

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

No branches or pull requests

3 participants