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
Closed

[PHPUnit] Add migration for 7.5 assertInternalType #4144

Slamdunk opened this issue Dec 10, 2018 · 6 comments

Comments

@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
Copy link

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
Copy link

@SpacePossum Could you elaborate on 😕 ?

@SpacePossum
Copy link
Contributor

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

@TomasVotruba
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
Copy link
Contributor

I see now, thanks for the help!

@TomasVotruba
Copy link

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
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
Projects
None yet
Development

No branches or pull requests

3 participants