Fix dynamic property creation warning in `class-woocommerce.php` (#36545)
Declares $api as a public property to the WooCommerce class in order to avoid a deprecation warning that will eventually be an error in upcoming PHP versions.
This commit is contained in:
parent
a274057a6e
commit
7ef4fef53a
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Define a public `api` property in the WooCommerce class to prevent a PHP deprecation warning
|
|
@ -65,6 +65,13 @@ final class WooCommerce {
|
|||
*/
|
||||
public $query = null;
|
||||
|
||||
/**
|
||||
* API instance
|
||||
*
|
||||
* @var WC_API
|
||||
*/
|
||||
public $api;
|
||||
|
||||
/**
|
||||
* Product factory instance.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Unit tests for the WooCommerce class.
|
||||
*/
|
||||
class WooCommerce_Test extends \WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Test that the $api property is defined, public and initialized correctly.
|
||||
*/
|
||||
public function test_api_property(): void {
|
||||
$property = new ReflectionProperty( WooCommerce::class, 'api' );
|
||||
|
||||
$this->assertTrue( $property->isPublic() );
|
||||
$this->assertInstanceOf( WC_API::class, $property->getValue( WC() ) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue