PHPackages                             valksor/php-dev-cs-fixer-custom-fixers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. valksor/php-dev-cs-fixer-custom-fixers

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

valksor/php-dev-cs-fixer-custom-fixers
======================================

Custom PHP-CS-Fixer rules for automated code style enforcement including Doctrine migration files and project-specific standards

01PHPCI passing

Since Dec 28Pushed 3mo agoCompare

[ Source](https://github.com/valksor/php-dev-cs-fixer-custom-fixers)[ Packagist](https://packagist.org/packages/valksor/php-dev-cs-fixer-custom-fixers)[ RSS](/packages/valksor-php-dev-cs-fixer-custom-fixers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Valksor PHP-CS-Fixer Custom Fixers
==================================

[](#valksor-php-cs-fixer-custom-fixers)

[![valksor](https://camo.githubusercontent.com/2af5a6a7e5f7da47cd0a924c8b00038f208f45f9b0d5be8d7a497a9808168187/68747470733a2f2f62616467656e2e6e65742f7374617469632f6f72672f76616c6b736f722f677265656e)](https://github.com/valksor)[![BSD-3-Clause](https://camo.githubusercontent.com/72547f8afb6b5ace804caebbf95c3bcbfc027ce9214777bc452f308f3165db01/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4253442d2d332d2d436c617573652d677265656e3f7374796c653d666c6174)](https://github.com/valksor/php-dev-cs-fixer-custom-fixers/blob/master/LICENSE)[![Coverage Status](https://camo.githubusercontent.com/08ae29ed7ea4b6ba1bbceaec2ee0ed48ba2d42c0c814cbec028a59a3f049ba05/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f76616c6b736f722f7068702d6465762d63732d66697865722d637573746f6d2d6669786572732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/valksor/php-dev-cs-fixer-custom-fixers?branch=master)[![php](https://camo.githubusercontent.com/77da2f7bbc049873edb2d1045a756d7a32e3ba50440a8e0e76a9109f62f0771b/68747470733a2f2f62616467656e2e6e65742f7374617469632f7068702f2533453d382e342f707572706c65)](https://www.php.net/releases/8.4/en.php)

A comprehensive PHP library providing custom fixers for PHP-CS-Fixer to enhance code quality, enforce modern coding standards, and improve development workflow efficiency.

Use Cases
---------

[](#use-cases)

### Code Quality Enhancement

[](#code-quality-enhancement)

- **Modern PHP Standards**: Enforce PHP 8.4+ best practices including promoted constructor properties
- **Readability Improvements**: Automatic formatting for better code readability and maintainability
- **Team Consistency**: Ensure consistent coding style across development teams
- **Migration Cleanup**: Automatically clean up auto-generated comments in Doctrine migration files

### Development Workflow Automation

[](#development-workflow-automation)

- **Automated Refactoring**: Convert traditional constructor patterns to modern promoted properties
- **Code Cleanup**: Remove unnecessary function calls and redundant code patterns
- **Standards Enforcement**: Go beyond PSR-12 with project-specific coding standards
- **CI/CD Integration**: Seamless integration with continuous integration pipelines

### Performance Optimization

[](#performance-optimization)

- **Code Optimization**: Remove inefficient patterns like unnecessary `strlen()` calls in comparisons
- **Clean Code**: Eliminate redundant `dirname()` calls and other unnecessary constructs
- **Modern Patterns**: Promote use of modern PHP features for better performance

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require valksor/php-dev-cs-fixer-custom-fixers --dev
```

Requirements
------------

[](#requirements)

- **PHP 8.4 or higher**
- **friendsofphp/php-cs-fixer** (3.81.0 or higher)
- **symfony/finder** (7.0 or higher)
- **valksor/php-functions-preg** (^1.0)

### Optional Dependencies

[](#optional-dependencies)

- **doctrine/migrations**: For fixing migration file comments (suggested)

Usage
-----

[](#usage)

The package provides custom fixers that can be used with PHP-CS-Fixer to automatically fix code style issues.

### Basic Usage

[](#basic-usage)

```
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use ValksorDev\PhpCsFixerCustomFixers\Fixers;

$finder = Finder::create()
    ->in(__DIR__)
    ->exclude('vendor')
    ->name('*.php');

$config = new Config();
$config
    ->setRules([
        '@PSR12' => true,
        // Enable all Valksor custom fixers
        'ValksorPhpCsFixerCustomFixers/declare_after_opening_tag' => true,
        'ValksorPhpCsFixerCustomFixers/doctrine_migrations' => true,
        'ValksorPhpCsFixerCustomFixers/line_break_between_method_arguments' => true,
        'ValksorPhpCsFixerCustomFixers/line_break_between_statements' => true,
        'ValksorPhpCsFixerCustomFixers/no_useless_dirname_call' => true,
        'ValksorPhpCsFixerCustomFixers/no_useless_strlen' => true,
        'ValksorPhpCsFixerCustomFixers/promoted_constructor_property' => true,
    ])
    ->setFinder($finder);

// Register custom fixers
$fixers = new Fixers();
foreach ($fixers as $fixer) {
    $config->registerCustomFixers([$fixer]);
}

return $config;
```

### Registering Specific Fixers

[](#registering-specific-fixers)

If you only want to use specific fixers, you can register them individually:

```
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use ValksorDev\PhpCsFixerCustomFixers\Fixer\DoctrineMigrationsFixer;

$finder = Finder::create()
    ->in(__DIR__)
    ->exclude('vendor')
    ->name('*.php');

$config = new Config();
$config
    ->setRules([
        '@PSR12' => true,
        // Enable only specific Valksor custom fixers
        'ValksorPhpCsFixerCustomFixers/doctrine_migrations' => true,
    ])
    ->setFinder($finder)
    ->registerCustomFixers([
        new DoctrineMigrationsFixer(),
    ]);

return $config;
```

Available Fixers
----------------

[](#available-fixers)

### DeclareAfterOpeningTagFixer

[](#declareafteropeningtagfixer)

Ensures that `declare(strict_types = 1)` is placed immediately after the opening PHP tag.

### DoctrineMigrationsFixer

[](#doctrinemigrationsfixer)

Removes unnecessary auto-generated comments from Doctrine migration files.

```
// Before
/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20230101000000 extends AbstractMigration
{
    public function up(Schema $schema)
    {
        // this up() migration is auto-generated, please modify it to your needs
    }
}

// After
final class Version20230101000000 extends AbstractMigration
{
    public function up(Schema $schema)
    {
    }
}
```

### LineBreakBetweenMethodArgumentsFixer

[](#linebreakbetweenmethodargumentsfixer)

Ensures that method arguments are separated by line breaks when there are multiple arguments.

### LineBreakBetweenStatementsFixer

[](#linebreakbetweenstatementsfixer)

Ensures that statements are separated by line breaks for better readability.

### NoUselessDirnameCallFixer

[](#nouselessdirnamecallfixer)

Removes unnecessary `dirname()` calls.

### NoUselessStrlenFixer

[](#nouselessstrlenfixer)

Removes unnecessary `strlen()` calls when used in comparisons.

### PromotedConstructorPropertyFixer

[](#promotedconstructorpropertyfixer)

Converts traditional constructor property assignments to promoted properties (PHP 8.0+).

Contributing
------------

[](#contributing)

- Code style requirements (PSR-12)
- Testing requirements for PRs
- One feature per pull request
- Development setup instructions

To contribute to the custom fixers:

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/new-fixer`)
3. Implement your custom fixer following the existing patterns
4. Add comprehensive tests for your fixer
5. Ensure all tests pass and code style is correct
6. Submit a pull request

### Creating a New Custom Fixer

[](#creating-a-new-custom-fixer)

When adding a new custom fixer:

1. Extend the appropriate base class:

    ```
    use ValksorDev\PhpCsFixerCustomFixers\PhpCsFixer\AbstractFixer;

    class YourCustomFixer extends AbstractFixer
    {
        // Implement required methods
    }
    ```
2. Add comprehensive test coverage in `tests/Fixer/YourCustomFixerTest.php`
3. Register the fixer in `src/ValksorDev/PhpCsFixerCustomFixers/Fixers.php`
4. Update documentation with examples

Security
--------

[](#security)

If you discover any security-related issues, please email us at  instead of using the issue tracker.

Support
-------

[](#support)

- **Documentation**: [Full documentation](https://github.com/valksor/php-dev)
- **Issues**: [GitHub Issues](https://github.com/valksor/php-dev/issues) for bug reports and feature requests
- **Discussions**: [GitHub Discussions](https://github.com/orgs/valksor/discussions/categories/php-dev) for questions and community support

Credits
-------

[](#credits)

- **[Original Author](https://github.com/valksor)** - Creator and maintainer
- **[All Contributors](https://github.com/valksor/valksor-dev/graphs/contributors)** - Thank you to all who contributed
- **[PHP-CS-Fixer Project](https://github.com/FriendsOfPHP/PHP-CS-Fixer)** - Core framework and inspiration
- **[Valksor Project](https://github.com/valksor)** - Part of the larger Valksor PHP ecosystem

License
-------

[](#license)

This package is licensed under the [BSD-3-Clause License](LICENSE).

About Valksor
-------------

[](#about-valksor)

This package is part of the [valksor/php-dev](https://github.com/valksor/valksor-dev) project - a comprehensive PHP library and Symfony bundle that provides a collection of utilities, components, and integrations for Symfony applications.

The main project includes:

- Various utility functions and components
- Doctrine ORM tools and extensions
- Symfony bundle for easy configuration
- And much more

If you find these custom fixers useful, you might want to check out the full Valksor project for additional tools and utilities that can enhance your Symfony application development.

To install the complete package:

```
composer require valksor/php-dev
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance53

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4db85e32518c5a6caa2fd625032a2b016ef42d60cf8a101c165cc5c0048b221?d=identicon)[k0d3r1s](/maintainers/k0d3r1s)

---

Top Contributors

[![k0d3r1s](https://avatars.githubusercontent.com/u/38725938?v=4)](https://github.com/k0d3r1s "k0d3r1s (33 commits)")

### Embed Badge

![Health badge](/badges/valksor-php-dev-cs-fixer-custom-fixers/health.svg)

```
[![Health](https://phpackages.com/badges/valksor-php-dev-cs-fixer-custom-fixers/health.svg)](https://phpackages.com/packages/valksor-php-dev-cs-fixer-custom-fixers)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
