Skip to content

bug: Fix ObjectPropertyRipper to handle stdClass objects #65

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 1 commit into from
Jun 5, 2025

Conversation

acoulton
Copy link
Member

@acoulton acoulton commented Jun 5, 2025

Currently, attempting to rip from a stdClass will fail with an error that it is not possible to bind a closure to the scope of an internal object.

It should not normally be necessary to call any of the rip methods for a stdClass, because by definition all props are public so the result will be the same as $vars = (array) $object.

However, it can cause a problem if e.g. calling the ObjectPropertyRipper recursively to dump an entire object graph where the tree may include some stdClass instances. Our methods are typed to accept any kind of object, so should work with stdClass rather than requiring the caller to check this externally.

Currently, attempting to rip from a `stdClass` will fail with
an error that it is not possible to bind a closure to the
scope of an internal object.

It should not normally be necessary to call any of the
`rip` methods for a `stdClass`, because by definition
all props are public so the result will be the same
as `$vars = (array) $object`.

However, it can cause a problem if e.g. calling the
ObjectPropertyRipper recursively to dump an entire
object graph where the tree may include some stdClass
instances. Our methods are typed to accept any kind of
object, so should work with `stdClass` rather than
requiring the caller to check this externally.
@acoulton acoulton requested a review from craig410 June 5, 2025 10:03
@acoulton acoulton merged commit 0c2be48 into 2.x Jun 5, 2025
4 checks passed
@acoulton acoulton deleted the 2.x-feat-rip-stdclass branch June 5, 2025 10:11
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