Skip to content

Commit

Permalink
feat: create @PHP82Migration:risky ruleset (PHP-CS-Fixer#8277)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos authored Nov 13, 2024
1 parent 9dc4237 commit c7ee73c
Show file tree
Hide file tree
Showing 20 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .php-cs-fixer.php-highest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

$config->setRules(array_merge($config->getRules(), [
'@PHP83Migration' => true,
'@PHP80Migration:risky' => true,
'@PHP82Migration:risky' => true,
'fully_qualified_strict_types' => ['import_symbols' => true],
'php_unit_attributes' => false, // as is not yet supported by PhpCsFixerInternal/configurable_fixer_template
]));
Expand Down
19 changes: 19 additions & 0 deletions doc/ruleSets/PHP82MigrationRisky.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
==================================
Rule set ``@PHP82Migration:risky``
==================================

Rules to improve code for PHP 8.2 compatibility.

Warning
-------

This set contains rules that are risky
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Using this rule set may lead to changes in your code's logic and behaviour. Use it with caution and review changes before incorporating them into your code base.

Rules
-----

- `@PHP80Migration:risky <./PHP80MigrationRisky.rst>`_
- `phpdoc_readonly_class_comment_to_keyword <./../rules/class_notation/phpdoc_readonly_class_comment_to_keyword.rst>`_
1 change: 1 addition & 0 deletions doc/ruleSets/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ List of Available Rule sets
- `@PHP80Migration:risky <./PHP80MigrationRisky.rst>`_
- `@PHP81Migration <./PHP81Migration.rst>`_
- `@PHP82Migration <./PHP82Migration.rst>`_
- `@PHP82Migration:risky <./PHP82MigrationRisky.rst>`_
- `@PHP83Migration <./PHP83Migration.rst>`_
- `@PHP84Migration <./PHP84Migration.rst>`_
- `@PHPUnit30Migration:risky <./PHPUnit30MigrationRisky.rst>`_
Expand Down
1 change: 1 addition & 0 deletions doc/rules/alias/modernize_strpos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Rule sets
The rule is part of the following rule sets:

- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

References
Expand Down
4 changes: 4 additions & 0 deletions doc/rules/alias/no_alias_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ The rule is part of the following rule sets:

``['sets' => ['@all']]``

- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_ with config:

``['sets' => ['@all']]``

- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_ with config:

``['sets' => ['@all']]``
Expand Down
1 change: 1 addition & 0 deletions doc/rules/alias/pow_to_exponentiation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The rule is part of the following rule sets:
- `@PHP71Migration:risky <./../../ruleSets/PHP71MigrationRisky.rst>`_
- `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

Expand Down
4 changes: 4 additions & 0 deletions doc/rules/alias/random_api_migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ The rule is part of the following rule sets:

``['replacements' => ['mt_rand' => 'random_int', 'rand' => 'random_int']]``

- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_ with config:

``['replacements' => ['mt_rand' => 'random_int', 'rand' => 'random_int']]``


References
----------
Expand Down
1 change: 1 addition & 0 deletions doc/rules/basic/non_printable_character.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The rule is part of the following rule sets:
- `@PHP71Migration:risky <./../../ruleSets/PHP71MigrationRisky.rst>`_
- `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

Expand Down
1 change: 1 addition & 0 deletions doc/rules/class_notation/no_php4_constructor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Rule sets
The rule is part of the following rule sets:

- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

Expand Down
1 change: 1 addition & 0 deletions doc/rules/class_notation/no_unneeded_final_method.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Rule sets
The rule is part of the following rule sets:

- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Example #1
+
+ readonly class C {
}
Rule sets
---------

The rule is part of the following rule set:

- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_

References
----------

Expand Down
1 change: 1 addition & 0 deletions doc/rules/function_notation/combine_nested_dirname.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The rule is part of the following rule sets:
- `@PHP71Migration:risky <./../../ruleSets/PHP71MigrationRisky.rst>`_
- `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

Expand Down
1 change: 1 addition & 0 deletions doc/rules/function_notation/implode_call.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The rule is part of the following rule sets:

- `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The rule is part of the following rule sets:
- `@PER-CS:risky <./../../ruleSets/PER-CSRisky.rst>`_
- `@PER:risky <./../../ruleSets/PERRisky.rst>`_
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@PSR12:risky <./../../ruleSets/PSR12Risky.rst>`_
- `@PhpCsFixer:risky <./../../ruleSets/PhpCsFixerRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_
Expand Down
1 change: 1 addition & 0 deletions doc/rules/function_notation/use_arrow_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The rule is part of the following rule sets:

- `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_

References
----------
Expand Down
1 change: 1 addition & 0 deletions doc/rules/function_notation/void_return.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The rule is part of the following rule sets:
- `@PHP71Migration:risky <./../../ruleSets/PHP71MigrationRisky.rst>`_
- `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_

References
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Rule sets
The rule is part of the following rule sets:

- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_
- `@Symfony:risky <./../../ruleSets/SymfonyRisky.rst>`_

References
Expand Down
1 change: 1 addition & 0 deletions doc/rules/strict/declare_strict_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The rule is part of the following rule sets:
- `@PHP71Migration:risky <./../../ruleSets/PHP71MigrationRisky.rst>`_
- `@PHP74Migration:risky <./../../ruleSets/PHP74MigrationRisky.rst>`_
- `@PHP80Migration:risky <./../../ruleSets/PHP80MigrationRisky.rst>`_
- `@PHP82Migration:risky <./../../ruleSets/PHP82MigrationRisky.rst>`_

References
----------
Expand Down
31 changes: 31 additions & 0 deletions src/RuleSet/Sets/PHP82MigrationRiskySet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <[email protected]>
* Dariusz Rumiński <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace PhpCsFixer\RuleSet\Sets;

use PhpCsFixer\RuleSet\AbstractMigrationSetDescription;

/**
* @internal
*/
final class PHP82MigrationRiskySet extends AbstractMigrationSetDescription
{
public function getRules(): array
{
return [
'@PHP80Migration:risky' => true,
'phpdoc_readonly_class_comment_to_keyword' => true,
];
}
}
22 changes: 22 additions & 0 deletions tests/RuleSet/Sets/PHP82MigrationRiskySetTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <[email protected]>
* Dariusz Rumiński <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace PhpCsFixer\Tests\RuleSet\Sets;

/**
* @internal
*
* @covers \PhpCsFixer\RuleSet\Sets\PHP82MigrationRiskySet
*/
final class PHP82MigrationRiskySetTest extends AbstractSetTestCase {}

0 comments on commit c7ee73c

Please sign in to comment.