Remove trigger_error from WooCommerce::__set (#52764)
This commit is contained in:
parent
62eae71618
commit
dd11871983
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: tweak
|
||||||
|
|
||||||
|
Replace trigger_error in WooCommerce::__set with an exception
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue