ronanguilloux / IsoCodes

PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Manufacturing Industry, Phone numbers & Zipcodes for many countries
GNU General Public License v3.0
792 stars 77 forks source link

Ensure tests pass without warnings in PHP 8.2 #183

Open elcapo opened 5 months ago

elcapo commented 5 months ago

Hi @ronanguilloux,

I hope I'm not being too invasive with this PR. If so, feel free to cancel it.

What I'm doing is making sure things work without issues in PHP 8.2 (as tests were throwing a hundreds of warnings). Most of them were due to passing null to PHP native functions that don't support null anymore. To fix those issues, I systematically added statements in the form of:

$value = $value ?? '';

The full summary of what this PR does, is:

stof commented 3 months ago

As the phpdoc type for those parameters says @param string, the proper fix should be done in the caller IMO, by avoiding the usage of parameter values that don't respect the document contract of the class.