-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce
PhpUnitAttributesFixer
(#7831)
- Loading branch information
1 parent
8713dfd
commit 6a69160
Showing
17 changed files
with
1,280 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
============================ | ||
Rule ``php_unit_attributes`` | ||
============================ | ||
|
||
PHPUnit attributes must be used over their respective PHPDoc-based annotations. | ||
|
||
Examples | ||
-------- | ||
|
||
Example #1 | ||
~~~~~~~~~~ | ||
|
||
.. code-block:: diff | ||
--- Original | ||
+++ New | ||
<?php | ||
/** | ||
- * @covers \VendorName\Foo | ||
* @internal | ||
*/ | ||
+#[\PHPUnit\Framework\Attributes\CoversClass(\VendorName\Foo::class)] | ||
final class FooTest extends TestCase { | ||
/** | ||
* @param int $expected | ||
* @param int $actual | ||
- * @dataProvider giveMeSomeData | ||
- * @requires PHP 8.0 | ||
*/ | ||
+ #[\PHPUnit\Framework\Attributes\DataProvider('giveMeSomeData')] | ||
+ #[\PHPUnit\Framework\Attributes\RequiresPhp('8.0')] | ||
public function testSomething($expected, $actual) {} | ||
} | ||
References | ||
---------- | ||
|
||
- Fixer class: `PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitAttributesFixer <./../../../src/Fixer/PhpUnit/PhpUnitAttributesFixer.php>`_ | ||
- Test class: `PhpCsFixer\\Tests\\Fixer\\PhpUnit\\PhpUnitAttributesFixerTest <./../../../tests/Fixer/PhpUnit/PhpUnitAttributesFixerTest.php>`_ | ||
|
||
The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.