Coder Social home page Coder Social logo

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

View Code? Open in Web Editor NEW

This project forked from uptimeproject/php-cs-fixer-config

0.0 1.0 0.0 24 KB

This is a shared FriendsOfPHP/php-cs-fixer configuration used primarily in UptimeProject.io projects. But feel free to use it in your projects if you would like.

License: MIT License

PHP 100.00%

php-cs-fixer-config's Introduction

GitHub Workflow Status Packagist PHP Version Support Packagist PHP Version Support Packagist Downloads

This is a shared FriendsOfPHP/php-cs-fixer configuration used primarily in UptimeProject.io projects. But feel free to use it in your projects if you would like. Also, if you want to propose a change, feel free to create a PR ๐Ÿ˜

This package can be used on PHP 7.1, 7.2, 7.3, 7.4 and 8.0.

Installation

composer require --dev uptimeproject/php-cs-fixer-config

PHP-CS-Fixer 2.0

If you are still using v2.x of PHP-CS-Fixer in your project, you should use version <1.2.x of this package.

composer require --dev uptimeproject/php-cs-fixer-config:1.2.*

Note that this version is no longer maintained, and you should upgrade to the latest version of PHP-CS-Fixer

Usage

Create a .php-cs-fixer.php configuration file in the root of your project.

<?php

$config = new UptimeProject\PhpCsFixerConfig\Config;
$config->getFinder()
    ->in(__DIR__ . "/src")
    ->in(__DIR__ . "/tests");

return $config;

Also, make sure to ignore the .php_cs.cache file in your git repository.

Adding/overriding rules

It can be the case that you want to change something in the rules. No problem, you can override or add rules as follows:

<?php

$config = new UptimeProject\PhpCsFixerConfig\Config([
    'declare_strict_types' => true,
]);
$config->getFinder()
    ->in(__DIR__ . "/src")
    ->in(__DIR__ . "/tests");

return $config;

Be aware when you do this that risky fixers are allowed by default!

Example without risky fixers

<?php

$ruleOverrides = [
    'no_php4_constructor' => false,
    'pow_to_exponentiation' => false,
    'no_unneeded_final_method' => false,
    'no_unreachable_default_argument_value' => false,
    'php_unit_strict' => false,
    'psr4' => false,
];

$config = new UptimeProject\PhpCsFixerConfig\Config($ruleOverrides, false);

$config->getFinder()
    ->in(__DIR__ . '/src')
    ->in(__DIR__ . '/tests');

return $config;

License

The MIT License (MIT). Please see License File for more information.

php-cs-fixer-config's People

Contributors

frontendcoffee avatar

Watchers

 avatar

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.