Skip to content

Incorrect error "undefined method" messages #16574

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

Closed
YuanchengJiang opened this issue Oct 24, 2024 · 1 comment
Closed

Incorrect error "undefined method" messages #16574

YuanchengJiang opened this issue Oct 24, 2024 · 1 comment

Comments

@YuanchengJiang
Copy link

Description

The following code:

<?php
$i = new ArrayIterator(array(1,1,1,1,1));
$i = new CachingIterator($i,CachingIterator::FULL_CACHE);
$fusion = $i;
$fusion->load("x");
?>

Resulted in this output:

Fatal error: Uncaught Error: Call to undefined method ArrayIterator::load()

But I expected this output instead (JIT 1215):

Fatal error: Uncaught Error: Call to undefined method CachingIterator::load()

PHP Version

nightly

Operating System

ubuntu 22.04

@nielsdos
Copy link
Member

nielsdos commented Oct 24, 2024

It's related to get_method being able to change the object, I think we should be using orig_obj... So this is also SPL-related as SPL changes the object pointer.

@nielsdos nielsdos self-assigned this Oct 24, 2024
nielsdos added a commit to nielsdos/php-src that referenced this issue Oct 24, 2024
The `get_method` object handler may change the object pointer. SPL does
this in its iterator implementations. This causes the error message
to change to another class which is confusing to the user. JIT handles
this correctly. This patch aligns behaviour with JIT.
@nielsdos nielsdos linked a pull request Oct 24, 2024 that will close this issue
nielsdos added a commit that referenced this issue Oct 25, 2024
* PHP-8.4:
  Fix GH-16574: Incorrect error "undefined method" messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants