Skip to content

Commit

Permalink
feat: @PHP84Migration introduction (#7774)
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Mar 25, 2024
1 parent e980ab2 commit 2091e39
Show file tree
Hide file tree
Showing 23 changed files with 102 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/ruleSets/PHP84Migration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
============================
Rule set ``@PHP84Migration``
============================

Rules to improve code for PHP 8.4 compatibility.

Rules
-----

- `@PHP83Migration <./PHP83Migration.rst>`_
- `nullable_type_declaration_for_default_null_value <./../rules/function_notation/nullable_type_declaration_for_default_null_value.rst>`_
1 change: 1 addition & 0 deletions doc/ruleSets/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ List of Available Rule sets
- `@PHP81Migration <./PHP81Migration.rst>`_
- `@PHP82Migration <./PHP82Migration.rst>`_
- `@PHP83Migration <./PHP83Migration.rst>`_
- `@PHP84Migration <./PHP84Migration.rst>`_
- `@PHPUnit30Migration:risky <./PHPUnit30MigrationRisky.rst>`_
- `@PHPUnit32Migration:risky <./PHPUnit32MigrationRisky.rst>`_
- `@PHPUnit35Migration:risky <./PHPUnit35MigrationRisky.rst>`_
Expand Down
1 change: 1 addition & 0 deletions doc/rules/array_notation/array_syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ The rule is part of the following rule sets:

``['after_heredoc' => true]``

- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_ with config:

``['after_heredoc' => true]``

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

``['after_heredoc' => true]``
Expand Down
1 change: 1 addition & 0 deletions doc/rules/array_notation/normalize_index_brace.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

Expand Down
1 change: 1 addition & 0 deletions doc/rules/basic/octal_notation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_

References
----------
Expand Down
1 change: 1 addition & 0 deletions doc/rules/cast_notation/no_unset_cast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

Expand Down
1 change: 1 addition & 0 deletions doc/rules/cast_notation/short_scalar_cast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
- `@PSR12 <./../../ruleSets/PSR12.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_
Expand Down
1 change: 1 addition & 0 deletions doc/rules/class_notation/visibility_required.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
- `@PSR2 <./../../ruleSets/PSR2.rst>`_ with config:

``['elements' => ['method', 'property']]``
Expand Down
4 changes: 4 additions & 0 deletions doc/rules/control_structure/trailing_comma_in_multiline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ The rule is part of the following rule sets:

``['after_heredoc' => true]``

- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_ with config:

``['after_heredoc' => true]``

- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

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

``['after_heredoc' => true]``

- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_ with config:

``['after_heredoc' => true]``

- `@PSR2 <./../../ruleSets/PSR2.rst>`_ with config:

``['attribute_placement' => 'ignore', 'on_multiline' => 'ensure_fully_multiline']``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Rule sets

The rule is part of the following rule sets:

- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

Expand Down
1 change: 1 addition & 0 deletions doc/rules/list_notation/list_syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_

References
----------
Expand Down
1 change: 1 addition & 0 deletions doc/rules/namespace_notation/clean_namespace.rst
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:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_

References
----------
Expand Down
1 change: 1 addition & 0 deletions doc/rules/operator/ternary_to_null_coalescing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_

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

- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

Expand Down
1 change: 1 addition & 0 deletions doc/rules/whitespace/heredoc_indentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The rule is part of the following rule sets:
- `@PHP81Migration <./../../ruleSets/PHP81Migration.rst>`_
- `@PHP82Migration <./../../ruleSets/PHP82Migration.rst>`_
- `@PHP83Migration <./../../ruleSets/PHP83Migration.rst>`_
- `@PHP84Migration <./../../ruleSets/PHP84Migration.rst>`_

References
----------
Expand Down
31 changes: 31 additions & 0 deletions src/RuleSet/Sets/PHP84MigrationSet.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 <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* 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 PHP84MigrationSet extends AbstractMigrationSetDescription
{
public function getRules(): array
{
return [
'@PHP83Migration' => true,
'nullable_type_declaration_for_default_null_value' => true,
];
}
}
6 changes: 6 additions & 0 deletions tests/Fixtures/Integration/set/@PHP84Migration.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--TEST--
Integration of @PHP84Migration.
--RULESET--
{"@PHP84Migration": true}
--REQUIREMENTS--
{"php": 80400}
3 changes: 3 additions & 0 deletions tests/Fixtures/Integration/set/@PHP84Migration.test-in.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

function sample(string $str = null) {}
3 changes: 3 additions & 0 deletions tests/Fixtures/Integration/set/@PHP84Migration.test-out.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

function sample(?string $str = null) {}
22 changes: 22 additions & 0 deletions tests/RuleSet/Sets/PHP84MigrationSetTest.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 <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* 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\PHP84MigrationSet
*/
final class PHP84MigrationSetTest extends AbstractSetTestCase {}

0 comments on commit 2091e39

Please sign in to comment.