From 54d50f223bc29f6590eea932b93c7b922a1ec355 Mon Sep 17 00:00:00 2001 From: Julien Fredon Date: Tue, 10 Dec 2024 21:10:31 +0100 Subject: [PATCH] Update type hints, improve test assertions, and raise PHP requirement. The code now uses nullable type hints for better clarity and stricter type enforcement. The deprecated assertInternalType method is replaced with assertIsInt in tests to ensure compatibility with newer PHPUnit versions. The minimum required PHP version in the composer.json file is increased to 7.1 due to the use of nullable type hints, which are incompatible with PHP 5.6. --- composer.json | 2 +- src/Syllable.php | 6 +++--- tests/src/SyllableTest.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 9c2fdf9..c223113 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "source": "https://github.com/vanderlee/phpSyllable/" }, "require": { - "php": ">=5.6", + "php": ">=7.1", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", diff --git a/src/Syllable.php b/src/Syllable.php index 0132910..02a71f4 100644 --- a/src/Syllable.php +++ b/src/Syllable.php @@ -162,7 +162,7 @@ public function getHyphen() /** * @param Cache $cache */ - public function setCache(Cache $cache = null) + public function setCache(?Cache $cache = null) { $this->cache = $cache; } @@ -598,8 +598,8 @@ private function parseHtmlText($html) */ private function hyphenateHtmlDom( DOMNode $node, - DOMNodeList $excludeNodes = null, - DOMNodeList $includeNodes = null, + ?DOMNodeList $excludeNodes = null, + ?DOMNodeList $includeNodes = null, $split = true ) { if ($node->hasChildNodes()) { diff --git a/tests/src/SyllableTest.php b/tests/src/SyllableTest.php index 52ecc16..1781b76 100644 --- a/tests/src/SyllableTest.php +++ b/tests/src/SyllableTest.php @@ -171,8 +171,8 @@ public function testCache($cacheClass, $language, $cacheDirectory, $cacheFile, $ $this->assertNotEmpty($this->object->getCache()->__get('patterns')); $this->assertGreaterThan(0, $this->object->getCache()->__get('max_pattern')); $this->assertNotEmpty($this->object->getCache()->__get('hyphenation')); - $this->assertInternalType('int', $this->object->getCache()->__get('left_min_hyphen')); - $this->assertInternalType('int', $this->object->getCache()->__get('right_min_hyphen')); + $this->assertIsInt($this->object->getCache()->__get('left_min_hyphen')); + $this->assertIsInt($this->object->getCache()->__get('right_min_hyphen')); } public function dataCacheVersionMatchesCacheFileVersionIsRelaxed()