Coder Social home page Coder Social logo

mlocati / php-cs-fixer-configurator Goto Github PK

View Code? Open in Web Editor NEW
249.0 10.0 16.0 8.67 MB

Inspect PHP-CS-Fixer fixers and easily configure them

Home Page: https://mlocati.github.io/php-cs-fixer-configurator/

License: MIT License

PHP 15.70% Batchfile 0.02% TypeScript 42.85% Vue 39.50% HTML 0.34% JavaScript 0.37% SCSS 0.58% Dockerfile 0.64%
php coding style php-cs-fixer

php-cs-fixer-configurator's Introduction

Build

PHP-CS-Fixer Configurator

This project lets you check all the available fixers and presets built in PHP-CS-Fixer in a visual way.

It allows you also to create configuration files via a guided interface.

Updating the PHP-CS-Fixer data

The PHP-CS-Fixer data is extracted by a couple of PHP scripts.

NOTE: on Windows, use backslashes (\) instead of forward slashes (/).

One time setup

  1. install PHP
  2. install Composer and add it to the PATH environment variable, so that it can be executed by running composer

Updating the data to the most recent versions

./bin/update-docs-all

(Re)Generate the data for all the versions

./bin/update-docs-all --force

Generating the data for a specific version

For example, to (re) generate the data for version 2.15.1:

./bin/update-docs 2.15.1

Building the web application

The web application is written in TypeScript and Vue, and it's compiled with Laravel Mix.

One time setup

  1. install node.js - including npm.
  2. run
    npm install

Building the app for production

npm run prod

Building the app while developing

npm run watch

Submitting pull requests

Because of security reasons and to reduce merge conflicts, the following files are generated automatically:

  • docs/css/*
  • docs/fonts/*
  • docs/js/*
  • docs/index.html

So, please don't add these files to your commits when submitting pull requests.

Credits

PHP-CS-Fixer Configurator uses some great open source tools.

You can find their licenses in the licenses directory.

Do you want to really say thank you?

You can offer me a monthly coffee or a one-time coffee 😉

php-cs-fixer-configurator's People

Contributors

ckrack avatar dependabot[bot] avatar ghoelian avatar gridark avatar keradus avatar mlocati avatar shikachuu avatar web-flow avatar wikando-ck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-cs-fixer-configurator's Issues

Little bugs

At first, thank you for that nice service!

Bugs:

  1. Wrong examples:
    [
        'break',
        'continue',
        'declare',
        'return',
        'throw',
        'try',
    ]

this is NOT JSON array:

Strings are delimited with double-quotation marks

, after last element, maybe fix here:

if ($first === true) {

  1. Switch between Define custom value and Use default value reset my value in textarea.

No blank lines between properties

Hello, I am using PHP 7.4.

Given the following snippet:

<?php
class Example
{
    public const FOO = 1;
    public static $bar = [1, 2, 3];
    private bool $baz = false;
    private $qux = [];
    private float $quux = 5.0;
}

When I run the fixer it is transformed to:

<?php
class Example
{
    public const FOO = 1;

    public static $bar = [1, 2, 3];

    private bool $baz = false;

    private $qux = [];

    private float $quux = 5.0;
}

But according to PSR-12 it should be like the first example. Isn't? 😄

Best,

Ordering enums

I would love to get an 'ordered_enum_elements' like 'ordered_class_elements' fixer.

I would think the options would be 'false' (don't order, leave alone even if 'ordered_class_elements') or 'sort_algorithm' = 'name' or 'value'.

My use case is this:

enum IncludeMembership : int
	{
	case NO = 0;
	case NEW_MEMBERS_ONLY = 1;
	case EXTEND_MEMBERSHIP = 2;
	case RENEW_MEMBERSHIP = 3;
	}

I would order it by value, but I can see a use case to order by name, or don't order at all. Currently it defaults to 'order_class_elements', but I use enums in the user interface, so the order makes a difference to me.

I would be happy to submit a PR, but would like some guidance as to what this should be called, the options and also where to implement this.

Thanks for the help.

`t.enabled undefined` on Style-CI export without rules

Current Behaviour

In an Style-CI export without rules it prints t.enabled undefined.
image

Reproduce

If you fresh open the main page go to Export and pick Style-CI in the Format dropdown it will print undefined.

Possible Solution

Caused by the conditions at the end of StyleCIExporter.convertConfiguration, because both converted.enabled and converted.disabled is undefined if converted object itself is empty, so calling .length on them will definetly fail.

Modal bug

Ciao/Hello @mlocati !

🇬🇧 When I close the modal box, I am forwarded to the page top. I have to scroll down every time that I close the modal box.
🇮🇹 Quando io chiudo il dialogo del modal, mi porta fino alla parte superiore della pagina. Devo scorrere verso il basso la pagina ogni volta che chiudo il dialogo del modal.

Discover "new" fixers more easily

Hi,

This tool is awesome.

When actively updating to the latest available fixers, it would be super helpful to be able to filter by version in a way you'd only see the fixers that are "new" in version X.

Much like a diff between e.g. 2.14 and 2.15

Thoughts?

Impossible to set option custom value in `blank_lines_before_namespace`

Hello. It`s an excellent tool. Tnx.

I`m using Firefox 118.0b6 (developer edition) and found a nasty bug.

Subject

Impossible to set option custom value in blank_lines_before_namespace.

I want set custom value 1 for blank_lines_before_namespace['max_line_breaks '], but get error message Error: The type of the option max_line_breaks of the fixer blank_lines_before_namespace is not an accepted one.

Reproduce

  1. Go to configurator
  2. Search blank_lines_before_namespace and select it
  3. Try config this statement and define custom value any option (ex. max_line_breaks = 1)
  4. Apply changes
  5. Take error message

Investigation

I did a little research and found this situation.

public validateOptionValue(optionName: string, value: any, warnings: string[]): [string, any] | null {
let option: PFCFixerOption | null = this.getOptionByName(optionName);
if (option === null) {
warnings.push(`The fixer ${this.name} does not have an option named ${optionName} for version ${this.version.fullVersion}: it has been removed`);
return null;
}
if (optionName === option.alias) {
warnings.push(`The option ${optionName} of the fixer ${this.name} has been renamed to ${option.name} for version ${this.version.fullVersion}`);
}
if (option.allowedValues !== undefined) {
if (value instanceof Array && option.allowedValues[0] instanceof Array) {
const allowedValues = option.allowedValues[0];
value = value.filter((v) => {
if (allowedValues.indexOf(v) >= 0) {
return true;
}
warnings.push(`The option ${optionName} of the fixer ${this.name} has the invalid value '${v}'`);
return false;
})
} else if (option.allowedValues.indexOf(value) < 0) {
warnings.push(`The option ${optionName} of the fixer ${this.name} has an invalid value`);
return null;
}
} else if (option.allowedTypes !== undefined) {
const valueType = ValueType.get(value);
let typeFound: boolean = false;
option.allowedTypes.some((allowedType: string): boolean => {
switch (allowedType) {
case 'array':
switch (ValueType.get((<PFCFixerOption>option).defaultValue)) {
case ValueType.ARRAY:
typeFound = valueType === ValueType.ARRAY;
break;
case ValueType.OBJECT:
typeFound = valueType === ValueType.OBJECT;
break;
default:
typeFound = valueType === ValueType.ARRAY || valueType === ValueType.OBJECT;
break;
}
break;
case 'bool':
typeFound = valueType === ValueType.BOOLEAN;
break;
case 'null':
typeFound = valueType === ValueType.NULL;
break;
case 'string':
typeFound = valueType === ValueType.STRING;
break;
case 'integer':
typeFound = valueType === ValueType.INTEGER;
break;
case 'double':
typeFound = valueType === ValueType.DECIMAL || valueType === ValueType.INTEGER;
break;
case 'null':
typeFound = valueType === ValueType.NULL;
break;
}
return typeFound;
});
if (typeFound === false) {
warnings.push(`The type of the option ${optionName} of the fixer ${this.name} is not an accepted one`);
return null;
}
}
return [option.name, value];
}

In string #294 you use long definition integer, but in config use short definition

"blank_lines_before_namespace": {
"configuration": [
{
"name": "max_line_breaks",
"description": "Maximum line breaks that should exist before namespace declaration.",
"defaultValue": 2,
"allowedTypes": [
"int"
]
},
{
"name": "min_line_breaks",
"description": "Minimum line breaks that should exist before namespace declaration.",
"defaultValue": 2,
"allowedTypes": [
"int"
]
}
],

изображение

Donation Via Bitcoin

Please add an option to donate to you via Bitcoin.
Thanks for this wonderful project.

Meaning of the 'red rules'

The help say "Fixers included in selected presets but explicitly excluded"

Where is it decided that this rule is not used, why is the rule excluded?

grafik

PS: Very good work, that facilitates the configuration extremely! 👍

Being able to show "not in"

We are using @PSR12 set and I looking into adding some more fixes

So I would like to see @PhpCsFixer but ONLY those fixes that are not already in @PSR12

Is there a way to do this in the interface?

Ability to hide unused deprecated rules

Love this tool, thank you!

An option to hide unused deprecated rules would help by reducing some noise in the list. We typically avoid using deprecated rules, so including them in the list offers no benefit. However, if we're still using a deprecated rule, listing it is helpful as a reminder to migrate.

Add php-cs-fixer for the PHP part of the project

Hello,

Most of the time it is good practice, to dog-food projects like this.

Current Behaviour

No php-cs-fixer rules included.

Possible Solution

Add php-cs-fixer rules to the PHP code and optionally introduce a a CI pipeline for PRs.

Validating the type of custom value of a fixer parameter

Hi!

The configurator is a good product, but there is an error with types when setting the custom value of a parameter.

Associative php array cannot be represented as a json array, only as an object. But the validator strictly requires only an array.

Also, an error occurs if you load the configuration, and open the parameter value. It will be an object, but when you try to save it will show an error.

For example, you can check on the binary_operator_spaces fixer, set the operators parameter value {"=": "align"}

Highlight 'Disabled fixers (manually)' in darker red

If our config array contains 'class_keyword_remove' => false, to ensure it's disabled, then it'd be useful if the rule were listed with a red background. Currently it's listed with a white background.

A darker shade of red than the excluded from presets colour might make sense, it'd be nicely consistent with the two shades of green used.

Commit `composer.lock`

Hello,

First of all thanks for the project, it makes configuration way easier.

Reason of this issue: https://getcomposer.org/doc/01-basic-usage.md#installing-from-composer-lock

Current Behaviour

If you freshly clone the project and run composer install, it has a chance to install slightly different depenceies than the PR author have.

This can cause hard-to-reproduce buggs since all the PHP dependencies only have the major versions pinned. "^2 || ^3"

This problem can occure even in CI since the composer.lock file is on .gitignore.

Possible Solution

Commit the composer.lock file for consistent depenceny behaviour.

Support for Symfony ContainerConfigurator

Hi, thanks for the great tool!
Really helps to get a better overview and understanding of all the fixers.

I've moved to symplify/easy-coding-standard as a tool, which internally uses php-cs-fixer and php_codesniffer.
The configuration is done with Symfony's new ContainerConfigurator.

Sadly, I can't reimport this into the configurator tool and it's not easy to compare/diff the fixers used.
This is an example taken from the ecs documentation:

<?php
// ecs.php

declare(strict_types=1);

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\Configuration\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();
    $services->set(ArraySyntaxFixer::class);

    $parameters = $containerConfigurator->parameters();
    $parameters->set(Option::ONLY, [
        ArraySyntaxFixer::class => [
            __DIR__ . '/src/NewCode'
        ]
    ]);
};

It would be great to have an importer/exporter for this.
I'm expecting it to be used more often, as Symfony is moving to this kind of configuration.

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.