Skip to content

Commit

Permalink
Add PHP 8.3 to GitHub workflows (#164)
Browse files Browse the repository at this point in the history
Co-authored-by: Aad Mathijssen <[email protected]>
  • Loading branch information
aadmathijssen and Aad Mathijssen authored Aug 22, 2024
1 parent 4b9538f commit 2d9c536
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"

steps:
- name: "Checkout"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
php-version:
- "5.3"
- "7.4"
- "8.3"

steps:
- name: "Checkout"
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ jobs:

strategy:
matrix:
php-version:
- "7.4"
include:
- php-version: "7.4"
phpunit-version-constraint: "^7.5"
- php-version: "8.3"
phpunit-version-constraint: "^9.6"

steps:
- name: "Checkout"
Expand All @@ -44,7 +47,6 @@ jobs:
run: "composer update ${{ env.COMPOSER_FLAGS }}"

- name: Run PHPStan
# Locked to phpunit 7.5 here as newer ones have void return types which break inheritance
run: |
composer require --dev phpunit/phpunit:^7.5.20 --with-all-dependencies ${{ env.COMPOSER_FLAGS }}
composer require --dev phpunit/phpunit:"${{ matrix.phpunit-version-constraint }}" --with-all-dependencies ${{ env.COMPOSER_FLAGS }}
vendor/bin/phpstan analyse
13 changes: 8 additions & 5 deletions tests/Constraint/ConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Composer\Semver\Constraint;

use Exception;
use LogicException;
use PHPUnit\Framework\TestCase;
use Composer\Semver\Intervals;

Expand Down Expand Up @@ -397,7 +399,7 @@ public function testInverseMatchingOtherConstraints()
->with($constraint)
->willReturn(true)
;
// @phpstan-ignore-next-line
/** @var ConstraintInterface $otherConstraintMock */
$this->assertTrue($constraint->matches($otherConstraintMock));
}
}
Expand Down Expand Up @@ -426,7 +428,7 @@ public function testComparableBranches()
*
* @param string $version
* @param Constraint::STR_OP_* $operator
* @param class-string $expected
* @param class-string<Exception> $expected
*/
public function testInvalidOperators($version, $operator, $expected)
{
Expand Down Expand Up @@ -580,16 +582,17 @@ private function matchCompiled(ConstraintInterface $constraint, $operator, $vers
}

/**
* @param class-string $class
* @param class-string<Exception> $class
* @return void
*/
private function doExpectException($class)
{
if (method_exists($this, 'expectException')) {
$this->expectException($class);
} else {
// @phpstan-ignore-next-line
} elseif (method_exists($this, 'setExpectedException')) {
$this->setExpectedException($class);
} else {
throw new LogicException('Expected method "expectException" or "setExpectedException" to exist.');
}
}
}
9 changes: 6 additions & 3 deletions tests/VersionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Composer\Semver\Constraint\MatchAllConstraint;
use Composer\Semver\Constraint\MultiConstraint;
use Composer\Semver\Constraint\Constraint;
use Exception;
use LogicException;
use PHPUnit\Framework\TestCase;

class VersionParserTest extends TestCase
Expand Down Expand Up @@ -851,7 +853,7 @@ public function testComplexConjunctive()
}

/**
* @param class-string $class
* @param class-string<Exception> $class
* @param string|null $message
* @return void
*/
Expand All @@ -862,9 +864,10 @@ private function doExpectException($class, $message = null)
if ($message) {
$this->expectExceptionMessage($message);
}
} else {
// @phpstan-ignore-next-line
} elseif (method_exists($this, 'setExpectedException')) {
$this->setExpectedException($class, $message);
} else {
throw new LogicException('Expected method "expectException" or "setExpectedException" to exist.');
}
}
}

0 comments on commit 2d9c536

Please sign in to comment.