phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

Formatter: Option to ignore section or line or entire file

Open kanlukasz opened this issue 2 years ago • 3 comments

Description

The option to ignore sections or lines or entire file from the formatter would be very useful. As you know, there is no universal method of formatting everything, so exclusion can help sometimes. This would also solve the problem of potentially erroneous formatting, which can happen with complex weird files. What do you think?

Describe the solution you'd like

Maybe something like in Stylelint eg.:

/* stylelint-disable */
a {}
/* stylelint-enable */

Or like in phpcs:

<?php
// phpcs:ignoreFile

public function store($myArray) // phpcs:ignore
// @codingStandardsIgnoreStart
class MyClassTest extends \PHPUnit_Framework_TestCase
{
    // @codingStandardsIgnoreEnd
    // ...
}

kanlukasz avatar Apr 06 '23 16:04 kanlukasz

Hello,

This feature is available in the latest pre-release. Please take a look and let me know how it goes ;-)

The comments are: // @php-format off // @php-format on

or you can use any other comment type, the text is important.

Thank you

Miloslav avatar May 10 '23 10:05 Miloslav

Hi, Thank you for the quick implementation Did some quick tests. At first glance, it works fine

I only have doubts about the formatting of the line with the comment - details in the video below: phphphpph

kanlukasz avatar May 11 '23 10:05 kanlukasz

The comment tags worked great for me; however, I still need a single line ignore for certain complex statements (for example in a function argument) where two wrapping comments isn't ideal

godismyjudge95 avatar Oct 01 '23 02:10 godismyjudge95