php_unit_strict is marked risky because "risky when any of the functions are overridden"
In reality, it exchanges all instances of assertEquals to assertSame, which breaks tests with objects that are equal but not identical. Likewise assertNotEquals and assertNotSame will fail too.
I doubt it's reasonable to statically analyse the tests to determine whether its parameters are objects, but if either side is a literal it should be doable. If this is a wontfix, please update the readme to warn about it.
I think the best option would be to document this fact. If you want to submit a PR, all you have to do is edit this line: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/c61f8695e56cd870a6345272a03f2eb064078a3d/src/Fixer/PhpUnit/PhpUnitStrictFixer.php#L76
And run php php-cs-fixer readme > README.md
Will do, but the usefulness of this fixer drops like a rock once you start comparing objects in tests. Can I leave this issue open as a feature request? (Either for an option or for a separate fixer)
As @ntzm stated; updating the docs is the way to go.
We don't have and won't get the SCA capability needed in the foreseeable future to check for scalar vs. object/resource.
(regretfully btw., just stating the facts here)
@SpacePossum I understand that, but most of the time I use assertSame in tests I've got a literal on the left. If there was an option to only attempt conversion if one side was a literal that should be easier to implement and wouldn't break tests with objects.
The only leftovers would be non-object tests done with variables (Through data providers and the like)
php_unit_strict should not use assertSame on values that might be objects
if one want's to compare objects using assertEquals it means he doesn't want to be strict about assertions, so he doesn't want to use php_unit_strict in first place. Be strict. Have dedicated objects comparators.