Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squiz.WhiteSpace.FunctionSpacing incorrect fix when spacing is 0 #2601

Closed
wants to merge 2 commits into from
Closed

Squiz.WhiteSpace.FunctionSpacing incorrect fix when spacing is 0 #2601

wants to merge 2 commits into from

Conversation

JanGalek
Copy link

@JanGalek JanGalek commented Sep 5, 2019

Fix this usecase:

Settings

spacing: 0
spacingBeforeFirst: 0
spacingAfterLast: 0

Code:

<?php
declare(strict_types = 1);

namespace Nette\CodingStandard\Examples;

interface OneBlankLineBeforeFirstFunctionClassInterface
{


    /** @return mixed */
    public function interfaceMethod();
}

it was returning this:

<?php
declare(strict_types = 1);

namespace Nette\CodingStandard\Examples;

interface OneBlankLineBeforeFirstFunctionClassInterface
{/** @return mixed */
    public function interfaceMethod();
}

it return now correct this:

<?php
declare(strict_types = 1);

namespace Nette\CodingStandard\Examples;

interface OneBlankLineBeforeFirstFunctionClassInterface
{
    /** @return mixed */
    public function interfaceMethod();
}

JanGalek and others added 2 commits September 5, 2019 18:04
Fix this usecase:

Settings
------------
spacing: 0
spacingBeforeFirst: 0
spacingAfterLast: 0

Code:
```php
<?php
declare(strict_types = 1);

namespace Nette\CodingStandard\Examples;

interface OneBlankLineBeforeFirstFunctionClassInterface
{


    /** @return mixed */
    public function interfaceMethod();
}
```

was returning this:
```php
<?php
declare(strict_types = 1);

namespace Nette\CodingStandard\Examples;

interface OneBlankLineBeforeFirstFunctionClassInterface
{ /** @return mixed */
    public function interfaceMethod();
}
```

but now correct is

```php
<?php
declare(strict_types = 1);

namespace Nette\CodingStandard\Examples;

interface OneBlankLineBeforeFirstFunctionClassInterface
{
    /** @return mixed */
    public function interfaceMethod();
}
```
@JanGalek JanGalek changed the title Update FunctionSpacingSniff.php FunctionSpacingSniff before 0 usecase fixed Sep 5, 2019
@JanGalek JanGalek changed the title FunctionSpacingSniff before 0 usecase fixed [FunctionSpacingSniff] spacing before first - usecase 0 fixed Sep 5, 2019
@gsherwood gsherwood added this to Backlog in PHPCS v3 Development via automation Sep 9, 2019
@gsherwood gsherwood added this to the 3.5.0 milestone Sep 9, 2019
@gsherwood gsherwood changed the title [FunctionSpacingSniff] spacing before first - usecase 0 fixed Squiz.WhiteSpace.FunctionSpacing incorrect fix when spacing is 0 Sep 9, 2019
gsherwood added a commit that referenced this pull request Sep 9, 2019
@gsherwood
Copy link
Member

Thanks a lot for this report and PR. I ended up fixing this is a slightly different way so that it reflects how many of the other sniffs solve this problem, which is just to ignore any content of the same line as prevContent.

@gsherwood gsherwood closed this Sep 9, 2019
@gsherwood gsherwood moved this from Backlog to Ready for Release in PHPCS v3 Development Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PHPCS v3 Development
Ready for Release
Development

Successfully merging this pull request may close these issues.

None yet

2 participants