Skip to content

Commit 3251263

Browse files
committed
Ensure no error in CustomerInfo when country param is null
In newer version of PHP, if a param has a type hint of `string` but receives `null` instead, it will throw an error. This ensures that a null value is also acceptable in `get_valid_country_code`.
1 parent 49a0c9d commit 3251263

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

includes/Generator/CustomerInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class CustomerInfo {
1111
/**
1212
* Get a country code for a country that the store is set to sell to, or validate a given country code.
1313
*
14-
* @param string $country_code ISO 3166-1 alpha-2 country code. E.g. US, ES, CN, RU etc.
14+
* @param string|null $country_code ISO 3166-1 alpha-2 country code. E.g. US, ES, CN, RU etc.
1515
*
1616
* @return string|\WP_Error
1717
*/
18-
public static function get_valid_country_code( string $country_code = '' ) {
18+
public static function get_valid_country_code( ?string $country_code = '' ) {
1919
$country_code = strtoupper( $country_code );
2020

2121
if ( $country_code && ! WC()->countries->country_exists( $country_code ) ) {

0 commit comments

Comments
 (0)