Download the PHP package ely/php-code-style without Composer
On this page you can find all versions of the php package ely/php-code-style. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ely/php-code-style
More information about ely/php-code-style
Files in ely/php-code-style
Package php-code-style
Short Description Set of PHP-CS-Fixer rules used in the development of Ely.by PHP projects
License Apache-2.0
Homepage https://github.com/elyby/php-code-style
Informations about the package php-code-style
Ely.by PHP-CS-Fixer rules
Set of PHP-CS-Fixer rules used in development of Ely.by PHP projects. It's suited for PHP 7.4 and above.
Installation
First of all install Ely.by PHP-CS-Fixer rules via composer with PHP-CS-Fixer:
Then create a file .php-cs-fixer.php
with the following contents:
And that's it. You can now find code style violations with following command:
And then completely fix them all with:
Configuration
You can pass a custom set of rules to the \Ely\CS\Config::create()
call. For example, it can be used to validate a
project with PHP 7.4 compatibility:
Code style
Our code style is based primarily on PSR-2, while borrowing some ideas from PSR-12 with some changes.
Example
This example encompasses some of the rules below as a quick overview:
Key differences:
-
Opening braces for classes MUST be on the same line.
- Opening braces for methods MUST be on the next line.
Additional rules:
-
There MUST be one empty line before
return
statement, except when there is only one statement before it. -
There MUST be one blank line around class body, but there MUST be no blank lines around anonymous class body.
-
Visibility MUST be declared for all methods, properties and constants.
-
There MUST be one blank line after an each of
if
,switch
,for
,foreach
,while
anddo-while
bodies. - There MUST be no alignment around multiline function parameters.
All versions of php-code-style with dependencies
erickskrauch/php-cs-fixer-custom-fixers Version ^1.0.1
friendsofphp/php-cs-fixer Version ^3.16
kubawerlos/php-cs-fixer-custom-fixers Version ^3.13
symfony/polyfill-php80 Version ^1.15