Skip to content

Conversation

@JakeQZ
Copy link
Collaborator

@JakeQZ JakeQZ commented Feb 17, 2024

This helps quickly identify the problem.

E.g.

Before:

d:\dev\php-css-parser>composer ci:php:fixer
> @php ./.phive/php-cs-fixer.phar --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots bin src tests
PHP CS Fixer 3.49.0 (b6dc318) Insomnia by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 7.4.16
Loaded config default from "config/php-cs-fixer.php".
...............................................   1) tests\Value\SizeTest.php (function_declaration, php_unit_fqcn_annotation)

Found 1 of 52 files that can be fixed in 1.802 seconds, 20.000 MB memory used
..F..                                                      52 / 52 (100%)
Legend: .-no changes, F-fixed, S-skipped (cached or empty file), I-invalid file syntax (file ignored), E-error
Script @php ./.phive/php-cs-fixer.phar --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots bin src tests handling the ci:php:fixer event returned with error code 8

Not possible to know what the problem is without further investigation.

After:

d:\dev\php-css-parser>composer ci:php:fixer
> @php ./.phive/php-cs-fixer.phar --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots --diff bin src tests
   1) tests\Value\SizeTest.php (php_unit_fqcn_annotation)
      ---------- begin diff ----------
--- D:\dev\php-css-parser\tests\Value\SizeTest.php
+++ D:\dev\php-css-parser\tests\Value\SizeTest.php
@@ -8,7 +8,7 @@
 use Sabberworm\CSS\Value\Size;

 /**
- * @covers Size
+ * @covers \Size
  */
 final class SizeTest extends TestCase
 {

      ----------- end diff -----------

Found 1 of 52 files that can be fixed in 0.029 seconds, 14.000 MB memory used
PHP CS Fixer 3.49.0 (b6dc318) Insomnia by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 7.4.16
Loaded config default from "config/php-cs-fixer.php".
Using cache file ".php-cs-fixer.cache".
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSFSS                                                      52 / 52 (100%)
Legend: .-no changes, F-fixed, S-skipped (cached or empty file), I-invalid file syntax (file ignored), E-error
Script @php ./.phive/php-cs-fixer.phar --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots --diff bin src tests handling the ci:php:fixer event returned with error code 8

It's now clear what the problem is, and it can be simply resolved. In this case the suggested fix was not correct.

This helps quickly identify the problem.

E.g.

Before:

```cmd
d:\dev\php-css-parser>composer ci:php:fixer
> @php ./.phive/php-cs-fixer.phar --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots bin src tests
PHP CS Fixer 3.49.0 (b6dc318) Insomnia by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 7.4.16
Loaded config default from "config/php-cs-fixer.php".
...............................................   1) tests\Value\SizeTest.php (function_declaration, php_unit_fqcn_annotation)

Found 1 of 52 files that can be fixed in 1.802 seconds, 20.000 MB memory used
..F..                                                      52 / 52 (100%)
Legend: .-no changes, F-fixed, S-skipped (cached or empty file), I-invalid file syntax (file ignored), E-error
Script @php ./.phive/php-cs-fixer.phar --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots bin src tests handling the ci:php:fixer event returned with error code 8
```

Not possible to know what the problem is without further investigation.

After:

```cmd
d:\dev\php-css-parser>composer ci:php:fixer
> @php ./.phive/php-cs-fixer.phar --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots --diff bin src tests
   1) tests\Value\SizeTest.php (php_unit_fqcn_annotation)
      ---------- begin diff ----------
--- D:\dev\php-css-parser\tests\Value\SizeTest.php
+++ D:\dev\php-css-parser\tests\Value\SizeTest.php
@@ -8,7 +8,7 @@
 use Sabberworm\CSS\Value\Size;

 /**
- * @Covers Size
+ * @Covers \Size
  */
 final class SizeTest extends TestCase
 {

      ----------- end diff -----------

Found 1 of 52 files that can be fixed in 0.029 seconds, 14.000 MB memory used
PHP CS Fixer 3.49.0 (b6dc318) Insomnia by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 7.4.16
Loaded config default from "config/php-cs-fixer.php".
Using cache file ".php-cs-fixer.cache".
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSFSS                                                      52 / 52 (100%)
Legend: .-no changes, F-fixed, S-skipped (cached or empty file), I-invalid file syntax (file ignored), E-error
Script @php ./.phive/php-cs-fixer.phar --config=config/php-cs-fixer.php fix --dry-run -v --show-progress=dots --diff bin src tests handling the ci:php:fixer event returned with error code 8
```

It's now clear what the problem is, and it can be simply resolved.
In this case the suggested fix was not correct.
@JakeQZ JakeQZ added enhancement developer-specific Issues that only affect maintainers, contributors, and people submitting PRs labels Feb 17, 2024
@JakeQZ JakeQZ self-assigned this Feb 17, 2024
@JakeQZ
Copy link
Collaborator Author

JakeQZ commented Feb 17, 2024

On a side point, I'm not sure The Fixer is correct here. I had the class referenced with a use statement, so don't see the need to have the FQN in the DocBlock. We don't have FQNs elsewhere in the DocBlock for classes that have been used,

@oliverklee
Copy link
Collaborator

On a side point, I'm not sure The Fixer is correct here. I had the class referenced with a use statement, so don't see the need to have the FQN in the DocBlock.

@covers annotations need to have the FQCN in it as PHPUnit does take the used classes into account for this: https://docs.phpunit.de/en/11.0/annotations.html#covers

The corresponding PHP attribute (not documented yet) will allow the usage of short class names, though, as it's real PHP code, while the doc block is not.

@oliverklee oliverklee merged commit dd81ad8 into main Feb 17, 2024
@oliverklee oliverklee deleted the dev/php-fixer-diff branch February 17, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

developer-specific Issues that only affect maintainers, contributors, and people submitting PRs enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants