consistence / coding-standard Goto Github PK
View Code? Open in Web Editor NEWConsistence - Coding Standard - PHP Code Sniffer rules
License: Other
Consistence - Coding Standard - PHP Code Sniffer rules
License: Other
The ruleset SlevomatCodingStandard.ControlStructures.YodaComparison
has been removed. Please update the ruleset as this breaks phpcs
, at least within the vscode plugin currently.
It appears this sniff has been updated to DisallowYodaComparisonSniff
.
Reasons:
slevomat/coding-standard
has some updated sniffs for PHP 7.4. Are there any blockers from supporting this version?
When using closure with multiple parameters each on new line, sniffer requires every variable in use
to be each on new line too.
Example:
$foo = 1;
$bar = 2;
static function (
bool $param1,
bool $param2
) use ($foo, $bar): int {
return $foo + $bar;
}
…leads to…
ERROR | [x] Multi-line use declarations must define one parameter per line
| (Squiz.Functions.MultiLineFunctionDeclaration.UseOneParamPerLine)
Expected behaviour:
This should be fine since each parameter is defined on separate line. To put variables in use
each on new line indeed let sniffer to pass; but it leads to worse code readability.
I didn't know this was possible to write, but it actually works - omitting the whitespace between type definition and parameter name:
Minimal reproducible code:
<?php
try {
} catch (\Exception$e) {
}
use Throwable;
class InvalidResponseException extends Exception
{
public function __construct(Validator $validator, ?Throwable $previous = null)
{
// ...
}
This reports Exception is not chainable. It must have optional \Throwable as last constructor argument and has "Throwable".
Because of this commit, the last minor update of slevomat/coding-standard is not supported anymore.
PHP 7 added new language features that can be formatted in different ways. It would be great if Consistence can define its way to format them. e.g.
declare(strict_types = 1)
- just after the PHP or on a new line?Any plans to update this lib to support PHP8? It could be as simple as adding ^7.0|^8.0
to the composer.json
config.
What is the reason for excluding Squiz.WhiteSpace.FunctionSpacing.After
here? With this, you can separate methods by any number of empty lines. May I send PR removing this exclusion?
Currently the negation formatting is not explicitly specified in the standard.
It can be written either:
if (!is_array($foo))
if (! is_array($foo))
if ( ! is_array($foo))
In the Scalar types chapter there is a code example which includes negation formatted without spaces around:
<?php
if (!is_int($foo)) {
return (int) $foo;
}
So it would be nice to have it explicitly stated in the coding standard. Maybe eventually also checked automatically (but PHP_CodeSniffer currently offers only SpaceAfterNotSniff
).
This would allow to drop "blank line after class opening bracket" and "blank line before class closing bracket" rules in custom stylesheets thanks to new options.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.