Repository: mlocati/ip-lib (php)

Issue:
Deprecations with PHP 8.4
I noticed a few deprecation warnings when using this library with PHP 8.4

1. `IPLib\Factory::rangeFromBoundaryAddresses(): Implicitly marking parameter $from as nullable is deprecated, the explicit nullable type must be used instead`
2. `IPLib\Factory::rangeFromBoundaryAddresses(): Implicitly marking parameter $to as nullable is deprecated, the explicit nullable type must be used instead`

I can provide a PR fixing those and adding PHP 8.3 and 8.4 to the pipelines if desired.

Pull request:
Avoid PHP 8.4 deprecation warnings
Fixes #89
Supersedes #90

Patch:
diff --git a/src/Factory.php b/src/Factory.php
index 066abde..9338a2d 100644
--- a/src/Factory.php
+++ b/src/Factory.php
@@ -215,20 +215,20 @@ class Factory
     }
 
     /**
-     * @param \IPLib\Address\AddressInterface $from
-     * @param \IPLib\Address\AddressInterface $to
+     * @param \IPLib\Address\AddressInterface|null $from
+     * @param \IPLib\Address\AddressInterface|null $to
      *
      * @return \IPLib\Range\RangeInterface|null
      *
      * @since 1.2.0
      */
-    protected static function rangeFromBoundaryAddresses(AddressInterface $from = null, AddressInterface $to = null)
+    protected static function rangeFromBoundaryAddresses($from = null, $to = null)
     {
-        if ($from === null && $to === null) {
+        if (!$from instanceof AddressInterface && !$to instanceof AddressInterface) {
             $result = null;
-        } elseif ($to === null) {
+        } elseif (!$to instanceof AddressInterface) {
             $result = Range\Single::fromAddress($from);
-        } elseif ($from === null) {
+        } elseif (!$from instanceof AddressInterface) {
             $result = Range\Single::fromAddress($to);
         } else {
             $result = null;


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index ee6cf42..866af79 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -49,6 +49,8 @@ jobs:
           - "8.0"
           - "8.1"
           - "8.2"
+          - "8.3"
+          - "8.4"
         include:
           - os: windows-latest
             php-version: "5.5"
diff --git a/test/tests/Addresses/NonDecimalIPv4AddressTest.php b/test/tests/Addresses/NonDecimalIPv4AddressTest.php
index 6de8249..37770c3 100644
--- a/test/tests/Addresses/NonDecimalIPv4AddressTest.php
+++ b/test/tests/Addresses/NonDecimalIPv4AddressTest.php
@@ -195,8 +195,9 @@ class NonDecimalIPv4AddressTest extends TestCase
      *
      * @param string $input
      * @param bool $parseNonDecimal
+     * @param array|null $expected
      */
-    public function testCases($input, $parseNonDecimal, array $expected = null)
+    public function testCases($input, $parseNonDecimal, $expected = null)
     {
         $ip = Factory::addressFromString($input, true, true, $parseNonDecimal);
         if ($expected === null) {
diff --git a/test/tests/Services/UnsignedIntegerMathTest.php b/test/tests/Services/UnsignedIntegerMathTest.php
index 444eaa0..bc5441f 100644
--- a/test/tests/Services/UnsignedIntegerMathTest.php
+++ b/test/tests/Services/UnsignedIntegerMathTest.php
@@ -78,7 +78,7 @@ class UnsignedIntegerMathTest extends TestCase
      * @param int[]|null $expectedResult
      * @param bool $onlyDecimal
      */
-    public function testGetBytes($value, $numBytes, array $expectedResult = null, $onlyDecimal = false)
+    public function testGetBytes($value, $numBytes, $expectedResult = null, $onlyDecimal = false)
     {
         $maxSignedIntegers = PHP_INT_SIZE === 4 ? array(null) : array(null, 0x7FFFFFFF);
         foreach ($maxSignedIntegers as $maxSignedInteger) {