Php cs fixer rules

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A tool to automatically fix PHP code style

License

avto-dev/php-cs-fixer

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Читайте также:  Center table height css

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Автоматический Code Style Fixer для PHP

Данный пакет для composer позволяет запускать автоматический Code Style Fixer для PHP с фиксированным набором правил, принятых в качестве основных для оформления исходного php кода.

Require this package with composer using the following command:

$ composer require avto-dev/php-cs-fixer "^1.3"

В директории с вашим приложением выполните в терминале:

Опционально можете передать свои параметры запуска. При передаче параметра —config — все параметры, что формирует данный пакет — будут проигнорированы, и будет произведен запуск именно с теми параметрами, что будут переданы вами.

Если вам требуется опционально переопределить переопределить параметры правил fixer-а, то создайте в корне вашего приложения файл .cs_rules.php , возвращающий ассоциированный массив правил (более подробно о самих правилах можешь ознакомиться по этой ссылке). При его наличии его контент будет мерджиться с конфигом пакета, опционально перекрывая необходимые правила. Иметь он должен следующий вид:

 /** * CS Fixer Rules. * * @see https://github.com/FriendsOfPHP/PHP-CS-Fixer * @see https://mlocati.github.io/php-cs-fixer-configurator/ */ return [ '@PSR2' => true, '@PHP71Migration' => true, 'binary_operator_spaces' => [ 'operators' => [ '=' => 'align_single_space', '=>' => 'align_single_space', ], ], 'blank_line_after_namespace' => true, 'blank_line_after_opening_tag' => true, ];

Так же в корне можете разместить файл .cs_excludes.php , содержащий пути директорий, которые следует исключить при обработке, вида:

 /** * Excludes directories names. * * NOTE: excludes will works only for directories. */ return [ 'bootstrap', 'storage', 'vendor', 'public', 'resources', ];

Для переопределения пути файла кэша — установите в переменной окружения переменную с именем PHP_CS_FIX_CACHE_FILE_PATH , значение которой — необходимый путь. Например:

$ PHP_CS_FIX_CACHE_FILE_PATH=./.new.cache ./cs-fix

Более подробно о работе пакета — Look into the sources, Luke .

If you will find any package errors, please, make an issue in current repository.

This is open-sourced software licensed under the MIT License.

About

A tool to automatically fix PHP code style

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A tool to automatically fix PHP Coding Standards issues

License

PHP-CS-Fixer/PHP-CS-Fixer

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Co-authored-by: Dariusz Rumiński

Git stats

Files

Failed to load latest commit information.

README.md

PHP Coding Standards Fixer

The PHP Coding Standards Fixer (PHP CS Fixer) tool fixes your code to follow standards; whether you want to follow PHP coding standards as defined in the PSR-1, PSR-2, etc., or other community driven ones like the Symfony one. You can also define your (team’s) style through configuration.

It can modernize your code (like converting the pow function to the ** operator on PHP 5.6) and (micro) optimize it.

If you are already using a linter to identify coding standards problems in your code, you know that fixing them by hand is tedious, especially on large projects. This tool does not only detect them, but also fixes them for you.

Note Each new PHP version requires a huge effort to support the new syntax. That’s why the latest PHP version might not be supported yet. If you need it, please, consider supporting the project in any convenient way, for example with code contribution or reviewing existing PRs. To run PHP CS Fixer on yet unsupported versions «at your own risk» — leverage the PHP_CS_FIXER_IGNORE_ENV.

The recommended way to install PHP CS Fixer is to use Composer in a dedicated composer.json file in your project, for example in the tools/php-cs-fixer directory:

mkdir -p tools/php-cs-fixer composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer

For more details and other installation methods, see installation instructions.

Assuming you installed PHP CS Fixer as instructed above, you can run the following command to fix the files PHP files in the src directory:

tools/php-cs-fixer/vendor/bin/php-cs-fixer fix src

See usage, list of built-in rules, list of rule sets and configuration file documentation for more details.

If you need to apply code styles that are not supported by the tool, you can create custom rules.

Dedicated plugins exist for:

The PHP CS Fixer is maintained on GitHub at https://github.com/PHP-CS-Fixer/PHP-CS-Fixer. Bug reports and ideas about new features are welcome there.

You can reach us at https://gitter.im/PHP-CS-Fixer/Lobby about the project, configuration, possible improvements, ideas and questions, please visit us!

The tool comes with quite a few built-in fixers, but everyone is more than welcome to contribute more of them.

About

A tool to automatically fix PHP Coding Standards issues

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

[READ-ONLY] A Rule set for PHP-CS-Fixer mainly targeting PHP 7.1 or higher.

suin/php-cs-fixer-rules

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

A Rule set for PHP-CS-Fixer mainly targeting PHP 7.1 or higher. See Rules.php for the rules detail.

Installation via Composer

$ composer require --dev suin/php-cs-fixer-rules

Create .php_cs.dist in your project:

 return PhpCsFixer\Config::create() ->setRiskyAllowed(true) ->setRules(Suin\PhpCsFixer\Rules::create([ // If you want to overwrite default rules // add rules here. 'declare_strict_types' => false, ])) ->setFinder(PhpCsFixer\Finder::create() ->exclude('vendor') ->in(__DIR__) );

Please see CHANGELOG for more details.

Send issue or pull-request to main repository.

Источник

Оцените статью