GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Addition of rule for cases better represented with assertSameSize() method by o0h · Pull Request #207 · phpstan/phpstan-phpunit

Conversation

@o0h

@o0h o0h commented Apr 4, 2024

Copy link
Copy Markdown

This Pull Request enhances the AssertSameWithCountRule in PHPUnit to handle additional use cases. The new rule now checks when both sides of the assertSame are counts, and suggests assertSameSize instead when necessary.

Here is some detail on what has changed:

  • AssertSameWithCountRule now includes a check for cases where expected value of assertCount is the direct result of count function call.
  • In these cases, a special assertion function assertSameSize is suggested to compare the sizes of collections rather than using the original assertSame function.

The code changes involve adjustments in method call structures, evaluation of counts and introduction of cases for assertSameSize.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@o0h
o0h marked this pull request as draft April 5, 2024 01:57
ondrejmirtes
ondrejmirtes requested changes Apr 5, 2024
View reviewed changes

@ondrejmirtes ondrejmirtes left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Hi,
this should only be reported with bleeding edge. Use private bool $bleedingEdge in the rule constructor and add the new behaviour only when this is true. Here's an example how it should look in config: https://github.com/phpstan/phpstan-doctrine/blob/0d967379b8ea58c4f4499b17eeb9f29718350497/rules.neon#L57

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@o0h

o0h commented Apr 5, 2024

Copy link
Copy Markdown
Author

Hi, @ondrejmirtes!

Thanks for the quick feedback!
Sorry that it's not passing the CI checks just yet. I'll sort out the issue and let you know once it's ready for review.

I'll be sure to use the bleeding edge flag as you suggested. Just hang tight a little longer!

Best regards,

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@o0h
o0h force-pushed the suggest-assert-same-size branch from f74e9be to bff5e12 Compare April 5, 2024 18:05
@o0h
Update AssertSameWithCountRule for assertSameSize
3a37222
Expanded the AssertSameWithCountRule in PHPUnit rules to handle additional scenarios. Now the rule checks if both sides of the assertSame are counts, and suggests assertSameSize instead when necessary. The modification enhances the rule's applicability and accuracy.
@o0h
o0h force-pushed the suggest-assert-same-size branch from bff5e12 to 3a37222 Compare April 5, 2024 19:00
@o0h
Update README
11d7b35
@o0h
o0h marked this pull request as ready for review April 5, 2024 19:09
@o0h

o0h commented Apr 5, 2024

Copy link
Copy Markdown
Author

I have completed the necessary corrections that were of concern.
I would appreciate it if you could take a look and check it.
Thank you 😃

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@o0h
Update link and fix typo in README.md
3f833d2
The link in the README file's "bleeding edge" reference has been updated to accurately direct users to the relevant blog post. Also corrected the typo by capitalizing the initial letter of the sentence.
@o0h
o0h requested a review from ondrejmirtes April 28, 2024 05:26
ondrejmirtes
ondrejmirtes requested changes Apr 28, 2024
View reviewed changes
Comment thread src/Rules/PHPUnit/AssertSameWithCountRule.php
}

if (
$right instanceof Node\Expr\MethodCall

@ondrejmirtes ondrejmirtes Apr 28, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

TBH this diff is very messy. I can't tell if the no-bleedingEdge behaviour is preserved or not. Can you split the changes in multiple commits? First extract logic into isCount... methods without changing the behaviour, and then introduce bleedingEdge-on behaviour that will be a new separate if statement. Can you please do that? Thank you.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ondrejmirtes ondrejmirtes ondrejmirtes requested changes

Requested changes must be addressed to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@o0h @ondrejmirtes
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.