Rector: Coding Style

Created on 24 Feb 2020  路  7Comments  路  Source: rectorphp/rector

Bug Report

| Subject | Details |
| :------------- | :---------------------------------------------------------------|
| Rector version | v0.7.1 |
| Installed as | composer dependency |

Running vendor/bin/rector process /var/www/html/app/Http --set solid --only "Rector\SOLID\Rector\ClassMethod\ChangeReadOnlyVariableWithDefaultValueToConstantRector" --dry-run or any rule is changing my code style. This must be new as it was not happening in v0.7.0.

    ---------- begin diff ----------
--- Original
+++ New
@@ -5,12 +5,11 @@
  * UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
  * The details is bundled with this project in the file LICENSE.txt.
  *
- * @project    UNIT3D Community Edition
+ * @project UNIT3D Community Edition
  *
- * @author     HDVinnie <[email protected]>
- * @license    https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
+ * @author HDVinnie <[email protected]>
+ * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
  */
-
 namespace App\Http\Resources;

 use Illuminate\Http\Resources\Json\JsonResource;
    ----------- end diff -----------

Expected Behavior

For rector to not change my style specifically when Im running a specified rule that has nothing to do with what changes it is imposing.

Demo

https://getrector.org/demo/96d150f2-9b63-4028-b66f-444c6e0c14e2#result

bug

All 7 comments

@TomasVotruba , this is actually a problem... I have the same, especially in CI, where I run first Rector and then PHP-CS-Fixer.

So, Rector always fails as it changes the Docblocks in the way described by @HDVinnie , but they are as reformatted by PHPCSFixer.

What happens is this:

On local machine:

  • Run Rector (that changes the docblock comments as described in this issues)
  • Run PHPCsFixer (that reformat the Docblocks in the way I want)

Then, on CI

  • Run Rector: Fails
    At this point, in fact, Rector always fails as it intercept changes in Docblocks also if it actually didn't changed nothing: it simply reprint the class with changed dockblocks and this fails as the docblocks are in reality formatted by PHPCS Fixer on local dev machine.

Demo link is just fine. No need for more info

Minimal code causing the issue:

<?php

/**
 * @license      https://www.gnu.org/licenses/agpl-3.0.en.html/
 */
class DemoFile
{
}

@TomasVotruba when do you plan to actually publish the hot fix since it effects the package as a whole. 0.7.2

I usually do releases in 5-10 days cycles with bunch of more fixes

@TomasVotruba This still appears to be a issue.

https://getrector.org/demo/2832d6f2-3887-4605-88f0-b112ce0e2a80

Please send PR with fixture, similar location as https://github.com/rectorphp/rector/pull/2925/files#diff-d48dc702bd2d58bc17e63877329e8454

Was this page helpful?
0 / 5 - 0 ratings