Convert optional-before-required arguments to required.
In PHP 8 required parameters after optional parameters in function/method signatures trigger a deprecation notice. These type of parameters are pointless since a value needs to always be provided for them anyway, so they are actually de-facto required. This commit converts all these not-so-optional parameters into truly required parameters by removing their default values.
This commit is contained in:
parent
53d33457e3
commit
7485b9165f
|
@ -539,7 +539,7 @@ final class WC_Cart_Totals {
|
|||
* @param string $key Total name you want to set.
|
||||
* @param int $total Total to set.
|
||||
*/
|
||||
protected function set_total( $key = 'total', $total ) {
|
||||
protected function set_total( $key, $total ) {
|
||||
$this->totals[ $key ] = $total;
|
||||
}
|
||||
|
||||
|
|
|
@ -859,7 +859,7 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
* @param string $address Name of address to set. billing or shipping.
|
||||
* @param mixed $value Value of the prop.
|
||||
*/
|
||||
protected function set_address_prop( $prop, $address = 'billing', $value ) {
|
||||
protected function set_address_prop( $prop, $address, $value ) {
|
||||
if ( array_key_exists( $prop, $this->data[ $address ] ) ) {
|
||||
if ( true === $this->object_read ) {
|
||||
if ( $value !== $this->data[ $address ][ $prop ] || ( isset( $this->changes[ $address ] ) && array_key_exists( $prop, $this->changes[ $address ] ) ) ) {
|
||||
|
|
|
@ -983,7 +983,7 @@ class WC_Order extends WC_Abstract_Order {
|
|||
* @param string $address Name of address to set. billing or shipping.
|
||||
* @param mixed $value Value of the prop.
|
||||
*/
|
||||
protected function set_address_prop( $prop, $address = 'billing', $value ) {
|
||||
protected function set_address_prop( $prop, $address, $value ) {
|
||||
if ( array_key_exists( $prop, $this->data[ $address ] ) ) {
|
||||
if ( true === $this->object_read ) {
|
||||
if ( $value !== $this->data[ $address ][ $prop ] || ( isset( $this->changes[ $address ] ) && array_key_exists( $prop, $this->changes[ $address ] ) ) ) {
|
||||
|
|
|
@ -78,7 +78,7 @@ class WC_REST_Data_Continents_Controller extends WC_REST_Data_Controller {
|
|||
* @param WP_REST_Request $request Request data.
|
||||
* @return array|mixed Response data, ready for insertion into collection data.
|
||||
*/
|
||||
public function get_continent( $continent_code = false, $request ) {
|
||||
public function get_continent( $continent_code, $request ) {
|
||||
$continents = WC()->countries->get_continents();
|
||||
$countries = WC()->countries->get_countries();
|
||||
$states = WC()->countries->get_states();
|
||||
|
|
|
@ -77,7 +77,7 @@ class WC_REST_Data_Countries_Controller extends WC_REST_Data_Controller {
|
|||
* @param WP_REST_Request $request Request data.
|
||||
* @return array|mixed Response data, ready for insertion into collection data.
|
||||
*/
|
||||
public function get_country( $country_code = false, $request ) {
|
||||
public function get_country( $country_code, $request ) {
|
||||
$countries = WC()->countries->get_countries();
|
||||
$states = WC()->countries->get_states();
|
||||
$data = array();
|
||||
|
|
|
@ -86,7 +86,7 @@ class WC_REST_Data_Currencies_Controller extends WC_REST_Data_Controller {
|
|||
* @param WP_REST_Request $request Request data.
|
||||
* @return array|mixed Response data, ready for insertion into collection data.
|
||||
*/
|
||||
public function get_currency( $code = false, $request ) {
|
||||
public function get_currency( $code, $request ) {
|
||||
$currencies = get_woocommerce_currencies();
|
||||
$data = array();
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class WC_API_Unit_Test_Case extends WC_Unit_Test_Case {
|
|||
* @param WP_Error $response Response to assert.
|
||||
* @param string $message optional message to render when assertion fails.
|
||||
*/
|
||||
public function assertHasAPIError( $code, $status = null, $response, $message = '' ) {
|
||||
public function assertHasAPIError( $code, $status, $response, $message = '' ) {
|
||||
|
||||
$this->assertWPError( $response, $message );
|
||||
|
||||
|
|
Loading…
Reference in New Issue