Comments (13)
Are you sure? There are a lot of build-in sniffs available.
from php_codesniffer.
As far as a generator that I use goes.
http://edorian.github.io/php-coding-standard-generator/
On 13 October 2014 11:14, Alexander Obuhovich [email protected]
wrote:
Are you sure? There are a lot of build-in sniffs available.
—
Reply to this email directly or view it on GitHub
#287 (comment)
.
- Bradley Weston ([email protected])
from php_codesniffer.
I've checked and you're right. There are none. But it's not a big deal to create any custom sniff from scratch or extend existing one. There are quite a few custom coding standards composed from build-in and custom-made sniffs out there. Mine for example: https://github.com/aik099/CodingStandard
To make standard self-sufficient I've copied over sniffs that I liked from other standards (not from build-in ones) to my standard and that's basically it.
I admit, that for starters writing own sniff or even extending existing one is a tough task especially if you haven't had any experience with PHP tokenizers in past. It also requires vast knowledge of all possible variations of PHP syntax (between different versions) to ensure that sniff only does what it is supposed to do and not some extra unwanted bit.
from php_codesniffer.
In other words I'm screwed aha :)
On 13 October 2014 11:22, Alexander Obuhovich [email protected]
wrote:
I've checked and you're right. There are none. But it's not a big deal to
create any custom sniff from scratch or extend existing one. There are
quite a few custom coding standards composed from build-in and custom-made
sniffs out there. Mine for example:
https://github.com/aik099/CodingStandardTo make standard self-sufficient I've copied over sniffs that I liked from
other standards (not from build-in ones) to my standard and that's
basically it.I admit, that for starters writing own sniff or even extending existing
one is a tough task especially if you haven't had any experience with PHP
tokenizers in past. It also requires vast knowledge of all possible
variations of PHP syntax (between different versions) to ensure that sniff
only does what it is supposed to do and not some extra unwanted bit.—
Reply to this email directly or view it on GitHub
#287 (comment)
.
- Bradley Weston ([email protected])
from php_codesniffer.
If we're talking about Laravel standard in general, then there is ticket about it: laravel/framework#5933
If you just need that coding standard to validate your own code, not on the CI server, then you might setup required configuration in PhpStorm coding standard and when doing code reformat it will automatically place brace on correct line.
from php_codesniffer.
But I recommend going for PHP_CodeSniffer option, because in 2.x version it also can auto-fix stuff. Compared to PhpStorm auto-fixing it's more advanced because you can write in sniff's PHP code what you need to be found and what needs to be fixed and how.
from php_codesniffer.
It will be for CI, to make sure my colleagues don't make my code look a
mess. I took a look at an example of PSR-2 class sniff and looked awful and
wasn't read-able to be honest.
On 13 October 2014 11:37, Alexander Obuhovich [email protected]
wrote:
But I recommend going for PHP_CodeSniffer option, because in 2.x version
it also can auto-fix stuff. Compared to PhpStorm auto-fixing it's more
advanced because you can write in sniff's PHP code what you need to be
found and what needs to be fixed and how.—
Reply to this email directly or view it on GitHub
#287 (comment)
.
- Bradley Weston ([email protected])
from php_codesniffer.
CI + PHP_CodeSniffer is a huge win. In my team I've configured PHP_CodeSniffer on each developer PhpStorm and on CI server as well. This way even if they miss an error locally CI server will still find it and e-mail them.
For now you can assemble your standard from existing sniffs and note somewhere what sniffs are missing. If after googling you are unable to find a particular sniffs, then maybe I can help you out by writing them for some $ of course.
from php_codesniffer.
I've Googled and not found anything. Will have to read into the sniffs more and get a good idea of it. Thanks for your time.
from php_codesniffer.
I've found where the code for the current standard is (PEAR_Sniffs_Classes_ClassDeclarationSniff), but my ruleset.xml
which means I don't know how to turn it of or even overwrite it with my modified version. Any ideas?
from php_codesniffer.
I don't know how to turn it off
Turning off particular error from a sniff is quite easy in fact. Just add following to your ruleset.xml
:
<rule ref="PEAR.Classes.ClassDeclaration.ShortNotCapital">
<severity>0</severity>
</rule>
In code above replace ShortNotCapital
with actual error code that is supplied to ->addError
call in the sniff's PHP code.
... even overwrite it with my modified version ...
It's PHP. Overwriting is done by creating your own sniff that extends that sniff and replacing required parts of PHP code with what you need.
from php_codesniffer.
When on about over-writing I mean so that is would use mine rather then theirs, if you extend something you still need a different class name how will it know to use my version? I have in fact created a fix but I don't know yet how to make it use mine.
from php_codesniffer.
In the ruleset.xml
you say from which sniffs your ruleset consists. You can either:
- include whole PEAR standard
- include all PEAR standard but not the specific sniffs you don't want
- manually cherry-pick sniffs you want only
Then, as long as you don't include sniff you extended the your sniff version will be used automatically.
Here you can find more about format of ruleset.xml
file: http://pear.php.net/manual/en/package.php.php-codesniffer.annotated-ruleset.php
from php_codesniffer.
Related Issues (20)
- Add an exception to a file for substring checking or exclude use or namespace checking HOT 1
- Autofixer for Squiz.WhiteSpace.FunctionSpacing goes into "infinite" loop for method defined on the same line as a class HOT 8
- Support multiline foreach in Squiz.ControlStructures.ForEachLoopDeclaration HOT 2
- Error executing phpunit. HOT 6
- Undefined index in FunctionDeclarationSniff HOT 3
- False positives for exception expression HOT 2
- PSR2.Methods.FunctionCallSignature.Indent cannot be exclude from command line HOT 2
- How to remove errors for specific comment or regex type string in a comment HOT 5
- Squiz.WhiteSpace.OperatorSpacing incorrectly adds space after bitwise operator HOT 3
- Generic.Files.LineLength miscalculates the length of line containing multibyte characters HOT 1
- Unnecessary line wrapping with `-s`
- PHP 8.3 - Typed class constants support HOT 6
- JavaScript: Indentation after object parameter HOT 2
- Auto fix of Squiz.Formatting.OperatorBracket.MissingBrackets is incorrect when working with ?? operator
- > Where Excel file import in codeigniter, the problem exists for phpexcel 1.8.0 on PHP 7 HOT 1
- The Future of PHP_CodeSniffer HOT 58
- PSR12.Files.FileHeader.SpacingAfterBlock: false positive when `use` is used for class and function HOT 1
- [PHP8.3] "final public const string JOURNEY" leads to "Class constants must be uppercase" HOT 4
- Allow lines to be longer than 80 chars if they're the first line in multi-line comments or part of annotations HOT 3
- Can't disable rule Underscore 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 php_codesniffer.