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:
Nestor Soriano 2020-10-02 09:45:09 +02:00
parent 53d33457e3
commit 7485b9165f
7 changed files with 7 additions and 7 deletions

View File

@ -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;
}

View File

@ -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 ] ) ) ) {

View File

@ -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 ] ) ) ) {

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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 );