Releases: blumilksoftware/codestyle
Releases · blumilksoftware/codestyle
v0.4.0 - removing useless docblocks
After this change, all useless comments will be removed:
Before:
<?php
declare(strict_types=1);
/**
* Class Whatever
*/
class Whatever
{
public int|string $something;
/**
* @throws JsonException
*/
public function do(): void
{
$i = 1 + 1;
json_encode([$i], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
}
}
After:
<?php
declare(strict_types=1);
class Whatever
{
public int|string $something;
/**
* @throws JsonException
*/
public function do(): void
{
$i = 1 + 1;
json_encode([$i], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
}
}
pipe symbol spacing
Symbol |
can be now used both in union types and bitwise operator:
<?php
declare(strict_types=1);
class Whatever
{
public int|string $something;
/**
* @throws JsonException
*/
public function do(): void
{
$i = 1 + 1;
json_encode([$i], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
}
}
arrow function spacing
There were new fixers added to Blumilk/Configuration/Defaults/CommonAdditionalRules
within #11 task:
use Blumilk\Codestyle\Fixers\NoSpacesAfterFunctionNameFixer;
use PhpCsFixer\Fixer\FunctionNotation\UseArrowFunctionsFixer;
use PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer;
use PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
Arrow functions spacing were broken and it wass working like this:
array_filter([1, 2, 3, 4], fn (int $i): bool => $i % 2 === 0);
Now it's properly formatted into this:
array_filter([1, 2, 3, 4], fn(int $i): bool => $i % 2 === 0);
extended config customization
#5 implemented. Now you can easier configure paths, set lists, skipped and additional rules in Config constructor:
<?php
declare(strict_types=1);
use Blumilk\Codestyle\Config;
use Blumilk\Codestyle\Configuration\Defaults\CommonAdditionalRules;
use Blumilk\Codestyle\Configuration\Defaults\CommonSetLists;
use Blumilk\Codestyle\Configuration\Defaults\LaravelPaths;
use Blumilk\Codestyle\Configuration\Utils\Rule;
use PhpCsFixer\Fixer\Alias\NoMixedEchoPrintFixer;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
$paths = new LaravelPaths();
$rules = new CommonAdditionalRules();
$sets = new CommonSetLists();
$config = new Config(
paths: $paths->filter("resources/lang"),
sets: $sets->filter(SetList::CLEAN_CODE)->add(SetList::COMMENTS),
rules: $rules->add(new Rule(NoMixedEchoPrintFixer::class, [
"use" => "echo",
]))
);
customizable paths
#7 implemented. Now you can configure paths, set lists, skipped and additional rules in Config constructor:
<?php
declare(strict_types=1);
use Blumilk\Codestyle\Config;
use Blumilk\Codestyle\Configuration\Defaults\LaravelPaths;
$paths = new LaravelPaths();
$config = new Config(
paths: $paths->filter("app", "tests")->add("src")
);
return $config->config();
Or:
<?php
declare(strict_types=1);
use Blumilk\Codestyle\Config;
use Blumilk\Codestyle\Configuration\Defaults\Paths;
$config = new Config(
paths: new Paths("src")
);
return $config->config();
proof of concept
0.0.1 #4 - ECS added (#6)