Git Product home page Git Product logo

Comments (13)

AD7six avatar AD7six commented on September 17, 2024

That code example is missing all the braces. Except in view files, braces should always be used as it makes code easier to read.

from cakephp-codesniffer.

tersmitten avatar tersmitten commented on September 17, 2024

This is code we use in a view.

from cakephp-codesniffer.

ADmad avatar ADmad commented on September 17, 2024

The standards are not meant to cover view files.

from cakephp-codesniffer.

tersmitten avatar tersmitten commented on September 17, 2024

I know, but it used to work and since a recent pear upgrade-all it is broken.

from cakephp-codesniffer.

ADmad avatar ADmad commented on September 17, 2024

Well it's coincidental it worked for your views. Either stop using it for views or update your code to make the sniffer happy :)

I don't think it's a good idea to change the sniffs to cater to files it wasn't meant to cover in the first place.

from cakephp-codesniffer.

AD7six avatar AD7six commented on September 17, 2024

This is code we use in a view.

The only way that syntax is supposed to be used in a view is e.g.:

<?php if ($whatever): ?>
...
<?php elseif($somethingelse): ?>

Which isn't the syntax you're using.

But as ADmad has said, the standard isn't intended to be ran on view files

from cakephp-codesniffer.

AD7six avatar AD7six commented on September 17, 2024

Closing as the standard is not intended to accept the syntax in the question.

from cakephp-codesniffer.

tersmitten avatar tersmitten commented on September 17, 2024

@AD7six Fine, but the above syntax does not work either if it's nested...

from cakephp-codesniffer.

AD7six avatar AD7six commented on September 17, 2024
www-data @ dev [ /tmp ]
-> cat foo.php 
<?php
$a = 'a';
if (!empty($a)) {
    $b = 'b';
    if ($b === 'c') {
        $c = 'e';
    } elseif ($b === 'd') {
        $c = 'f';
    } else {
        $c = 'g';
    }
}
www-data @ dev [ /tmp ]
-> phpcs --standard=CakePHP foo.php 
Time: 68 ms, Memory: 3.00Mb

www-data @ dev [ /tmp ]
-> 

It works fine.

from cakephp-codesniffer.

tersmitten avatar tersmitten commented on September 17, 2024

But this one:

<?php $a = 'a'; ?>
<p>a</p>
<?php if (!empty($a)): ?>
    <p>c</p>
    <?php if ($b === 'c'): ?>
        <p>d</p>
    <?php elseif ($b === 'd'): ?>
        <p>e</p>
    <?php else: ?>
        <p>f</p>
    <?php endif; ?>
    <p>g</p>
<?php endif;

not.

from cakephp-codesniffer.

AD7six avatar AD7six commented on September 17, 2024

that's not supposed to pass... that syntax is appropriate for a view file which the standard is not designed to be used on.

from cakephp-codesniffer.

tersmitten avatar tersmitten commented on September 17, 2024

What about this test?

from cakephp-codesniffer.

AD7six avatar AD7six commented on September 17, 2024

A left over from before we restricted the standard to be used with php files only.

from cakephp-codesniffer.

Related Issues (20)

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.