Skip to content

Commit

Permalink
Ensure no error in CustomerInfo when country param is null
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
coreymckrill committed Jul 13, 2024
1 parent 49a0c9d commit 3251263
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/Generator/CustomerInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class CustomerInfo {
/**
* Get a country code for a country that the store is set to sell to, or validate a given country code.
*
* @param string $country_code ISO 3166-1 alpha-2 country code. E.g. US, ES, CN, RU etc.
* @param string|null $country_code ISO 3166-1 alpha-2 country code. E.g. US, ES, CN, RU etc.
*
* @return string|\WP_Error
*/
public static function get_valid_country_code( string $country_code = '' ) {
public static function get_valid_country_code( ?string $country_code = '' ) {
$country_code = strtoupper( $country_code );

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

0 comments on commit 3251263

Please sign in to comment.