Remove trigger_error from WooCommerce::__set (#52764)

This commit is contained in:
Néstor Soriano 2024-11-13 16:24:58 +01:00 committed by GitHub
parent 62eae71618
commit dd11871983
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Replace trigger_error in WooCommerce::__set with an exception

View File

@ -209,13 +209,13 @@ final class WooCommerce {
* *
* @param string $key Property name. * @param string $key Property name.
* @param mixed $value Property value. * @param mixed $value Property value.
* @throws Exception Attempt to access a property that's private or protected.
*/ */
public function __set( string $key, $value ) { public function __set( string $key, $value ) {
if ( 'api' === $key ) { if ( 'api' === $key ) {
$this->api = $value; $this->api = $value;
} elseif ( property_exists( $this, $key ) ) { } elseif ( property_exists( $this, $key ) ) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error throw new Exception( 'Cannot access private property ' . __CLASS__ . '::$' . esc_html( $key ) );
trigger_error( 'Cannot access private property WooCommerce::$' . esc_html( $key ), E_USER_ERROR );
} else { } else {
$this->$key = $value; $this->$key = $value;
} }