stefna / codestyle
Custom php sniffer for stefna
Installs: 23 746
Dependents: 28
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 6
pkg:composer/stefna/codestyle
Requires
- php: ^7.1 || ^8.0
- squizlabs/php_codesniffer: ^3.8.0
- 2.x-dev
- 1.x-dev
- 1.19.1
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.1
- 1.12.0
- 1.11.1
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.0
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.0
- 0.1.0
- dev-try-catch
- dev-support-async-properties
- dev-bracket-placement-in-constructor
- dev-TooManyBlankLines/Remove-Symbol-Skip
- dev-Issue/18
- dev-Namespaces/UseDoesNotStartWithBackslash
- dev-Classes/ClassLength
- dev-Sniff/ControlSignature
- dev-master
- dev-new-codestyle
This package is auto-updated.
Last update: 2026-01-27 13:32:23 UTC
README
Usage
vendor/bin/phpcs -n --standard=vendor/stefna/codestyle/library.xml src/
License
The MIT License (MIT). Please see License File for more information.
Sniffs
DeclareStrictSniff
Now enforces that <?php declare(strict_types=1);
becomes the first line in the file.
MultiLineFunctionDeclarationSniff
Add support for empty methods on a single line. Example:
class Example { public function empty(): void {}; }
Enforce multi row parameters to not be on the first row. Example:
class Example { public function test( #[Attribute] int $param, ) }
DocCommentSniff
Allows some doc blocks to work as single line:
- @var
- @phpstan-var
- @type
- @lang
- @noinspection
- @use
- @deprecated
- @phpstan-ignore-next-line
/** @var string $var */
@return doesn't need any description/data:
/** * @return */
ControlStructureSpacingSniff
Adding an exception to allow multiline if-statments to be indented less, if started on the same line as the opening parenthesis.
Example:
if (isset( $a['key'], $a['key']['subKey'], )) { }
CamelCapsMethodNameSniff
Allow a the custom case of everything being upper case.
class Example { public function METHOD(): void {} }
BracketPlacementSniff
Two rules are enfored by this.
First, a control statement has to be on it's own line. Example:
if (false) { doSomething(); } else { doSomethingElse(); }
Second, foces the closing bracket to be on it's own line except if it's on a single line with an empty body. Example:
if (false) {}
BlanLinesSniff
Enforces that inside a function, the first line after the opening { can't be empty
Example:
function test(): void { $var = 'This has to be the first line'; }
It also enforces that the spacing between rows can be 0 or 1 blank line. Example:
function test(): void { $var = 0; $var += 1; $var *= 2; }
StaticSniff
Now warns about closures to be static if they don't have $this in body
Example:
$closure = static function () { something(); }; $fn = static fn () => something();