Giter VIP home page Giter VIP logo

gomzyakov / php-cs-fixer-config Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 295 KB

Use the same php-cs-fixer configuration across all of your projects

Home Page: https://packagist.org/packages/gomzyakov/php-cs-fixer-config

License: MIT License

PHP 78.59% Dockerfile 6.75% Makefile 14.66%
php code-style php-cs-fixer code-standards code-styles php-cs-fixer-config php-cs-fixer-ruleset laravel-pint pint code-styling laravel php-styles

php-cs-fixer-config's Introduction

Code-style configuration for php-cs-fixer

packagist downloads_count GitHub release license codecov

This package allows sharing identical php-cs-fixer formatting rules across all of your projects without copy-and-pasting configuration files.

Quickstart

Step 1 of 3

Install friendsofphp/php-cs-fixer & this package via Composer:

composer require --dev friendsofphp/php-cs-fixer gomzyakov/php-cs-fixer-config

Step 2 of 3

Then create file .php-cs-fixer.dist.php at the root of your project with following contents:

<?php

use Gomzyakov\CS\Finder;
use Gomzyakov\CS\Config;

// Routes for analysis with `php-cs-fixer`
$routes = ['./src', './tests'];

return Config::createWithFinder(Finder::createWithRoutes($routes));

Change the value of $routes depending on where your project's source code is.

Step 3 of 3

And that's it! You can now find code style violations with following command:

./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run

And then completely fix them all with:

./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php

Configuration

You must pass a set of routes to the Finder::createWithRoutes() call. For example, for Laravel projects, this would be:

Finder::createWithRoutes(['./app', './config', './database', './resources', './routes', './tests'])

Also, you can pass a custom set of rules to the Config::createWithFinder() call:

Config::createWithFinder($finder, [
    '@PHP81Migration'   => true,
    'array_indentation' => false
])

Laravel Pint

The following describes the use of styles in conjunction with friendsofphp/php-cs-fixer. Also you can use these style settings for Laravel Pint.

Support

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

License

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

Special thanks

php-cs-fixer-config's People

Contributors

dependabot[bot] avatar gomzyakov avatar letraceursnork avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-cs-fixer-config's Issues

Remove slashes before base classes

     /**
      * A list of the exception types that are not reported.
      *
-     * @var array<int, class-string<Throwable>>
+     * @var array<int, class-string<\Throwable>>
      */

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

composer
composer.json
  • php ^7.4 || ^8.0
  • friendsofphp/php-cs-fixer ^3.15
  • phpunit/phpunit ^10.0
  • phpstan/phpstan ^1.10
  • mockery/mockery ^1.5
docker-compose
docker-compose.yaml
dockerfile
Dockerfile
  • php 8.2.4-alpine
  • composer 2.5.5
github-actions
.github/workflows/tests.yml
  • actions/checkout v3
  • shivammathur/setup-php v2
  • codecov/codecov-action v3
  • actions/checkout v3
  • actions/checkout v3

  • Check this box to trigger a request for Renovate to run again on this repository

Redefining some parameters of complex rules is not working

You can not redefine a specific parameter of a complex rule like binary_operator_spaces -> default due to its complexity.

When you try redefine it like this:

'binary_operator_spaces'            => [
    'default'   => 'single_space',
],

operators option will reset to its PHP-CS-Fixer default instead of your package's default

Get rid of deprecation notices

Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\FilenameFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/finder/Iterator/FilenameFilterIterator.php:28
Deprecation Notice: Return type of Composer\Repository\CompositeRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/src/Composer/Repository/CompositeRepository.php:178
12 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\FileTypeFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/finder/Iterator/FileTypeFilterIterator.php:42
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php:55
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::hasChildren() should either be compatible with RecursiveIterator::hasChildren(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php:71
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator::getChildren() should either be compatible with RecursiveIterator::getChildren(): ?RecursiveIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php:76
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\FilterIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/finder/Iterator/FilterIterator.php:30
Deprecation Notice: Return type of Symfony\Component\Finder\Iterator\PathFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar:///usr/bin/composer/vendor/symfony/finder/Iterator/PathFilterIterator.php:27

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.