antonioribeiro / laravelcs

Laravel PHP_CodeSniffer
BSD 3-Clause "New" or "Revised" License
234 stars 32 forks source link

Docblock space indents are being flagged as incorrect #6

Open samwilson opened 9 years ago

samwilson commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

antonioribeiro commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 8 years ago

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