Skip to content

Commit

Permalink
Merge branch 'master' into stan2
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Jan 10, 2024
2 parents 69e9b57 + d38fdc5 commit c978560
Show file tree
Hide file tree
Showing 20 changed files with 1,604 additions and 45 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/issues_and_pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
name: "Issues and Pull Requests"

on:
# Allow running on demand using Github UI
workflow_dispatch:
schedule:
- cron: "0 12 * * *"

Expand Down Expand Up @@ -34,7 +36,7 @@ jobs:
steps:
# Config reference: https://github.com/actions/stale
- name: "Handle stale issues and pull requests"
uses: "actions/stale@v8"
uses: "actions/stale@v9"
with:
close-issue-message: "${{ env.CLOSE_MESSAGE }}"
close-pr-message: "${{ env.CLOSE_MESSAGE }} When it comes to pull requests it may be better to create new one, on top of main branch."
Expand Down
86 changes: 86 additions & 0 deletions doc/rules/basic/numeric_literal_separator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
==================================
Rule ``numeric_literal_separator``
==================================

Adds separators to numeric literals of any kind.

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

``override_existing``
~~~~~~~~~~~~~~~~~~~~~

Whether literals already containing underscores should be reformatted.

Allowed types: ``bool``

Default value: ``false``

``strategy``
~~~~~~~~~~~~

Whether numeric literal should be separated by underscores or not.

Allowed values: ``'no_separator'`` and ``'use_separator'``

Default value: ``'no_separator'``

Examples
--------

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

*Default* configuration.

.. code-block:: diff
--- Original
+++ New
<?php
-$integer = 1234_5678;
-$octal = 01_234_56;
-$binary = 0b00_10_01_00;
-$hexadecimal = 0x3D45_8F4F;
+$integer = 12345678;
+$octal = 0123456;
+$binary = 0b00100100;
+$hexadecimal = 0x3D458F4F;
Example #2
~~~~~~~~~~

With configuration: ``['strategy' => 'use_separator']``.

.. code-block:: diff
--- Original
+++ New
<?php
-$integer = 12345678;
-$octal = 0123456;
-$binary = 0b0010010011011010;
-$hexadecimal = 0x3D458F4F;
+$integer = 12_345_678;
+$octal = 0123_456;
+$binary = 0b00100100_11011010;
+$hexadecimal = 0x3D_45_8F_4F;
Example #3
~~~~~~~~~~

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

.. code-block:: diff
--- Original
+++ New
-<?php $var = 24_40_21;
+<?php $var = 244021;
References
----------

- Fixer class: `PhpCsFixer\\Fixer\\Basic\\NumericLiteralSeparatorFixer <./../../../src/Fixer/Basic/NumericLiteralSeparatorFixer.php>`_
- Test class: `PhpCsFixer\\Tests\\Fixer\\Basic\\NumericLiteralSeparatorFixerTest <./../../../tests/Fixer/Basic/NumericLiteralSeparatorFixerTest.php>`_

The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.
6 changes: 6 additions & 0 deletions doc/rules/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ Basic
- `non_printable_character <./basic/non_printable_character.rst>`_ *(risky)*

Remove Zero-width space (ZWSP), Non-breaking space (NBSP) and other invisible unicode symbols.
- `numeric_literal_separator <./basic/numeric_literal_separator.rst>`_

Adds separators to numeric literals of any kind.
- `octal_notation <./basic/octal_notation.rst>`_

Literal octal must be in ``0o`` notation.
Expand Down Expand Up @@ -861,6 +864,9 @@ String Notation
- `heredoc_to_nowdoc <./string_notation/heredoc_to_nowdoc.rst>`_

Convert ``heredoc`` to ``nowdoc`` where possible.
- `multiline_string_to_heredoc <./string_notation/multiline_string_to_heredoc.rst>`_

Convert multiline string to ``heredoc`` or ``nowdoc``.
- `no_binary_string <./string_notation/no_binary_string.rst>`_

There should not be a binary flag before strings.
Expand Down
97 changes: 97 additions & 0 deletions doc/rules/phpdoc/phpdoc_align.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ Allowed values: ``'left'`` and ``'vertical'``

Default value: ``'vertical'``

``spacing``
~~~~~~~~~~~

Spacing between tag, hint, comment, signature, etc. You can set same spacing for
all tags using a positive integer or different spacings for different tags using
an associative array of positive integers ``['tagA' => spacingForA, 'tagB' =>
spacingForB]``. If you want to define default spacing to more than 1 space use
``_default`` key in config array, e.g.: ``['tagA' => spacingForA, 'tagB' =>
spacingForB, '_default' => spacingForAllOthers]``.

Allowed types: ``int`` and ``int[]``

Default value: ``1``

``tags``
~~~~~~~~

Expand Down Expand Up @@ -58,6 +72,13 @@ Example #1
+ * @param int $code an HTTP response status code
+ * @param bool $debug
+ * @param mixed &$reference a parameter passed by reference
*
* @return Foo description foo
*
- * @throws Foo description foo
+ * @throws Foo description foo
* description foo
*
*/
Example #2
Expand All @@ -81,6 +102,13 @@ With configuration: ``['align' => 'vertical']``.
+ * @param int $code an HTTP response status code
+ * @param bool $debug
+ * @param mixed &$reference a parameter passed by reference
*
* @return Foo description foo
*
- * @throws Foo description foo
+ * @throws Foo description foo
* description foo
*
*/
Example #3
Expand All @@ -104,6 +132,75 @@ With configuration: ``['align' => 'left']``.
+ * @param int $code an HTTP response status code
+ * @param bool $debug
+ * @param mixed &$reference a parameter passed by reference
*
* @return Foo description foo
*
- * @throws Foo description foo
+ * @throws Foo description foo
* description foo
*
*/
Example #4
~~~~~~~~~~

With configuration: ``['align' => 'left', 'spacing' => 2]``.

.. code-block:: diff
--- Original
+++ New
<?php
/**
- * @param EngineInterface $templating
- * @param string $format
- * @param int $code an HTTP response status code
- * @param bool $debug
- * @param mixed &$reference a parameter passed by reference
+ * @param EngineInterface $templating
+ * @param string $format
+ * @param int $code an HTTP response status code
+ * @param bool $debug
+ * @param mixed &$reference a parameter passed by reference
*
- * @return Foo description foo
+ * @return Foo description foo
*
- * @throws Foo description foo
- * description foo
+ * @throws Foo description foo
+ * description foo
*
*/
Example #5
~~~~~~~~~~

With configuration: ``['align' => 'left', 'spacing' => ['param' => 2]]``.

.. code-block:: diff
--- Original
+++ New
<?php
/**
- * @param EngineInterface $templating
- * @param string $format
- * @param int $code an HTTP response status code
- * @param bool $debug
- * @param mixed &$reference a parameter passed by reference
+ * @param EngineInterface $templating
+ * @param string $format
+ * @param int $code an HTTP response status code
+ * @param bool $debug
+ * @param mixed &$reference a parameter passed by reference
*
* @return Foo description foo
*
- * @throws Foo description foo
+ * @throws Foo description foo
* description foo
*
*/
Rule sets
Expand Down
45 changes: 45 additions & 0 deletions doc/rules/string_notation/multiline_string_to_heredoc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
====================================
Rule ``multiline_string_to_heredoc``
====================================

Convert multiline string to ``heredoc`` or ``nowdoc``.

Examples
--------

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

.. code-block:: diff
--- Original
+++ New
<?php
-$a = 'line1
-line2';
+$a = <<<'EOD'
+line1
+line2
+EOD;
Example #2
~~~~~~~~~~

.. code-block:: diff
--- Original
+++ New
<?php
-$a = "line1
-{$obj->getName()}";
+$a = <<<EOD
+line1
+{$obj->getName()}
+EOD;
References
----------

- Fixer class: `PhpCsFixer\\Fixer\\StringNotation\\MultilineStringToHeredocFixer <./../../../src/Fixer/StringNotation/MultilineStringToHeredocFixer.php>`_
- Test class: `PhpCsFixer\\Tests\\Fixer\\StringNotation\\MultilineStringToHeredocFixerTest <./../../../tests/Fixer/StringNotation/MultilineStringToHeredocFixerTest.php>`_

The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.
6 changes: 3 additions & 3 deletions src/Console/Output/Progress/PercentageBarOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public function __construct(OutputContext $context)
$this->context = $context;

$this->progressBar = new ProgressBar($context->getOutput(), $this->context->getFilesCount());
$this->progressBar->setBarCharacter('');
$this->progressBar->setEmptyBarCharacter('░');
$this->progressBar->setProgressCharacter('');
$this->progressBar->setBarCharacter(''); // dark shade character \u2593
$this->progressBar->setEmptyBarCharacter('░'); // light shade character \u2591
$this->progressBar->setProgressCharacter('');
$this->progressBar->setFormat('normal');

$this->progressBar->start();
Expand Down

0 comments on commit c978560

Please sign in to comment.