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] Add migration for 7.5 assertInternalType #4144

Closed
Slamdunk opened this Issue Dec 10, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@Slamdunk
Copy link
Contributor

Slamdunk commented Dec 10, 2018

References: https://github.com/sebastianbergmann/phpunit/blob/7.5.0/ChangeLog-7.5.md

Implemented sebastianbergmann/phpunit#3368: Added assertIsArray(), assertIsBool(), assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(), assertIsResource(), assertIsString(), assertIsScalar(), assertIsCallable(), assertIsIterable(), assertIsNotArray(), assertIsNotBool(), assertIsNotFloat(), assertIsNotInt(), assertIsNotNumeric(), assertIsNotObject(), assertIsNotResource(), assertIsNotString(), assertIsNotScalar(), assertIsNotCallable(), assertIsNotIterable() as alternatives to assertInternalType() and assertNotInternalType()

The methods assertInternalType() and assertNotInternalType() are now deprecated. There is no behavioral change in this version of PHPUnit. Using these methods will trigger a deprecation warning in PHPUnit 8 and in PHPUnit 9 these methods will be removed.

@TomasVotruba

This comment has been minimized.

Copy link

TomasVotruba commented Dec 10, 2018

AST integration in Rector for inspiration: rectorphp/rector@a59e356#diff-d98925ff1d61912b3a56a882ffafeae3

One drawbacks is that boolean/integer are internaly converted to bool/int.

-$this->assertNotInternalType('bool', $value, 'message');
+$this->assertIsNotBool($value, 'message');

-$this->assertNotInternalType('boolean', $value, 'message');
+$this->assertIsNotBool($value, 'message');
@TomasVotruba

This comment has been minimized.

Copy link

TomasVotruba commented Dec 31, 2018

@SpacePossum Could you elaborate on 😕 ?

@SpacePossum

This comment has been minimized.

Copy link
Member

SpacePossum commented Dec 31, 2018

The linking to other tooling/project that use AST confuses (😕) me because this tool does not use AST, it works with tokens.

@TomasVotruba

This comment has been minimized.

Copy link

TomasVotruba commented Dec 31, 2018

It's not about AST, it's about test case fixtures that you can copy while writing the fixer - rectorphp/rector@a59e356#diff-fb3d7cfa2c5b2dca79374f0551cbaeec

I've probably used wrong link, I wanted to share fixture, not the AST code. Is that more clear now?

@SpacePossum

This comment has been minimized.

Copy link
Member

SpacePossum commented Dec 31, 2018

I see now, thanks for the help!

@TomasVotruba

This comment has been minimized.

Copy link

TomasVotruba commented Dec 31, 2018

Great! I'm glad it's clear 👍 . Free free to comment next time, if something I write seems confusing. I'm happy for feedback to improve my writing.

SpacePossum added a commit that referenced this issue Mar 19, 2019

feature #4328 Add PhpUnitDedicateAssertInternalTypeFixer (Slamdunk)
This PR was squashed before being merged into the 2.15-dev branch (closes #4328).

Discussion
----------

Add PhpUnitDedicateAssertInternalTypeFixer

Closes #4144

- [x] Update `RuleSet`
- [x] Add integration test with `PhpUnitDedicateAssertInternalTypeFixer`

I intentionally created a new fixer instead of updating [PhpUnitDedicateAssertInternalTypeFixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.14.2/src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php) because the codes need too different logics.

I don't really like the names, they may confuse the users, any suggestion is welcome, but I would like to keep the two fixers in two different classes.

Commits
-------

f721b4b Add PhpUnitDedicateAssertInternalTypeFixer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.