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.MemberVarSpacing.AfterComment fails to fix error when comment is not a docblock #983

Closed
matul91 opened this issue Apr 28, 2016 · 6 comments

Comments

@matul91
Copy link

matul91 commented Apr 28, 2016

If the file contains following code it is reported as an error and nothing is fixed.

<?php
/**
 * Comment
 *
 * @author Rather Unknown
 */
namespace Bar;

class Foo extends \Foo\Bar {

    //  here comes the comment

    private $caseStudy = null;

}

Output from phpcbf:
Processing Contract.php [PHP => 58 tokens in 16 lines]... DONE in 15ms (1 fixable violations)
* => Fixing file: 2/1 violations remaining [made 50 passes]... ERROR in 1.24 secs*
No fixable errors were found
Time: 1.3 secs; Memory: 6Mb

@matul91
Copy link
Author

matul91 commented Apr 28, 2016

If there is no blank line between a comment and a class member, everything works smoothly.

<?php
/**
 * Comment
 *
 * @author Me
 */

namespace Bar;

class Foo extends \Foo\Bar {

    //  here comes the comment
    private $caseStudy = null;

}

@gsherwood
Copy link
Member

What coding standard are you using?

I can't replicate any fixer errors with any of the included ones. If you are using a custom one, can you share it with me? It's quite possible that two sniffs are conflicting.

If you can't share it, can you post the output of this command: phpcs --standard=Squiz --report=diff -vv /path/to/file.php

@matul91
Copy link
Author

matul91 commented May 11, 2016

Hi,

We are using a custom ruleset definition what might be an issue. The ruleset is below.
``

<rule ref="Generic.Classes.DuplicateClassName"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.Commenting.Fixme"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.Files.LineEndings"/>
<rule ref="Generic.Files.LineLength">
    <properties>
        <property name="lineLimit" value="180"/>
        <property name="absoluteLineLimit" value=""/>
    </properties>
</rule>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
<rule ref="Generic.Metrics.NestingLevel"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<rule ref="PEAR.ControlStructures.ControlSignature"/>
<rule ref="PEAR.Functions.ValidDefaultValue"/>
<rule ref="PEAR.NamingConventions.ValidClassName"/>
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent"/>
<rule ref="PEAR.WhiteSpace.ScopeClosingBrace"/>
    <properties>
        <property name="exact" value="false"/>
    </properties>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration"/>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
<rule ref="PSR1.Files.SideEffects"/>
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
<rule ref="PSR2.Files.EndFileNewline"/>
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
<rule ref="Squiz.PHP.CommentedOutCode"/>
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
<rule ref="Squiz.PHP.Eval"/>
<rule ref="Squiz.PHP.ForbiddenFunctions"/>
<rule ref="Squiz.PHP.GlobalKeyword"/>
<rule ref="Squiz.PHP.Heredoc"/>
<rule ref="Squiz.PHP.InnerFunctions"/>
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<rule ref="Squiz.PHP.NonExecutableCode"/>
<rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
<rule ref="Squiz.Scope.MemberVarScope"/>
<rule ref="Squiz.Scope.MethodScope"/>
<rule ref="Squiz.Scope.StaticThisUsage"/>
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
    <properties>
        <property name="spacing" value="1"/>
    </properties>
</rule>
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<rule ref="Zend.Files.ClosingTag"/>

@gsherwood gsherwood changed the title Squiz.WhiteSpace.MemberVarSpacing.AfterComment freezes during fixing files by phpcbf Squiz.WhiteSpace.MemberVarSpacing.AfterComment fails to fix error when comment is not a docblock May 12, 2016
@gsherwood
Copy link
Member

Thanks for getting back to me. Your standard obviously leaves out some sniffs the included ones have, which gets the bug to appear. I've now fixed it. It was only a problem with inline comments above member vars.

@aik099
Copy link
Contributor

aik099 commented May 12, 2016

@gsherwood , which commit contains the fix?

@gsherwood
Copy link
Member

I typed the wrong bug ID in the commit. The fix is this one: 0434c48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants