Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit 10 | Make all assertion/exception methods final #104

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Helpers/AssertAttributeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ trait AssertAttributeHelper {
*
* @throws ReflectionException When a non-existent property is requested.
*/
public static function getProperty( $objInstance, $propertyName ) {
final public static function getProperty( $objInstance, $propertyName ) {
$reflect = new ReflectionObject( $objInstance );
$property = $reflect->getProperty( $propertyName );
$property->setAccessible( true );
Expand All @@ -62,7 +62,7 @@ public static function getProperty( $objInstance, $propertyName ) {
*
* @return mixed
*/
public static function getPropertyValue( $objInstance, $propertyName ) {
final public static function getPropertyValue( $objInstance, $propertyName ) {
$property = static::getProperty( $objInstance, $propertyName );

return $property->getValue( $objInstance );
Expand Down
12 changes: 6 additions & 6 deletions src/Polyfills/AssertEqualsSpecializations.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait AssertEqualsSpecializations {
*
* @return void
*/
public static function assertEqualsCanonicalizing( $expected, $actual, $message = '' ) {
final public static function assertEqualsCanonicalizing( $expected, $actual, $message = '' ) {
static::assertEquals( $expected, $actual, $message, 0.0, 10, true );
}

Expand All @@ -37,7 +37,7 @@ public static function assertEqualsCanonicalizing( $expected, $actual, $message
*
* @return void
*/
public static function assertEqualsIgnoringCase( $expected, $actual, $message = '' ) {
final public static function assertEqualsIgnoringCase( $expected, $actual, $message = '' ) {
static::assertEquals( $expected, $actual, $message, 0.0, 10, false, true );
}

Expand All @@ -51,7 +51,7 @@ public static function assertEqualsIgnoringCase( $expected, $actual, $message =
*
* @return void
*/
public static function assertEqualsWithDelta( $expected, $actual, $delta, $message = '' ) {
final public static function assertEqualsWithDelta( $expected, $actual, $delta, $message = '' ) {
static::assertEquals( $expected, $actual, $message, $delta );
}

Expand All @@ -64,7 +64,7 @@ public static function assertEqualsWithDelta( $expected, $actual, $delta, $messa
*
* @return void
*/
public static function assertNotEqualsCanonicalizing( $expected, $actual, $message = '' ) {
final public static function assertNotEqualsCanonicalizing( $expected, $actual, $message = '' ) {
static::assertNotEquals( $expected, $actual, $message, 0.0, 10, true );
}

Expand All @@ -77,7 +77,7 @@ public static function assertNotEqualsCanonicalizing( $expected, $actual, $messa
*
* @return void
*/
public static function assertNotEqualsIgnoringCase( $expected, $actual, $message = '' ) {
final public static function assertNotEqualsIgnoringCase( $expected, $actual, $message = '' ) {
static::assertNotEquals( $expected, $actual, $message, 0.0, 10, false, true );
}

Expand All @@ -91,7 +91,7 @@ public static function assertNotEqualsIgnoringCase( $expected, $actual, $message
*
* @return void
*/
public static function assertNotEqualsWithDelta( $expected, $actual, $delta, $message = '' ) {
final public static function assertNotEqualsWithDelta( $expected, $actual, $delta, $message = '' ) {
static::assertNotEquals( $expected, $actual, $message, $delta );
}
}
16 changes: 8 additions & 8 deletions src/Polyfills/AssertFileEqualsSpecializations.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait AssertFileEqualsSpecializations {
*
* @return void
*/
public static function assertFileEqualsCanonicalizing( $expected, $actual, $message = '' ) {
final public static function assertFileEqualsCanonicalizing( $expected, $actual, $message = '' ) {
static::assertFileEquals( $expected, $actual, $message, true );
}

Expand All @@ -42,7 +42,7 @@ public static function assertFileEqualsCanonicalizing( $expected, $actual, $mess
*
* @return void
*/
public static function assertFileEqualsIgnoringCase( $expected, $actual, $message = '' ) {
final public static function assertFileEqualsIgnoringCase( $expected, $actual, $message = '' ) {
static::assertFileEquals( $expected, $actual, $message, false, true );
}

Expand All @@ -56,7 +56,7 @@ public static function assertFileEqualsIgnoringCase( $expected, $actual, $messag
*
* @return void
*/
public static function assertFileNotEqualsCanonicalizing( $expected, $actual, $message = '' ) {
final public static function assertFileNotEqualsCanonicalizing( $expected, $actual, $message = '' ) {
static::assertFileNotEquals( $expected, $actual, $message, true );
}

Expand All @@ -70,7 +70,7 @@ public static function assertFileNotEqualsCanonicalizing( $expected, $actual, $m
*
* @return void
*/
public static function assertFileNotEqualsIgnoringCase( $expected, $actual, $message = '' ) {
final public static function assertFileNotEqualsIgnoringCase( $expected, $actual, $message = '' ) {
static::assertFileNotEquals( $expected, $actual, $message, false, true );
}

Expand All @@ -84,7 +84,7 @@ public static function assertFileNotEqualsIgnoringCase( $expected, $actual, $mes
*
* @return void
*/
public static function assertStringEqualsFileCanonicalizing( $expectedFile, $actualString, $message = '' ) {
final public static function assertStringEqualsFileCanonicalizing( $expectedFile, $actualString, $message = '' ) {
static::assertStringEqualsFile( $expectedFile, $actualString, $message, true );
}

Expand All @@ -98,7 +98,7 @@ public static function assertStringEqualsFileCanonicalizing( $expectedFile, $act
*
* @return void
*/
public static function assertStringEqualsFileIgnoringCase( $expectedFile, $actualString, $message = '' ) {
final public static function assertStringEqualsFileIgnoringCase( $expectedFile, $actualString, $message = '' ) {
static::assertStringEqualsFile( $expectedFile, $actualString, $message, false, true );
}

Expand All @@ -112,7 +112,7 @@ public static function assertStringEqualsFileIgnoringCase( $expectedFile, $actua
*
* @return void
*/
public static function assertStringNotEqualsFileCanonicalizing( $expectedFile, $actualString, $message = '' ) {
final public static function assertStringNotEqualsFileCanonicalizing( $expectedFile, $actualString, $message = '' ) {
static::assertStringNotEqualsFile( $expectedFile, $actualString, $message, true );
}

Expand All @@ -126,7 +126,7 @@ public static function assertStringNotEqualsFileCanonicalizing( $expectedFile, $
*
* @return void
*/
public static function assertStringNotEqualsFileIgnoringCase( $expectedFile, $actualString, $message = '' ) {
final public static function assertStringNotEqualsFileIgnoringCase( $expectedFile, $actualString, $message = '' ) {
static::assertStringNotEqualsFile( $expectedFile, $actualString, $message, false, true );
}
}
44 changes: 22 additions & 22 deletions src/Polyfills/AssertIsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait AssertIsType {
*
* @return void
*/
public static function assertIsArray( $actual, $message = '' ) {
final public static function assertIsArray( $actual, $message = '' ) {
static::assertInternalType( 'array', $actual, $message );
}

Expand All @@ -37,7 +37,7 @@ public static function assertIsArray( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsBool( $actual, $message = '' ) {
final public static function assertIsBool( $actual, $message = '' ) {
static::assertInternalType( 'bool', $actual, $message );
}

Expand All @@ -49,7 +49,7 @@ public static function assertIsBool( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsFloat( $actual, $message = '' ) {
final public static function assertIsFloat( $actual, $message = '' ) {
static::assertInternalType( 'float', $actual, $message );
}

Expand All @@ -61,7 +61,7 @@ public static function assertIsFloat( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsInt( $actual, $message = '' ) {
final public static function assertIsInt( $actual, $message = '' ) {
static::assertInternalType( 'int', $actual, $message );
}

Expand All @@ -73,7 +73,7 @@ public static function assertIsInt( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNumeric( $actual, $message = '' ) {
final public static function assertIsNumeric( $actual, $message = '' ) {
static::assertInternalType( 'numeric', $actual, $message );
}

Expand All @@ -85,7 +85,7 @@ public static function assertIsNumeric( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsObject( $actual, $message = '' ) {
final public static function assertIsObject( $actual, $message = '' ) {
static::assertInternalType( 'object', $actual, $message );
}

Expand All @@ -97,7 +97,7 @@ public static function assertIsObject( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsResource( $actual, $message = '' ) {
final public static function assertIsResource( $actual, $message = '' ) {
static::assertInternalType( 'resource', $actual, $message );
}

Expand All @@ -109,7 +109,7 @@ public static function assertIsResource( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsString( $actual, $message = '' ) {
final public static function assertIsString( $actual, $message = '' ) {
static::assertInternalType( 'string', $actual, $message );
}

Expand All @@ -121,7 +121,7 @@ public static function assertIsString( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsScalar( $actual, $message = '' ) {
final public static function assertIsScalar( $actual, $message = '' ) {
static::assertInternalType( 'scalar', $actual, $message );
}

Expand All @@ -133,7 +133,7 @@ public static function assertIsScalar( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsCallable( $actual, $message = '' ) {
final public static function assertIsCallable( $actual, $message = '' ) {
static::assertInternalType( 'callable', $actual, $message );
}

Expand All @@ -152,7 +152,7 @@ public static function assertIsCallable( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsIterable( $actual, $message = '' ) {
final public static function assertIsIterable( $actual, $message = '' ) {
if ( \function_exists( 'is_iterable' ) === true ) {
// PHP >= 7.1.
// phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.is_iterableFound
Expand All @@ -173,7 +173,7 @@ public static function assertIsIterable( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotArray( $actual, $message = '' ) {
final public static function assertIsNotArray( $actual, $message = '' ) {
static::assertNotInternalType( 'array', $actual, $message );
}

Expand All @@ -185,7 +185,7 @@ public static function assertIsNotArray( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotBool( $actual, $message = '' ) {
final public static function assertIsNotBool( $actual, $message = '' ) {
static::assertNotInternalType( 'bool', $actual, $message );
}

Expand All @@ -197,7 +197,7 @@ public static function assertIsNotBool( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotFloat( $actual, $message = '' ) {
final public static function assertIsNotFloat( $actual, $message = '' ) {
static::assertNotInternalType( 'float', $actual, $message );
}

Expand All @@ -209,7 +209,7 @@ public static function assertIsNotFloat( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotInt( $actual, $message = '' ) {
final public static function assertIsNotInt( $actual, $message = '' ) {
static::assertNotInternalType( 'int', $actual, $message );
}

Expand All @@ -221,7 +221,7 @@ public static function assertIsNotInt( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotNumeric( $actual, $message = '' ) {
final public static function assertIsNotNumeric( $actual, $message = '' ) {
static::assertNotInternalType( 'numeric', $actual, $message );
}

Expand All @@ -233,7 +233,7 @@ public static function assertIsNotNumeric( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotObject( $actual, $message = '' ) {
final public static function assertIsNotObject( $actual, $message = '' ) {
static::assertNotInternalType( 'object', $actual, $message );
}

Expand All @@ -245,7 +245,7 @@ public static function assertIsNotObject( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotResource( $actual, $message = '' ) {
final public static function assertIsNotResource( $actual, $message = '' ) {
static::assertNotInternalType( 'resource', $actual, $message );
}

Expand All @@ -257,7 +257,7 @@ public static function assertIsNotResource( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotString( $actual, $message = '' ) {
final public static function assertIsNotString( $actual, $message = '' ) {
static::assertNotInternalType( 'string', $actual, $message );
}

Expand All @@ -269,7 +269,7 @@ public static function assertIsNotString( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotScalar( $actual, $message = '' ) {
final public static function assertIsNotScalar( $actual, $message = '' ) {
static::assertNotInternalType( 'scalar', $actual, $message );
}

Expand All @@ -281,7 +281,7 @@ public static function assertIsNotScalar( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotCallable( $actual, $message = '' ) {
final public static function assertIsNotCallable( $actual, $message = '' ) {
static::assertNotInternalType( 'callable', $actual, $message );
}

Expand All @@ -300,7 +300,7 @@ public static function assertIsNotCallable( $actual, $message = '' ) {
*
* @return void
*/
public static function assertIsNotIterable( $actual, $message = '' ) {
final public static function assertIsNotIterable( $actual, $message = '' ) {
if ( \function_exists( 'is_iterable' ) === true ) {
// PHP >= 7.1.
// phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.is_iterableFound
Expand Down
2 changes: 1 addition & 1 deletion src/Polyfills/AssertObjectEquals.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ trait AssertObjectEquals {
* @throws TypeError When any of the passed arguments do not meet the required type.
* @throws InvalidComparisonMethodException When the comparator method does not comply with the requirements.
*/
public static function assertObjectEquals( $expected, $actual, $method = 'equals', $message = '' ) {
final public static function assertObjectEquals( $expected, $actual, $method = 'equals', $message = '' ) {
/*
* Parameter input validation.
* In PHPUnit this is done via PHP native type declarations. Emulating this for the polyfill.
Expand Down
8 changes: 4 additions & 4 deletions src/Polyfills/AssertStringContains.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait AssertStringContains {
*
* @return void
*/
public static function assertStringContainsString( $needle, $haystack, $message = '' ) {
final public static function assertStringContainsString( $needle, $haystack, $message = '' ) {
if ( $needle === '' ) {
static::assertSame( $needle, $needle, $message );
return;
Expand All @@ -49,7 +49,7 @@ public static function assertStringContainsString( $needle, $haystack, $message
*
* @return void
*/
public static function assertStringContainsStringIgnoringCase( $needle, $haystack, $message = '' ) {
final public static function assertStringContainsStringIgnoringCase( $needle, $haystack, $message = '' ) {
if ( $needle === '' ) {
static::assertSame( $needle, $needle, $message );
return;
Expand All @@ -67,7 +67,7 @@ public static function assertStringContainsStringIgnoringCase( $needle, $haystac
*
* @return void
*/
public static function assertStringNotContainsString( $needle, $haystack, $message = '' ) {
final public static function assertStringNotContainsString( $needle, $haystack, $message = '' ) {
if ( $needle === '' ) {
$msg = "Failed asserting that '{$haystack}' does not contain \"\".";
if ( $message !== '' ) {
Expand All @@ -89,7 +89,7 @@ public static function assertStringNotContainsString( $needle, $haystack, $messa
*
* @return void
*/
public static function assertStringNotContainsStringIgnoringCase( $needle, $haystack, $message = '' ) {
final public static function assertStringNotContainsStringIgnoringCase( $needle, $haystack, $message = '' ) {
if ( $needle === '' ) {
$msg = "Failed asserting that '{$haystack}' does not contain \"\".";
if ( $message !== '' ) {
Expand Down
Loading