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

No space after class name generates: Class name "" is not in camel caps format #663

Closed
lucascube opened this issue Jul 31, 2015 · 4 comments

Comments

@lucascube
Copy link

So I'm new to CodeSniffer and I was hoping to get a good understanding as to why this error keep occurring on existing and new code. The error is Class name "" is not in camel caps format and it happens using PSR1.

phpcs --standard=PSR1 '/var/www/webroot/paypalipn/Test/CodeSniffer/Test.php'

FILE: /private/var/www/webroot/paypalipn/Test/CodeSniffer/Test.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 15 | ERROR | Class name "" is not in camel caps format
----------------------------------------------------------------------

Time: 9ms; Memory: 2.5Mb

FILE CONTENT:

<?php
/**
 * File DOC
 */
namespace Test\CodeSniffer;

/**
 * Class Test
 *
 * @package Test\CodeSniffer
 * @author  ${USER} <${USER}@datajoe.com>
 * @date    ${DATE}
 * @version 1
 */
class Test{
    /**
     * constructor
     */
    public function __construct(){
        echo "Testing";
    }
}
phpcbf --standard=PSR1 --encoding=utf-8 -w -v -a -s '/var/www/webroot/paypalipn/Test/CodeSniffer/Test.php'
Changing into directory /private/var/www/webroot/paypalipn/Test/CodeSniffer
Processing Test.php [PHP => 97 tokens in 22 lines]... DONE in 8ms (0 fixable violations)
No fixable errors were found
Time: 12ms; Memory: 2.25Mb

A more verbose run:

phpcs --standard=PSR1 --encoding=utf-8 -w -v -a -s '/var/www/webroot/paypalipn/Test/CodeSniffer/Test.php'
Registering sniffs in the PSR1 standard... DONE (7 sniffs registered)
Creating file list... DONE (1 files in queue)
Changing into directory /private/var/www/webroot/paypalipn/Test/CodeSniffer
Processing Test.php [PHP => 97 tokens in 22 lines]... DONE in 5ms (1 errors, 0 warnings)

FILE: /private/var/www/webroot/paypalipn/Test/CodeSniffer/Test.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 15 | ERROR | Class name "" is not in camel caps format
    |       | (Squiz.Classes.ValidClassName.NotCamelCaps)
----------------------------------------------------------------------
@aik099
Copy link
Contributor

aik099 commented Jul 31, 2015

Please do this to made bug report more readable:

  • format phpcs command output using fenced code blocks
  • put file contents in question in a gist or format it using fenced code blocks as well

@gsherwood
Copy link
Member

I've fixed the comment.

@gsherwood gsherwood changed the title Class name "" is not in camel caps format PRS1 No space after class name generates: Class name "" is not in camel caps format Jul 31, 2015
gsherwood added a commit that referenced this issue Jul 31, 2015
@gsherwood
Copy link
Member

This was caused by a specific sniff assuming there would be a space between the class name and the opening brace, which is obviously not the case in your code. I've now fixed this bug.

@lucascube
Copy link
Author

Thank you for fixing my post. I'll try to remember to format it in future use. Also, another thank you for fixing this bug.

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