From 8391bb7a1739cb20955a7b4418c56ced1d55b766 Mon Sep 17 00:00:00 2001 From: Tom Arbesser-Rastburg Date: Sun, 1 Dec 2024 12:04:27 +1100 Subject: [PATCH] Fix deprecation warnings --- composer.json | 4 ++-- lib/Diff/SequenceMatcher.php | 23 +++++++++++++++++++---- tests/Diff/Renderer/Html/ArrayTest.php | 4 +++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 12d70ab6..d1a43d97 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "authors": [ { "name": "Chris Boulton", - "email": "@chrisboulton" + "email": "chris@chrisboulton.no-email" } ], "autoload": { @@ -14,6 +14,6 @@ } }, "require-dev": { - "phpunit/phpunit": "~5.5" + "phpunit/phpunit": "~8" } } diff --git a/lib/Diff/SequenceMatcher.php b/lib/Diff/SequenceMatcher.php index e819e810..f2514ba3 100644 --- a/lib/Diff/SequenceMatcher.php +++ b/lib/Diff/SequenceMatcher.php @@ -75,6 +75,21 @@ class Diff_SequenceMatcher 'ignoreCase' => false ); + /** + * @var array|null + */ + private $matchingBlocks; + + /** + * @var array|null + */ + private $opCodes; + + /** + * @var array|null + */ + private $fullBCount; + /** * The constructor. With the sequences being passed, they'll be set for the * sequence matcher and it will perform a basic cleanup & calculate junk @@ -84,7 +99,7 @@ class Diff_SequenceMatcher * @param string|array $b A string or array containing the lines to compare. * @param string|array $junkCallback Either an array or string that references a callback function (if there is one) to determine 'junk' characters. */ - public function __construct($a, $b, $junkCallback=null, $options) + public function __construct($a, $b, $junkCallback, $options) { $this->a = null; $this->b = null; @@ -349,8 +364,8 @@ public function getMatchingBlocks() return $this->matchingBlocks; } - $aLength = count($this->a); - $bLength = count($this->b); + $aLength = count($this->a ?? []); + $bLength = count($this->b ?? []); $queue = array( array( @@ -739,4 +754,4 @@ private function tupleSort($a, $b) return 1; } } -} \ No newline at end of file +} diff --git a/tests/Diff/Renderer/Html/ArrayTest.php b/tests/Diff/Renderer/Html/ArrayTest.php index e0e303d0..5dfc0e8f 100644 --- a/tests/Diff/Renderer/Html/ArrayTest.php +++ b/tests/Diff/Renderer/Html/ArrayTest.php @@ -2,7 +2,9 @@ namespace Tests\Diff\Renderer\Html; -class ArrayTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class ArrayTest extends TestCase { public function testRenderSimpleDelete() {