Skip to content

PHP 8.4 Compat: Throw UnexpectedValueException for calls to undefined methods.#1109

Closed
peterwilsoncc wants to merge 1 commit intogoogleads:mainfrom
peterwilsoncc:fix/trigger-user-error-deprecation
Closed

PHP 8.4 Compat: Throw UnexpectedValueException for calls to undefined methods.#1109
peterwilsoncc wants to merge 1 commit intogoogleads:mainfrom
peterwilsoncc:fix/trigger-user-error-deprecation

Conversation

@peterwilsoncc
Copy link
Copy Markdown

@peterwilsoncc peterwilsoncc commented Oct 9, 2025

This is to cover a deprecation in PHP 8.4 Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, per the PHP 8.4 migration guide.

All calls to trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR); are replaced by throwing an exception throw new \UnexpectedValueException('Call to undefined method ' . __CLASS__ . "::$method()");

This will continue triggering a fatal error for the library. I'm happy to bikeshed the correct type of exception to throw here, I went back and forth on a simple Error but decided against it in the end.

Note, this comes out of a ticket for woocommerce/google-listings-and-ads#3117, a WooCommerce/WordPress plugin making use of the dev-legacy-v31.0.1 release. This is due to the need to support PHP 7.4.

If this change is acceptable to you all, it would be great if you could backport it to a v31 branch. I'm happy to create a pull request for this if you wish.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Oct 9, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@peterwilsoncc peterwilsoncc changed the title Throw UnexpectedValueException for calls to undefined methods. PHP 8.4 Compat: Throw UnexpectedValueException for calls to undefined methods. Oct 9, 2025
@ajs424
Copy link
Copy Markdown
Contributor

ajs424 commented Mar 31, 2026

Since there hasn't been any updates on this PR in quite some time I'll go ahead and close it out. If this is still a relevant concern with the current version /legacy branch of the PHP client library please feel free to reopen or create an updated PR.

@ajs424 ajs424 closed this Mar 31, 2026
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