litus/php-cs

This package is abandoned and no longer maintained. The author suggests using the litus/php-cs-fixer package instead.

dev-master 2018-03-02 11:31 UTC

This package is not auto-updated.

Last update: 2019-02-20 17:54:51 UTC


README

This project contains a custom fixer for php-cs-fixer. If a php file doesn't contain a license header, it is added. If the license header in the php file is different than the supplied file, the php file is updated.

Usage

Add the following to composer.json:

{
    ...
    "require": {
        "litus/php-cs": "dev-master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/LitusProject/PhpCodeStyle"
        }
    ],
    ...
}

Create a .license_header file (or pick any filename you want) and put the license header in this file.
Note: Add an unformatted version of the license header!

Create a .php_cs file:

<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
    ->in(__DIR__);

return Litus\CodeStyle\Config\Config::create()
    ->setLicense(__DIR__ . '/.license_header') // or the filename you chose
    ->finder($finder);

Code Style

We conform to the PSR-2 and PSR-4 coding styles with the following exceptions:

  • We only have one use statement per file instead of one statement per declaration
  • We sometimes do prepend private variables and methods with an underscore ('_')
    note to ourselves: the "sometimes" indicates we're doing this wrong
  • We do not use a vendor namespace for the main project