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

Add class constructors #83

Merged
merged 1 commit into from
Oct 3, 2021
Merged

Add class constructors #83

merged 1 commit into from
Oct 3, 2021

Conversation

davidcole1340
Copy link
Owner

Constructor methods can now be specified. They are required if
you want to construct the class from PHP. This replaces the Default
implementation requirement on class objects.

Constructors can return Self or Result<Self, E> where E: Into<PhpException>.

impl<'a, T: RegisteredClass> FromZval<'a> for &'a mut T {
const TYPE: DataType = DataType::Object(Some(T::CLASS_NAME));
// TODO(david): mutable FromZval?
// impl<'a, T: RegisteredClass> FromZval<'a> for &'a mut T {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Zval::object() was changed to return an immutable reference, FromZval can no longer be implemented for &mut T. I think we will need to add a new trait FromZvalMut, and then any type which implements FromZval can implement FromZvalMut.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be done in a later PR as it will require keeping a mutable Zval inside Arg

@davidcole1340 davidcole1340 merged commit 125ec3b into master Oct 3, 2021
@davidcole1340 davidcole1340 deleted the constructor branch October 3, 2021 06:53
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.

2 participants