Skip to content

Conversation

@davidcole1340
Copy link
Collaborator

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
Collaborator 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
Collaborator 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.

3 participants