Skip to content

Commit

Permalink
Merge branch '1.x' into 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Apr 4, 2024
2 parents 2f29c9c + 3ac4954 commit ef3b23a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 10 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,18 @@ jobs:
if: ${{ matrix.php < 7.0 }}
run: composer lint-lt70 -- --checkstyle | cs2pr

- name: "Lint PHP files against parse errors - PHP 7.x"
if: ${{ startsWith( matrix.php, '7' ) }}
- name: "Lint PHP files against parse errors - PHP 7.0"
if: ${{ matrix.php == '7.0' }}
run: composer lint70

- name: "Lint PHP files against parse errors - PHP 7.1 - 7.4"
if: ${{ startsWith( matrix.php, '7' ) && matrix.php != '7.0' }}
run: composer lint7

- name: "Lint PHP files against parse errors - PHP >= 8.0"
if: ${{ matrix.php >= 8.0 }}
- name: "Lint PHP files against parse errors - PHP 8.0 - 8.3"
if: ${{ matrix.php >= 8.0 && matrix.php < 8.4 }}
run: composer lint-gte80 -- --checkstyle | cs2pr

- name: "Lint PHP files against parse errors - PHP >= 8.4"
if: ${{ matrix.php >= 8.4 }}
run: composer lint-gte84
3 changes: 3 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObjectUnion\.php$</exclude-pattern>
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObjectUnionNoReturnType\.php$</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionDeclarations.NewNullableTypes.typeDeclarationFound">
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObject\.php$</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Operators.NewOperators.t_spaceshipFound">
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObject\.php$</exclude-pattern>
</rule>
Expand Down
12 changes: 10 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@
"lint7": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git --exclude src/Exceptions/Error.php --exclude src/Exceptions/TypeError.php --exclude tests/Polyfills/Fixtures/ValueObjectUnion.php --exclude tests/Polyfills/Fixtures/ValueObjectUnionNoReturnType.php"
],
"lint70": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git --exclude src/Exceptions/Error.php --exclude src/Exceptions/TypeError.php --exclude tests/Polyfills/Fixtures/ValueObject.php --exclude tests/Polyfills/Fixtures/ValueObjectUnion.php --exclude tests/Polyfills/Fixtures/ValueObjectUnionNoReturnType.php"
],
"lint-lt70": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git --exclude src/TestCases/TestCasePHPUnitGte8.php --exclude src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7.php --exclude tests/Polyfills/Fixtures/ChildValueObject.php --exclude tests/Polyfills/Fixtures/ValueObject.php --exclude tests/Polyfills/Fixtures/ValueObjectUnion.php --exclude tests/Polyfills/Fixtures/ValueObjectUnionNoReturnType.php"
],
"lint-gte80": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git"
],
"lint-gte84": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git --exclude tests/Polyfills/Fixtures/ValueObjectNoReturnType.php"
],
"check-cs": [
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 5.6-"
],
Expand All @@ -86,9 +92,11 @@
]
},
"scripts-descriptions": {
"lint7": "Check the PHP files for parse errors. (PHP 7.x)",
"lint7": "Check the PHP files for parse errors. (PHP 7.1 - 7.4)",
"lint70": "Check the PHP files for parse errors. (PHP 7.0)",
"lint-lt70": "Check the PHP files for parse errors. (PHP < 7.0)",
"lint-gte80": "Check the PHP files for parse errors. (PHP 8.0+)",
"lint-gte80": "Check the PHP files for parse errors. (PHP 8.0 - 8.3)",
"lint-gte84": "Check the PHP files for parse errors. (PHP 8.4+)",
"check-cs": "Check the PHP files for code style violations and best practices.",
"fix-cs": "Auto-fix code style violations in the PHP files.",
"test": "Run the unit tests without code coverage (PHPUnit < 10).",
Expand Down
6 changes: 6 additions & 0 deletions tests/Polyfills/AssertObjectEqualsPHPUnitLt940Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* would make a test incompatible with the PHPUnit 9.4.0+ native implementation
* of the assertion.
*
* These tests are not run on PHP 8.4+ as only PHPUnit 9.5+ is compatible with PHP 8.4.
*
* @covers \Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals
*/
final class AssertObjectEqualsPHPUnitLt940Test extends TestCase {
Expand Down Expand Up @@ -56,6 +58,10 @@ public function maybeSkipTest() {
if ( \version_compare( PHPUnit_Version::id(), '9.4.0', '>=' ) ) {
$this->markTestSkipped( 'This test can not be run with the PHPUnit native implementation of assertObjectEquals()' );
}

if ( \version_compare( \PHP_VERSION_ID, '8.3.99', '>' ) ) {
$this->markTestSkipped( 'This test can not be run on PHP 8.4 or higher as PHPUnit < 9.4.0 is not compatible with PHP 8.4' );
}
}

/**
Expand Down
8 changes: 6 additions & 2 deletions tests/Polyfills/AssertObjectEqualsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
* Due to the use of return types in the classes under test (fixtures), these
* tests can only run on PHP 7.0 and higher.
*
* And due to the implicitly nullable parameter deprecation in PHP 8.4 requiring a
* nullable type for one of the tests, the minimum PHP version for running this
* version of the tests has been set to PHP 7.1.
*
* The `AssertObjectEqualsPHPUnitLt940Test` class mirrors this test class
* and tests the polyfill method for PHP < 7.0.
* and tests the polyfill method for PHP < 7.1.
*
* @covers \Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals
*
* @requires PHP 7.0
* @requires PHP 7.1
*/
final class AssertObjectEqualsTest extends TestCase {

Expand Down
2 changes: 1 addition & 1 deletion tests/Polyfills/Fixtures/ValueObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function equalsTwoParams( $other, $param ): bool {
*
* @return bool
*/
public function equalsParamNotRequired( self $other = null ): bool {
public function equalsParamNotRequired( ?self $other = null ): bool {
return ( $this->value === $other->value );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCases/TestCaseTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ final public function testAvailabilityEqualToSpecializations() {
/**
* Verify availability of trait polyfilled PHPUnit methods [14].
*
* @requires PHP 7.0
* @requires PHP 7.1
*
* @return void
*/
Expand Down

0 comments on commit ef3b23a

Please sign in to comment.