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

Docblock space indents are being flagged as incorrect #6

Open
samwilson opened this issue Feb 26, 2015 · 7 comments
Open

Docblock space indents are being flagged as incorrect #6

samwilson opened this issue Feb 26, 2015 · 7 comments

Comments

@samwilson
Copy link

Is it correct that the following is not correct? (To mungle grammar at this early hour!)

/**
 * Comment about a thing.
 */

There is a single space at the beginning of the second two lines, before the asterisks.

@antonioribeiro
Copy link
Owner

Not sure what's happening, but I tested it here now:

<?php

namespace App;

class Whatever
{
    /**
     * Comment about a thing.
     */
    public function what_()
    {
    }
}

Forced one error and got this:

$ phpcs --standard=/tmp/LaravelCodeSniffer/Standards/Laravel/  test.php

FILE: /var/www/pragmarx/google2fa/src/test.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 10 | ERROR | Method name "Whatever::what_" is not in camel caps
    |       | format
----------------------------------------------------------------------

Time: 35ms; Memory: 3.25Mb

@samwilson
Copy link
Author

Hm, maybe try with a class docblock? Is it the spaces in column one that it's complaining about?

@antonioribeiro
Copy link
Owner

My point was: your docblock flagging was not related to this package but to php_codesniffer: https://github.com/squizlabs/PHP_CodeSniffer.

But I changed that class to do a full check with it:

<?php

/**
 * IPC_Test_Config
 *
 * PHP version 5
 *
 * @category Testing
 * @package  IPC.Test
 * @author   Rajat Pandit <rajat_pandit@ipcmedia.com>
 * @license  http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @link     http://ipcmedia.com
 */

namespace App;

/**
 * Class Whatever
 * @category Testing
 * @package  IPC.Test
 * @author   Rajat Pandit <rajat_pandit@ipcmedia.com>
 * @license  http://www.gnu.org/copyleft/gpl.html GNU General Public License
 * @link     http://ipcmedia.com
 */
class Whatever
{
    /**
     * Comment about a thing.
     *
     * @return null
     */
    public function what_()
    {
    }
}

And got

 $ phpcs test.php

FILE: /var/www/pragmarx/google2fa/src/test.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 32 | ERROR | Public method name "Whatever::what_" is not in camel
    |       | caps format
----------------------------------------------------------------------

Time: 30ms; Memory: 3.75Mb

Anyway, you are not showing me any error messages, only saying space indents are being flagged, so I can't really take a look at that for you.

But I don't think it's related to that space, because that one is supposed to be there.

@samwilson
Copy link
Author

Sorry, I should've been more thorough earlier! :) I was being a bit slapdash.

Here's the file I'm testing (test.php):

<?php

/**
 * Blah.
 */
class Test {

}

And error I'm getting:

$ phpcs --standard=/c/Users/samwilson/AppData/Roaming/Composer/vendor/pragmarx/laravelcs/Standards/Laravel/ test.php

FILE: C:\work\test.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
 4 | ERROR | [x] Tabs must be used to indent lines; spaces are not
   |       |     allowed
 5 | ERROR | [x] Tabs must be used to indent lines; spaces are not
   |       |     allowed
 6 | ERROR | [ ] Each class must be in a namespace of at least one
   |       |     level (a top-level vendor name)
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 30ms; Memory: 2Mb

@antonioribeiro
Copy link
Owner

Hmm... yeah, class doc blocks, I don't remember having touched them during development. Will have to take a look at it. But, anyway. Laravel 5.1 (May) is going to be PSR-2, so this package may not be needed anymore. :(

@samwilson
Copy link
Author

Yes, I just read about that. These sniffs will still be required for older code though. But yeah, I think I'll start using PSR-2 now anyway, so don't worry too much about this issue. Thanks for helping! :)

@Horki
Copy link

Horki commented Sep 21, 2016

as @samwilson said I'm having a same problem, is this fixable?
is there any way to exclude it when calling phpcs??
@antonioribeiro good work anyway

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

No branches or pull requests

3 participants