alcohol / iso3166

A PHP library providing ISO 3166-1 data.
https://iso3166.thephpleague.com
MIT License
640 stars 59 forks source link

Add type declarations #65

Closed franmomu closed 2 years ago

franmomu commented 2 years ago

I may went too far, just let me know and I'll modify the PR, the changes are:

alcohol commented 2 years ago
  • Adding parameter type declarations which makes InvalidArgumentException.php not necessary since using other type than string would result in an Error.

Looks good to me, makes sense.

  • Add strict_types to every file.

I think this doesn't change much since we make no calls to code other than our own. Doesn't hurt.

  • MakeISO3166::$countries static as suggested by PHPStorm since the array is quite heavy.

In what scenario does this actually provide any gain though? I have considered it myself as well, but I know too little of PHP internals to know the difference/impact of this change.

franmomu commented 2 years ago

In what scenario does this actually provide any gain though? I have considered it myself as well, but I know too little of PHP internals to know the difference/impact of this change.

It was suggested by PHPStorm, I guess it uses less memory across instances, but I don't know for sure. So let's keep it as it was until we find a reason.

alcohol commented 2 years ago

Thanks again for your contribution, much appreciated :-)