Skip to content

Commit

Permalink
Merge branch 'master' into codito/config-option-for-fqcn-in-phpdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Dec 28, 2023
2 parents 1b2ef5d + 5a8a522 commit 9416449
Show file tree
Hide file tree
Showing 39 changed files with 590 additions and 112 deletions.
16 changes: 0 additions & 16 deletions .github/composite-actions/setup-php-with-composer-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,7 @@ runs:
shell: bash
run: composer config extra.symfony.require ${{ inputs.composer-flex-with-symfony-version }}

- name: Configure Symfony ^7
if: inputs.composer-flex-with-symfony-version == '^7'
shell: bash
run: |
composer remove facile-it/paraunit --dev --no-update
- name: Install Composer deps
uses: ./.github/composite-actions/install-composer-deps
with:
flags: ${{ inputs.composer-flags }}

- name: Mock ParaUnit under Symfony ^7
if: inputs.composer-flex-with-symfony-version == '^7'
shell: bash
run: |
echo '#!/usr/bin/env bash' > vendor/bin/paraunit
echo 'set -eu' >> vendor/bin/paraunit
echo 'shift' >> vendor/bin/paraunit
echo './vendor/bin/phpunit "${@}"' >> vendor/bin/paraunit
chmod +x vendor/bin/paraunit
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ jobs:
if: matrix.collect-code-coverage == 'yes'
run: sed 's/enforceTimeLimit="true"/enforceTimeLimit="false"/g' phpunit.xml.dist > phpunit.xml

- name: Disable time limit for tests under Windows # due to https://github.com/sebastianbergmann/phpunit/issues/5589
if: matrix.operating-system == 'windows-latest'
run: (Get-Content phpunit.xml.dist) -replace 'enforceTimeLimit="true"', 'enforceTimeLimit="false"' | Out-File phpunit.xml

- name: Run tests
if: matrix.run-tests == 'yes' && matrix.collect-code-coverage != 'yes'
env:
Expand All @@ -184,7 +188,7 @@ jobs:
if: matrix.run-tests == 'yes' && matrix.collect-code-coverage == 'yes'
env:
FAST_LINT_TEST_CASES: 1
run: vendor/bin/paraunit coverage --testsuite unit --exclude-group covers-nothing --clover build/logs/clover.xml
run: vendor/bin/paraunit coverage --testsuite unit --pass-through=--exclude-group=covers-nothing --clover=build/logs/clover.xml

- name: Upload coverage results to Coveralls
if: matrix.run-tests == 'yes' && matrix.collect-code-coverage == 'yes'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ projects. This tool does not only detect them, but also fixes them for you.
## Supported PHP Versions

* PHP 7.4
* PHP 8.0 (except PHP 8.0.0 due to [bug in PHP tokenizer](https://bugs.php.net/bug.php?id=80462))
* PHP 8.0
* PHP 8.1
* PHP 8.2
* PHP 8.3
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^9.6 || ^10.5.5",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"suggest": {
Expand Down Expand Up @@ -124,7 +124,7 @@
],
"test:coverage": [
"Composer\\Config::disableProcessTimeout",
"paraunit coverage --testsuite unit --exclude-group covers-nothing"
"@composer show facile-it/paraunit ^2 && (paraunit coverage --testsuite unit --pass-through=--exclude-group=covers-nothing) || (paraunit coverage --testsuite unit --exclude-group covers-nothing)"
],
"test:integration": [
"Composer\\Config::disableProcessTimeout",
Expand Down
50 changes: 50 additions & 0 deletions dev-tools/phpstan/baseline.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,56 @@
<?php declare(strict_types = 1);

$ignoreErrors = [];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\CheckCommand\\:\\:\\$defaultDescription has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/CheckCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\CheckCommand\\:\\:\\$defaultName has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/CheckCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\DescribeCommand\\:\\:\\$defaultName has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/DescribeCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\DocumentationCommand\\:\\:\\$defaultName has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/DocumentationCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\FixCommand\\:\\:\\$defaultDescription has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/FixCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\FixCommand\\:\\:\\$defaultName has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/FixCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\HelpCommand\\:\\:\\$defaultName has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/HelpCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\ListFilesCommand\\:\\:\\$defaultName has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/ListFilesCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\ListSetsCommand\\:\\:\\$defaultName has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/ListSetsCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Property PhpCsFixer\\\\Console\\\\Command\\\\SelfUpdateCommand\\:\\:\\$defaultName has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Console/Command/SelfUpdateCommand.php',
];
$ignoreErrors[] = [
'message' => '#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#',
'count' => 1,
Expand Down
1 change: 1 addition & 0 deletions doc/ruleSets/PER-CS2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Rules
-----

- `@PER-CS1.0 <./PER-CS1.0.rst>`_
- `cast_spaces <./../rules/cast_notation/cast_spaces.rst>`_
- `concat_space <./../rules/operator/concat_space.rst>`_ with config:

``['spacing' => 'one']``
Expand Down
5 changes: 4 additions & 1 deletion doc/ruleSets/PSR12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ Rules

- `single_trait_insert_per_statement <./../rules/class_notation/single_trait_insert_per_statement.rst>`_
- `ternary_operator_spaces <./../rules/operator/ternary_operator_spaces.rst>`_
- `unary_operator_spaces <./../rules/operator/unary_operator_spaces.rst>`_
- `unary_operator_spaces <./../rules/operator/unary_operator_spaces.rst>`_ with config:

``['only_dec_inc' => true]``

- `visibility_required <./../rules/class_notation/visibility_required.rst>`_
1 change: 1 addition & 0 deletions doc/ruleSets/PhpCsFixer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Rules
- `return_assignment <./../rules/return_notation/return_assignment.rst>`_
- `self_static_accessor <./../rules/class_notation/self_static_accessor.rst>`_
- `single_line_comment_style <./../rules/comment/single_line_comment_style.rst>`_
- `single_line_empty_body <./../rules/basic/single_line_empty_body.rst>`_
- `whitespace_after_comma_in_array <./../rules/array_notation/whitespace_after_comma_in_array.rst>`_ with config:

``['ensure_single_space' => true]``
Expand Down
14 changes: 12 additions & 2 deletions doc/ruleSets/Symfony.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Rules that follow the official `Symfony Coding Standards <https://symfony.com/do
Rules
-----

- `@PSR12 <./PSR12.rst>`_
- `@PER-CS2.0 <./PER-CS2.0.rst>`_
- `align_multiline_comment <./../rules/phpdoc/align_multiline_comment.rst>`_
- `array_syntax <./../rules/array_notation/array_syntax.rst>`_
- `backtick_to_shell_exec <./../rules/alias/backtick_to_shell_exec.rst>`_
Expand All @@ -20,7 +20,6 @@ Rules

``['allow_single_line_anonymous_functions' => true, 'allow_single_line_empty_anonymous_classes' => true]``

- `cast_spaces <./../rules/cast_notation/cast_spaces.rst>`_
- `class_attributes_separation <./../rules/class_notation/class_attributes_separation.rst>`_ with config:

``['elements' => ['method' => 'one']]``
Expand All @@ -40,6 +39,7 @@ Rules

- `empty_loop_condition <./../rules/control_structure/empty_loop_condition.rst>`_
- `fully_qualified_strict_types <./../rules/import/fully_qualified_strict_types.rst>`_
- `function_declaration <./../rules/function_notation/function_declaration.rst>`_
- `general_phpdoc_tag_rename <./../rules/phpdoc/general_phpdoc_tag_rename.rst>`_ with config:

``['replacements' => ['inheritDocs' => 'inheritDoc']]``
Expand Down Expand Up @@ -165,10 +165,20 @@ Rules

- `standardize_increment <./../rules/operator/standardize_increment.rst>`_
- `standardize_not_equals <./../rules/operator/standardize_not_equals.rst>`_
- `statement_indentation <./../rules/whitespace/statement_indentation.rst>`_ with config:

``['stick_comment_to_next_continuous_control_statement' => true]``

- `switch_continue_to_break <./../rules/control_structure/switch_continue_to_break.rst>`_
- `trailing_comma_in_multiline <./../rules/control_structure/trailing_comma_in_multiline.rst>`_
- `trim_array_spaces <./../rules/array_notation/trim_array_spaces.rst>`_
- `type_declaration_spaces <./../rules/whitespace/type_declaration_spaces.rst>`_
- `types_spaces <./../rules/whitespace/types_spaces.rst>`_
- `unary_operator_spaces <./../rules/operator/unary_operator_spaces.rst>`_
- `whitespace_after_comma_in_array <./../rules/array_notation/whitespace_after_comma_in_array.rst>`_
- `yoda_style <./../rules/control_structure/yoda_style.rst>`_

Disabled rules
--------------

- `single_line_empty_body <./../rules/basic/single_line_empty_body.rst>`_
3 changes: 3 additions & 0 deletions doc/rules/cast_notation/cast_spaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ Rule sets

The rule is part of the following rule sets:

- `@PER <./../../ruleSets/PER.rst>`_
- `@PER-CS <./../../ruleSets/PER-CS.rst>`_
- `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_

Expand Down
65 changes: 60 additions & 5 deletions doc/rules/operator/unary_operator_spaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@ Rule ``unary_operator_spaces``

Unary operators should be placed adjacent to their operands.

Configuration
-------------

``only_dec_inc``
~~~~~~~~~~~~~~~~

Limit to increment and decrement operators.

Allowed types: ``bool``

Default value: ``false``

Examples
--------

Example #1
~~~~~~~~~~

*Default* configuration.

.. code-block:: diff
--- Original
Expand All @@ -26,16 +40,57 @@ Example #1
+$sample = ~$c;
+function &foo(){}
Example #2
~~~~~~~~~~

With configuration: ``['only_dec_inc' => false]``.

.. code-block:: diff
--- Original
+++ New
<?php
-function foo($a, ... $b) { return (-- $a) * ($b ++);}
+function foo($a, ...$b) { return (--$a) * ($b++);}
Example #3
~~~~~~~~~~

With configuration: ``['only_dec_inc' => true]``.

.. code-block:: diff
--- Original
+++ New
<?php
-function foo($a, ... $b) { return (-- $a) * ($b ++);}
+function foo($a, ... $b) { return (--$a) * ($b++);}
Rule sets
---------

The rule is part of the following rule sets:

- `@PER <./../../ruleSets/PER.rst>`_
- `@PER-CS <./../../ruleSets/PER-CS.rst>`_
- `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_
- `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
- `@PSR12 <./../../ruleSets/PSR12.rst>`_
- `@PER <./../../ruleSets/PER.rst>`_ with config:

``['only_dec_inc' => true]``

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

``['only_dec_inc' => true]``

- `@PER-CS1.0 <./../../ruleSets/PER-CS1.0.rst>`_ with config:

``['only_dec_inc' => true]``

- `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_ with config:

``['only_dec_inc' => true]``

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

``['only_dec_inc' => true]``

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

Expand Down
71 changes: 69 additions & 2 deletions doc/rules/whitespace/statement_indentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@ Rule ``statement_indentation``

Each statement must be indented.

Configuration
-------------

``stick_comment_to_next_continuous_control_statement``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Last comment of code block counts as comment for next block.

Allowed types: ``bool``

Default value: ``false``

Examples
--------

Example #1
~~~~~~~~~~

*Default* configuration.

.. code-block:: diff
--- Original
Expand All @@ -24,6 +38,53 @@ Example #1
+ echo "bar";
}
Example #2
~~~~~~~~~~

With configuration: ``['stick_comment_to_next_continuous_control_statement' => false]``.

.. code-block:: diff
--- Original
+++ New
<?php
- // foo
+// foo
if ($foo) {
echo "foo";
- // this is treated as comment of `if` block, as `stick_comment_to_next_continuous_control_statement` is disabled
+ // this is treated as comment of `if` block, as `stick_comment_to_next_continuous_control_statement` is disabled
} else {
$aaa = 1;
}
Example #3
~~~~~~~~~~

With configuration: ``['stick_comment_to_next_continuous_control_statement' => true]``.

.. code-block:: diff
--- Original
+++ New
<?php
- // foo
+// foo
if ($foo) {
echo "foo";
- // this is treated as comment of `elseif(1)` block, as `stick_comment_to_next_continuous_control_statement` is enabled
+// this is treated as comment of `elseif(1)` block, as `stick_comment_to_next_continuous_control_statement` is enabled
} elseif(1) {
echo "bar";
} elseif(2) {
- // this is treated as comment of `elseif(2)` block, as the only content of that block
+ // this is treated as comment of `elseif(2)` block, as the only content of that block
} elseif(3) {
$aaa = 1;
- // this is treated as comment of `elseif(3)` block, as it is a comment in the final block
+ // this is treated as comment of `elseif(3)` block, as it is a comment in the final block
}
Rule sets
---------

Expand All @@ -35,8 +96,14 @@ The rule is part of the following rule sets:
- `@PER-CS2.0 <./../../ruleSets/PER-CS2.0.rst>`_
- `@PSR2 <./../../ruleSets/PSR2.rst>`_
- `@PSR12 <./../../ruleSets/PSR12.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_
- `@Symfony <./../../ruleSets/Symfony.rst>`_
- `@PhpCsFixer <./../../ruleSets/PhpCsFixer.rst>`_ with config:

``['stick_comment_to_next_continuous_control_statement' => true]``

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

``['stick_comment_to_next_continuous_control_statement' => true]``


Source class
------------
Expand Down

0 comments on commit 9416449

Please sign in to comment.