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

Ideas for additional strict rules #7

Open
4 tasks
mhujer opened this issue Dec 28, 2017 · 5 comments
Open
4 tasks

Ideas for additional strict rules #7

mhujer opened this issue Dec 28, 2017 · 5 comments

Comments

@mhujer
Copy link
Contributor

mhujer commented Dec 28, 2017

Here is a list of a ideas that may be implemented in the future:

  • suggest assertInstanceOf(Foo::class, $a) instead of assertTrue($a instanceof Foo)
  • suggest assertNotInstanceOf(Foo::class, $a) instead of assertFalse($a instanceof Foo)
  • suggest assertArrayHasKey() instead of assertTrue(array_key_exists(..))
  • suggest assertFileExists() instead of assertTrue(file_exists($filePath))
@ondrejmirtes
Copy link
Member

I think that assertArrayHasKey and assertFileExists are not that common and can be written in multiple ways, so I'm not sure about them.

BTW: It might be interesting to suggest assertCount and other already implemented rules also for assertEquals and not just assertSame. I know that it's a loose comparison but those more-specific asserts might also be loose comparisons as well?

@mhujer
Copy link
Contributor Author

mhujer commented Dec 28, 2017

Suggestions for specific rules instead of assertEquals should be handled by #6.

  1. If both operands are boolean/string/integer, it would recommend using assertSame
  2. And then the other rule would suggest changing it to a more specific assert 😄

@carusogabriel
Copy link
Contributor

I have more suggestions, and if I could help implement them 😸 :

  • Suggest assertCount(1, $foo) instead of assertSame(1, sizeof($foo))
  • Suggest assertContains('foo', [...]) instead of assertTrue(in_array('foo', [...]))
  • Suggest assertEmpty($foo) instead of assertTrue(empty($foo))

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Dec 30, 2017 via email

@carusogabriel
Copy link
Contributor

More ideas https://docs.google.com/spreadsheets/d/145hef6esG-B09AfooY-4e0oFKa1eVDoeUeo-eXVZRoA/edit?usp=sharing...

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

No branches or pull requests

3 participants