Skip to content

Commit a60c693

Browse files
committed
Improve constraint checking logic
1 parent 09e9d08 commit a60c693

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

contribution/extension/type.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,21 @@ protected function is_stable_version($version)
396396
}
397397

398398
/**
399-
* Check if phpBB requirement allows 4.0.0 or higher
399+
* Check if phpBB requires 4.0.0 or higher
400400
*
401401
* @param string $constraint Version constraint
402-
* @return bool True if constraint allows phpBB 4.0.0+
402+
* @return bool True if constraint requires phpBB 4.0.0+
403403
*/
404404
protected function requires_phpbb_4_or_higher($constraint)
405405
{
406406
try
407407
{
408408
$parser = new \Composer\Semver\VersionParser();
409-
$constraintObj = $parser->parseConstraints($constraint);
410-
// Check if the constraint excludes versions below 4.0.0 by testing if 3.9.9 does NOT satisfy the constraint
411-
return !$constraintObj->matches(new \Composer\Semver\Constraint\Constraint('==', '3.9.9.0'));
409+
$constraint_obj = $parser->parseConstraints($constraint);
410+
$phpbb4_constraint = $parser->parseConstraints('>=4.0.0');
411+
$phpbb3_constraint = $parser->parseConstraints('<4.0.0');
412+
// Check if constraint allows 4.0.0+ and excludes all versions below 4.0.0
413+
return $constraint_obj->matches($phpbb4_constraint) && !$constraint_obj->matches($phpbb3_constraint);
412414
}
413415
catch (\Exception $e)
414416
{

0 commit comments

Comments
 (0)