Skip to content

Commit

Permalink
Update type hints, improve test assertions, and raise PHP requirement.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jfredon committed Dec 10, 2024
1 parent f13791c commit 54d50f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"source": "https://github.com/vanderlee/phpSyllable/"
},
"require": {
"php": ">=5.6",
"php": ">=7.1",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
Expand Down
6 changes: 3 additions & 3 deletions src/Syllable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions tests/src/SyllableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 54d50f2

Please sign in to comment.