• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

keradus / PHP-CS-Fixer / 969
94%
1.11: 82%

Build:
Build:
LAST BUILD BRANCH: master
DEFAULT BRANCH: 1.11
Ran 26 Sep 2015 08:23AM UTC
Jobs 5
Files 148
Run time 3min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
969

push

travis-ci

Dariusz Ruminski
feature #1383 Introduce rules and sets (keradus)

This PR was squashed before being merged into the 2.0-dev branch (closes #1383).

Discussion
----------

Introduce rules and sets

Hi everyone!
Few changes that I have been working on lately...

I have tried to keep commits very clean to show what has changed step by step.
Below some description... Each point should match commit.
Please ignore merge commits, I will get rid of them later.

This PR may be big, so it may be worth to read changes commit by commit instead of all at once.
Please split discussion into two parts - first do we like changes described below and implemented, and then, if we agreed about changes, I will fill the docs and review of the code itself may begin.

1. **Introduce FixerFactory**
It's a class that will register build in fixers, allow to register custom fixers, sort them and attach config to them (see ConfigAwareInterface).
In future (see next changes in this PR) it will also allow to configure fixers.

2. **Replace level and fixers from configuration in favor of rules, remove getLevel from FixerInterface**
Closes #866 (ping @Seldaek).
Instead of setting level and fixers start setting rules. Many rules can be grouped in sets.
Eg to take all psr2 fixers, remove braces fixer and add strict fixer we can use:
CLI args:
`--rules=@PSR2,-braces,strict`
config file:
    ```php
    ->setRules([
        '@PSR2' => true,
        'braces' => false,
        'strict' => true,
    ])
    ```
One set can include other set (like `@Symfony` is `@PSR2` + extra fixers, `@PSR2` is `@PSR1` + other fixers).
When setting the rules set expand to it's definition and adding/removing fixers is doing step by step (so one may exclude set and then add one fixer from it).
For example, consider the following:
    ```
    @PSR1 = encoding,short_tag
    @PSR2 = @PSR1,braces,elseif
    @Symfony = @PSR2,return

    // then, one uses:
    --rules=strict,@Symfony,-@PSR2,@PSR1,-encoding
    // which expanded step by step into:
    --rules=strict,@PSR2,return,-@PSR2,@PSR1,-encoding
    --rules=strict,return,@PSR1,-encoding
    --rules=strict,return,encoding,short_tag,-encoding
    --rules=strict,return,short_tag
    ```
Also, remove getLevel method from FixerInterface.

3. **Add FixerInterface::configure method**
For now we have only way to turn fixer on or off, without possibility to configure how it should fix the code. This problem manifested first time with HeaderCommentFixer, when we have no way to configure the header itself!
Now, the fixers may have configuration (eg PhpUnitStrictFixer) and we have a way to change default configuration.
Setting the configuration for Fixers when using CLI tool is only possible in .php_cs file, not via CLI args.
In .php_cs file configuration is passed as part of rules definition:
    ```php
    ->setRules([
        '@PSR2' => true,
        'braces' => false,
        'strict' => true,
        'php_unit_strict' => [ 'assertEquals', 'assertNotEquals' ],
    ])
    ```
When a rule is false then fixer is off, when rule is truly then rule is on - especially when true it is on with default configuration and when it's array it is on and array is passed to configure method.
Also, remove Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader method

4. **Cache now detects configuration change not only by tool version and names of fixers, but also their configuration**
Closes #1305. (ping @GrahamCampbell)

5. **Disallow to set non-existing rules**

Commits
-------

b4ca035 Introduce rules and sets

4914 of 5569 relevant lines covered (88.24%)

361.93 hits per line

Jobs
ID Job ID Ran Files Coverage
2 969.2 26 Sep 2015 08:16AM UTC 0
89.15
Travis Job 969.2
3 969.3 26 Sep 2015 08:16AM UTC 0
89.62
Travis Job 969.3
4 969.4 26 Sep 2015 08:16AM UTC 0
89.74
Travis Job 969.4
5 969.5 26 Sep 2015 08:16AM UTC 0
89.93
Travis Job 969.5
7 969.7 26 Sep 2015 08:24AM UTC 0
71.27
Travis Job 969.7
Source Files on build 969
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #969
  • d1aec7bc on github
  • Prev Build on master (#953)
  • Next Build on master (#985)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc