Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Easy Coding Standard Laravel Package

symplify/easy-coding-standard

Easy Coding Standard (ECS) makes PHP coding standards effortless on PHP 7.2–8.5. Fast parallel runs, supports PHP_CodeSniffer and PHP-CS-Fixer, uses prepared rule sets, generates ecs.php config on first run, and can check and auto-fix code with --fix.

View on GitHub
Deep Wiki
Context7

How to Test Fixers and Sniffs

Do you write your own fixer and sniffs? Would you like to test them without having to learn a lot about their internals?

This package make fixer and sniff testing with 1 single approach super easy.

Usage

  1. Extend Symplify\EasyCodingStandard\Testing\PHPUnit\AbstractCheckerTestCase class

  2. Provide files to doTestFiles() method

namespace Your\CodingStandard\Tests\Fixer\YourFixer;

use Iterator;
use Symplify\EasyCodingStandard\Testing\PHPUnit\AbstractCheckerTestCase;
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
use Symplify\SmartFileSystem\SmartFileInfo;
use Your\CondingStandard\Fixer\YourFixer;

final class YourFixerTest extends AbstractCheckerTestCase
{
    /**
     * [@dataProvider](https://github.com/dataProvider) provideData()
     */
    public function test(string $filePath): void
    {
        $this->doTestFile($filePath);
    }

    public function provideData(): Iterator
    {
        return self::yieldFiles(__DIR__ . '/Fixture');
    }

    /**
     * [@dataProvider](https://github.com/dataProvider) provideDataWithFileErrors()
     */
    public function testFileErrors(string $filePath, int $expectedErrorCount): void
    {
        $this->doTestFileInfoWithErrorCountOf($filePath, $expectedErrorCount);
    }

    public function provideDataWithFileErrors(): Iterator
    {
        yield [__DIR__ . '/Fixture/wrong.php.inc', 1];
        yield [__DIR__ . '/Fixture/correct.php.inc', 0];
    }

    protected function getCheckerClass(): string
    {
        return YourFixer::class;
    }
}

The /Fixture directory with diffs, should be a *.php.inc file with this content:

<?php

$array = array();

?>
-----
<?php

$array = [];

?>

In pseudo-code:

before
------
after
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport