Skip to content

Update some object handlers to return zend_result #132

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Book/php7/classes_objects/object_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Here are all the object handlers with their signature and a small description.
disallow manual construction by throwing an error in the handler.

.. c:member::
int count_elements(zend_object *object, zend_long *count)
zend_result count_elements(zend_object *object, zend_long *count)

This is just the internal way of implementing the ``Countable::count`` method. The function returns a
``zend_result`` and assigns the value to the ``zend_long *count`` pointer.
Expand All @@ -71,14 +71,14 @@ Here are all the object handlers with their signature and a small description.
the values are uncomparable ``ZEND_UNCOMPARABLE`` should be returned.

.. c:member::
int cast_object(zend_object *readobj, zval *writeobj, int type)
zend_result cast_object(zend_object *readobj, zval *writeobj, int type)

Internal classes have the ability to implement a custom compare behavior and override casting behavior for all
types. Userland classes on the other hand only have the ability to override object to string casting through
``__toString``.

.. c:member::
int get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only)
zend_result get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only)

This handler is invoked when the object is used as a function, i.e. it is the internal version of ``__invoke``.
The name derives from the fact that its main use is for the implementation of closures (the ``Closure`` class).
Expand Down Expand Up @@ -122,7 +122,7 @@ Here are all the object handlers with their signature and a small description.
longer active, in which case execution of user code may be skipped.

.. c:member::
int do_operation(zend_uchar opcode, zval *result, zval *op1, zval *op2)
zend_result do_operation(zend_uchar opcode, zval *result, zval *op1, zval *op2)

``do_operation`` is an optional handler that will be invoked for various arithmetic and binary operations on
instances of the given class. This allows for operator overloading semantics to be implemented for custom classes.
Expand Down