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

Modernizer: add scalar + return type declarations (wherever possible) #241

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Jan 15, 2025

In line with the new minimum of PHPUnit 7.x, the assertions in the PHPUnit Polyfills will now have both parameter as well as return type declarations (wherever possible considering the minimum supported PHP version of PHP 7.1).

Additional type declarations will be added in future majors if/when the minimum supported PHP version allows for it.

Includes removing polyfilled inline type checks for assertions which were introduced in PHPUnit with declared types, but for which the polyfills couldn't type the parameters prior to this.

Includes minor adjustments to exception expectations in the tests to allow for the PHP native TypeErrors - in contrast to the emulated ones.

Notes:

  • AssertObjectProperty: the string type for the $propertyName parameter for the assertObject[Not]HasProperty() has not been applied as it would invalidate the type check (as we can't enforce strict_types for tests using the assertion).

Refs:

In line with the new minimum of PHPUnit 7.x, the assertions in the PHPUnit Polyfills will now have both parameter as well as return type declarations (wherever possible considering the minimum supported PHP version of PHP 7.1).

Additional type declarations will be added in future majors if/when the minimum supported PHP version allows for it.

Includes removing polyfilled inline type checks for assertions which were introduced in PHPUnit with declared types, but for which the polyfills couldn't type the parameters prior to this.

Includes minor adjustments to exception expectations in the tests to allow for the PHP native `TypeError`s - in contrast to the emulated ones.

Notes:
* `AssertObjectProperty`: the `string` type for the `$propertyName` parameter for the `assertObject[Not]HasProperty()` has not been applied as it would invalidate the type check (as we can't enforce `strict_types` for tests using the assertion).

Refs:
* sebastianbergmann/phpunit@852e540
* sebastianbergmann/phpunit@a7ab2b9
@coveralls
Copy link

Coverage Status

coverage: 98.331% (-0.1%) from 98.445%
when pulling e1a3029 on feature/modernize-type-declarations
into d6cf070 on 4.x.

@jrfnl jrfnl mentioned this pull request Jan 15, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants