All Projects → refinery29 → php-cs-fixer-config

refinery29 / php-cs-fixer-config

Licence: MIT License
📓 Provides a configuration for friendsofphp/php-cs-fixer, used within Refinery29.

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to php-cs-fixer-config

panzerlop
Configuration Guides for fixing things in Linux, Proton & KDE
Stars: ✭ 23 (-46.51%)
Mutual labels:  config
phpcsfixer-preset
Use the same php-cs-fixer configuration across all of your projects, with presets for common project layouts (Laravel, Composer packages, etc.).
Stars: ✭ 22 (-48.84%)
Mutual labels:  php-cs-fixer
haf
A fully typed 🔒, cross-platform, persistent 💾 config ⚙️ solution for your NodeJS projects with a great developer experience!
Stars: ✭ 186 (+332.56%)
Mutual labels:  config
goodconf
Transparently load variables from environment or JSON/YAML file.
Stars: ✭ 80 (+86.05%)
Mutual labels:  config
rubric
Linter Config Initializer for Python
Stars: ✭ 21 (-51.16%)
Mutual labels:  config
smallrye-config
SmallRye Config - A Java Configuration library
Stars: ✭ 74 (+72.09%)
Mutual labels:  config
eslint-config-hardcore
The most strict (yet practical) ESLint config. 34 plugins. 1047 rules.
Stars: ✭ 168 (+290.7%)
Mutual labels:  config
autorice
Autorice 9001 ~ Simple and fast arch setup in minutes
Stars: ✭ 55 (+27.91%)
Mutual labels:  config
play-rconf
Remote configuration for Play Framework
Stars: ✭ 17 (-60.47%)
Mutual labels:  config
mozitools
Mozi Botnet related tools helping to unpack a sample, decode a configuration and track active Mozi nodes using DHT.
Stars: ✭ 23 (-46.51%)
Mutual labels:  config
rails-settings-cached
Global settings for your Rails application.
Stars: ✭ 940 (+2086.05%)
Mutual labels:  config
Config
PHP library for simple configuration management
Stars: ✭ 39 (-9.3%)
Mutual labels:  config
renovate-config
My shareable config for @renovateapp
Stars: ✭ 28 (-34.88%)
Mutual labels:  config
dotfiles
My personal app/env configs and dotfiles.
Stars: ✭ 27 (-37.21%)
Mutual labels:  config
ecs-gen
docker-gen for AWS ECS
Stars: ✭ 46 (+6.98%)
Mutual labels:  config
eslint-define-config
Provide a defineConfig function for .eslintrc.js files
Stars: ✭ 61 (+41.86%)
Mutual labels:  config
curator
Config curator is CLI tool for installing static configuration files.
Stars: ✭ 29 (-32.56%)
Mutual labels:  config
prathimacode-hub
Hello everyone, Welcome to my GitHub README profile. Glad to see you here! Check out this repository to view my work and learn more about me. Don't just star it, fork it as well.📢✌️
Stars: ✭ 53 (+23.26%)
Mutual labels:  config
set-config-resolver
[READ-ONLY] Loads configs to you with CLI --config, -c, --set, -s or sets parameter
Stars: ✭ 50 (+16.28%)
Mutual labels:  config
nvimrc
My Neovim configuration. Supports macOS and Linux.
Stars: ✭ 31 (-27.91%)
Mutual labels:  config

php-cs-fixer-config

Build Status Code Climate Test Coverage Latest Stable Version Total Downloads

This repository provides configurations for friendsofphp/php-cs-fixer, which we use to verify and enforce a single coding standard for PHP code within Refinery29.

Installation

Run

$ composer require --dev refinery29/php-cs-fixer-config

Usage

Pick a configuration

The following configurations are available:

  • Refinery29\CS\Config\Php56
  • Refinery29\CS\Config\Php70
  • Refinery29\CS\Config\Php71

Configuration

Create a configuration file .php_cs in the root of your project:

<?php

$config = new Refinery29\CS\Config\Php56();
$config->getFinder()->in(__DIR__);

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;

$config->setCacheFile($cacheDir . '/.php_cs.cache');

return $config;

💡 Optionally, you can specify a header comment to use, which will automatically enable the header_comment fixer:

$header = <<<EOF
Copyright (c) 2016 Refinery29, Inc.

For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
EOF;

$config = new Refinery29\CS\Config\Php56($header);

Git

Add .php_cs.cache (this is the cache file created by php-cs-fixer) to .gitignore:

vendor/
.php_cs.cache

Travis

Update your .travis.yml to cache the php_cs.cache file:

cache:
  directories:
    - $HOME/.php-cs-fixer

Then run php-cs-fixer in the script section:

script:
  - vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --diff --dry-run

If you only want to run php-cs-fixer on one PHP version, update your build matrix and use a condition:

matrix:
  include:
    - php: 5.5
      env: WITH_CS=true
    - php: 5.6
      env: WITH_COVERAGE=true

script:
  - if [[ "$WITH_CS" == "true" ]]; then vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --diff --dry-run; fi

Makefile

Create a Makefile with a composer (because we're lazy) and a cs target:

composer:
	composer validate
	composer install

cs: composer
	vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --diff

Fixing issues

Manually

If you need to fix issues locally, just run

$ make cs

Pre-commit hook

You can add a pre-commit hook

$ touch .git/pre-commit && chmod +x .git/pre-commit

Paste this into .git/pre-commit:

#!/usr/bin/env bash

echo "pre commit hook start"

CURRENT_DIRECTORY=`pwd`
GIT_HOOKS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

PROJECT_DIRECTORY="$GIT_HOOKS_DIR/../.."

cd $PROJECT_DIRECTORY;
PHP_CS_FIXER="vendor/bin/php-cs-fixer"

HAS_PHP_CS_FIXER=false

if [ -x "$PHP_CS_FIXER" ]; then
    HAS_PHP_CS_FIXER=true
fi

if $HAS_PHP_CS_FIXER; then
    git status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do
        ${PHP_CS_FIXER} fix --config=.php_cs --verbose ${line};
        git add "$line";
    done
else
    echo ""
    echo "Please install php-cs-fixer, e.g.:"
    echo ""
    echo "  composer require --dev friendsofphp/php-cs-fixer:^2.2.0
    echo ""
fi

cd $CURRENT_DIRECTORY;
echo "pre commit hook finish"

💡 See https://gist.github.com/jwage/c4ef1dcb95007b5be0da by @jwage (adjusted by @rcatlin for @refinery29).

Contributing

Please have a look at CONTRIBUTING.md.

License

This package is licensed using the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].