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

Add phpstan-phpunit and phpstan-strict-rules #105

Merged
merged 4 commits into from
Apr 12, 2023

Conversation

phil-davis
Copy link
Contributor

@phil-davis phil-davis commented Feb 9, 2023

  1. added phpstan-phpunit and phpstan-strict-rules to composer.json and fixed up things reported about test code.
  2. Add phpstan messages to ignoreErrors instead of ignoring
  3. fixup things reported in real code

@codecov
Copy link

codecov bot commented Feb 9, 2023

Codecov Report

Merging #105 (496e883) into master (2626b72) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             master     #105   +/-   ##
=========================================
  Coverage     99.73%   99.73%           
  Complexity      109      109           
=========================================
  Files             7        7           
  Lines           376      376           
=========================================
  Hits            375      375           
  Misses            1        1           
Impacted Files Coverage Δ
lib/EmitterTrait.php 100.00% <ø> (ø)
lib/Loop/Loop.php 100.00% <100.00%> (ø)
lib/Loop/functions.php 100.00% <100.00%> (ø)
lib/Promise.php 100.00% <100.00%> (ø)
lib/Promise/functions.php 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

tests/Event/EmitterTest.php Outdated Show resolved Hide resolved
phpstan.neon Outdated Show resolved Hide resolved
phil-davis and others added 2 commits February 9, 2023 15:44
count: 1
path: lib/Loop/Loop.php
-
message: "#^Instanceof between Generator<mixed, mixed, mixed, TReturn> and Generator will always evaluate to true.$#"
Copy link
Member

@staabm staabm Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might make sense to configure phpstan with treatPhpDocTypesAsCertain: false since we have defensive code which makes double sure that types in phpdocs are really passed as expected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that locally, and it does not make any difference for this message.
Somehow PHPstan "knows" about Promises and Generator and still thinks that the check can never fail.

For now, IMO we can just keep this in ignoreErrors

@phil-davis phil-davis marked this pull request as ready for review February 9, 2023 10:04
@phil-davis
Copy link
Contributor Author

@staabm please review again and merge if you think it looks OK.

IMO the code changes I made are just being more explicit in "if" statements - phpstan now wants all "if" conditions to be real booleans. No more just saying if($var) when $var is not actually boolean type.

Copy link
Member

@staabm staabm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

@phil-davis phil-davis merged commit 267f691 into sabre-io:master Apr 12, 2023
@phil-davis phil-davis deleted the phpstan-phpunit branch April 12, 2023 10:23
@phil-davis
Copy link
Contributor Author

I am getting back to a backlog of sabre-io issues and PRs - there should be some action from now and over the coming weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants