Comments (13)
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.
This is code we use in a view.
from cakephp-codesniffer.
The standards are not meant to cover view files.
from cakephp-codesniffer.
I know, but it used to work and since a recent pear upgrade-all
it is broken.
from cakephp-codesniffer.
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.
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.
Closing as the standard is not intended to accept the syntax in the question.
from cakephp-codesniffer.
@AD7six Fine, but the above syntax does not work either if it's nested...
from cakephp-codesniffer.
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.
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.
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.
What about this test?
from cakephp-codesniffer.
A left over from before we restricted the standard to be used with php files only.
from cakephp-codesniffer.
Related Issues (20)
- Do not allow to use underscore prefixes HOT 1
- Error SlevoodingStandard.Arrays.TrailingAmatCrrayComma HOT 10
- Add an empty line between opening tag and declare HOT 2
- Allow for new major Slevomat v7
- PhpStorm HOT 1
- 5.0: Require static return type hint for chaining methods HOT 1
- Collection generics HOT 2
- Union type render fails in some cases
- Union type require spaces ? HOT 3
- Constructor property promotion HOT 3
- Cake 5 CS HOT 1
- Files are not queued by phpcs when using this standard HOT 3
- update links
- can support for slevomat/coding-standard v6 be removed? HOT 5
- Version 4.7 shows this warning HOT 1
- Compare PHP native param types and phpdoc param types
- ECS Support HOT 4
- Cake5: Dynamic property error with PHP 8.2 due to our ruleset HOT 1
- Enum case casing HOT 1
- Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Undefined property HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cakephp-codesniffer.