Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fabbot.io tries to apply a patch for #[\Attribute #40149

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

Closed
wkania opened this issue Feb 10, 2021 · 3 comments
Closed

fabbot.io tries to apply a patch for #[\Attribute #40149

wkania opened this issue Feb 10, 2021 · 3 comments

Comments

@wkania
Copy link
Contributor

wkania commented Feb 10, 2021

Symfony version(s) affected: 5.x

Description
fabbot is using PHP CS Fixer 2.18, so this should not be a problem. The leading backslash is recommended.

Current code
Patch

diff -ru src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php
--- src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php	2021-02-10 21:32:14.283031188 +0000
+++ src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php	2021-02-10 21:32:15.265010897 +0000
@@ -21,7 +21,7 @@
  *
  * @author Benjamin Eberlei <[email protected]>
  */
-#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
+#[Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
 class UniqueEntity extends Constraint
 {
     public const NOT_UNIQUE_ERROR = '23bd9dbf-6b9b-41cd-a99e-4844bcf3077f';

How to reproduce

Possible Solution

Additional context
Checks were not successful in the PR.

I checked it locally and there was no problem:

composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer:2.18.0
tools/php-cs-fixer/vendor/bin/php-cs-fixer fix src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php 
Loaded config default from ".php_cs.dist".
Using cache file ".php_cs.cache".
Paths from configuration file have been overridden by paths provided as command arguments.

Fixed all files in 0.097 seconds, 12.000 MB memory used
@stof
Copy link
Member

stof commented Feb 11, 2021

which PHP version are you using locally ? PHP 7 or PHP 8 ? As php-cs-fixer relies on the token parsed by PHP, the behavior when encountering attributes might differ (on PHP 7, php-cs-fixer will see a comment, not an attribute)

@wkania
Copy link
Contributor Author

wkania commented Feb 11, 2021

I retested it locally with PHP 8.0.2 and it applied the patch.
Then a bug in CSFixer.

@wkania
Copy link
Contributor Author

wkania commented Feb 11, 2021

I opened the issue so closing.

@wkania wkania closed this as completed Feb 11, 2021
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