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

Always stop when "PHP_CS_FIXER_FUTURE_MODE" is used #5601

Merged
merged 1 commit into from Apr 9, 2021
Merged

Always stop when "PHP_CS_FIXER_FUTURE_MODE" is used #5601

merged 1 commit into from Apr 9, 2021

Conversation

kubawerlos
Copy link
Contributor

@kubawerlos kubawerlos commented Apr 6, 2021

Deprecations are not always stopping application when PHP_CS_FIXER_FUTURE_MODE is on.

We can see that in first commit where rules with deprecation configuration was added the build have passed - and we run fixer with PHP_CS_FIXER_FUTURE_MODE flag: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.18.5/.github/workflows/ci.yml#L146

The second commit is moving all trigger_error calls to Utils::triggerDeprecation and there we decide basing on PHP_CS_FIXER_FUTURE_MODE if throw an exception.

3rd and 4th commits are restoring config and makes fabbot happy, respectively.

@coveralls
Copy link

coveralls commented Apr 6, 2021

Coverage Status

Coverage increased (+0.04%) to 91.887% when pulling 86ccb06 on kubawerlos:handling_errors into 082a84b on FriendsOfPHP:master.

@kubawerlos kubawerlos changed the title [WIP] Handling errors Always stop when "PHP_CS_FIXER_FUTURE_MODE" is used Apr 7, 2021
@kubawerlos kubawerlos marked this pull request as ready for review April 7, 2021 15:58
*
* @param string $className
*/
public function testThereIsNoTriggerErrorUsedDirectly($className)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -289,6 +289,27 @@ public function provideCalculateBitmaskCases()
];
}

/**
* @group legacy
* @expectedDeprecation The message
Copy link
Member

Choose a reason for hiding this comment

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

can we use expectDeprecationMessage method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, this method is actually expectExceptionMessage call: https://github.com/sebastianbergmann/phpunit/blob/9.5.4/src/Framework/TestCase.php#L646

Copy link
Member

Choose a reason for hiding this comment

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

isn't deprecation an exception under the hood?
also, the annotation is simply calling the method, isn't it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't deprecation an exception under the hood?

yes, in the other test, but here - without PHP_CS_FIXER_FUTURE_MODE on - it's only user deprecation.

Copy link
Member

Choose a reason for hiding this comment

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

can you try expectDeprecation method of Sf phpunit bridge? https://symfony.com/doc/current/components/phpunit_bridge.html#id1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems I can.

@kubawerlos kubawerlos changed the base branch from 2.18 to master April 7, 2021 20:26
@kubawerlos kubawerlos added this to the 2.19.0 milestone Apr 7, 2021
@keradus
Copy link
Member

keradus commented Apr 9, 2021

Thank you @kubawerlos.

@keradus keradus merged commit 063a142 into PHP-CS-Fixer:master Apr 9, 2021
@kubawerlos kubawerlos deleted the handling_errors branch April 9, 2021 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants