Giter Site home page Giter Site logo

yii-coding-standard's People

Contributors

ardem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii-coding-standard's Issues

Current line icon not showing

Hey amazing plugin, only problem I am having is that the current line icon isn't showing in the gutter. I can see which line I am on in the Xdebug Stack window, and if I step through it updates accordingly, and I can see the breakpoints in the gutter, but no visual indication of the current line.

I am running OSX 10.9 and ST3 3059.

Xdebug.sublime-settings:

{
    "close_on_stop": true,  
}

multi line FOR-Statement is classified as single line, giving false error

I have the following input:

for ($i=0;$i<$this->months;$i++) {
  $monthStart = ...

and i get the following error:

54 | ERROR | Single line "FOR" must have an expression started from new line.

i have looked into the sniff and from my understanding it is wrongly thinking of this for-statement as a single line for statement and so it can not understand the code.

i have written the following test code:

for ($i=0;$i<10;$i++) 
    doSomething();

for ($i=0;$i<10;$i++) doSomething();

for ($i=0;$i<10;$i++) {
    doSomething();
}

the sniff breaks for the second and third for-statement.

i think there is a problem in line 60 of Yii/Sniffs/ControlStructures/SingleLineWithoutBracesSniff.php because the search for the opening curly bracket is done "local" so it stops at the first semikolon. In a for statement the semikolon is used inside the declaration before the opening curly bracket.

simply doing a non-local search does not fix the problem as in the above testcase no error would be found (missing the second for-statement).

maybe i can later write a patch.

UTF-8 detection detects ASCII in some cases

the mb_detect_encoding function sometimes detects ASCII instead of utf8 and then gives an error.

reproduce:
create a file utf-8 encoded but with only ascii complient characters in it.
codesniff the file

it now says
"File must use only UTF-8 encoding. but ASCII found"

utf-8 detection re-issued

Hi,

sorry for opening this again.

The issue is still there as just like the mb_detect_encoding function file also just detects the encoding by which character type is found in it. therefor an utf-8 encoded file without characters outside the ascii range is detected as ascii. no matter how explicitly you say it should be saved as utf 8. opening the file in vim and asking ":set fileencoding?" or ":set encoding?" returns utf 8.

the detection fails because the function returns ascii (which is a subset of utf8) even though it is utf-8 encoded.

Incorrect single line else complaint

public function testMethod()
{
    if (true)
        return true;
    else
        return setFalse();
}

This triggers a false alarm.
Suggested fix:

        $newline = false;

        while (in_array($tokens[$closeBracket + $n]['type'], array('T_WHITESPACE', 'T_SEMICOLON'))) {
            $strlen = strlen($tokens[$closeBracket + $n]['content']);
            if ($tokens[$closeBracket + $n]['content'][$strlen - 1] == $phpcsFile->eolChar) {
                $newline = true;
                break;
            }
            $n++;
        }

Make standard *really* installable via Composer

There's a problem with sandboxed installation using Composer.

PHP_CodeSniffer accepts the external standard only if it's toplevel directory is named the same as the standard. So, after the following:

$ php composer.phar install --dev
$ phpcs --standard=./vendor/ardem/yii-coding-standard ./src

I get the following irrelevant fatal error:

PHP Fatal error:  Cannot redeclare class Yii_Sniffs_Objects_ObjectParenthesesSniff in /home/hijarian/projects/YiiBooster/vendor/ardem/yii-coding-standard/Sniffs/Objects/ObjectParenthesesSniff.php on line 28
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpcs:0
PHP   2. PHP_CodeSniffer_CLI->process() /usr/bin/phpcs:37
PHP   3. PHP_CodeSniffer->process() /usr/share/php/PHP/CodeSniffer/CLI.php:579
PHP   4. PHP_CodeSniffer->populateTokenListeners() /usr/share/php/PHP/CodeSniffer.php:462
PHP   5. PHP_CodeSniffer::autoload() /usr/share/php/PHP/CodeSniffer.php:0
PHP   6. include() /usr/share/php/PHP/CodeSniffer.php:283

After I rename yii-coding-standard to Yii (thus corrupting the Composer installation) the invocation

$ phpcs --standard=./vendor/ardem/Yii ./src

does its job at last.

I suppose if you are going to have a Composer-installable library this issue should be resolved...

Yii 1.x coding standard for Allman structure not in standards file

According to the docs at https://github.com/yiisoft/yii/wiki/Core-framework-code-style, the structure for braces should follow Allman structure at http://en.wikipedia.org/wiki/Indent_style#Allman_style

if (x == y)
{
something();
somethingelse();
}

However, this structure will error
ERROR | Expected "if (...) {\n"; found "if(...)\n{\n"

using the coding standard files, it's wanting the following:

if (x == y) {
something();
somethingelse();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.