Skip to content

Commit

Permalink
Update ecs config (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 21, 2024
1 parent e2557f0 commit ca22404
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 34 deletions.
43 changes: 18 additions & 25 deletions ecs.php
Expand Up @@ -7,41 +7,34 @@
use PhpCsFixer\Fixer\ClassNotation\OrderedTraitsFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return function (ECSConfig $ecsConfig): void {
$ecsConfig->paths(
return ECSConfig::configure()
->withPaths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
]
);

// this way you add a single rule
$ecsConfig->rules(
],
)
->withRules(
[
NoUnusedImportsFixer::class,
OrderedClassElementsFixer::class,
OrderedTraitsFixer::class,
NoUnusedImportsFixer::class,
]
);

// this way you can add sets - group of rules
$ecsConfig->sets(
[
// run and fix, one by one
SetList::DOCBLOCK,
SetList::NAMESPACES,
SetList::COMMENTS,
SetList::PSR_12,
]
);

// this way configures a rule
$ecsConfig->ruleWithConfiguration(
)
->withPreparedSets(
arrays: true,
cleanCode: true,
comments:true,
docblocks: true,
namespaces: true,
psr12: true,
strict: true
)
->withPhpCsFixerSets(perCS20: true)
->withConfiguredRule(
ClassDefinitionFixer::class,
[
'space_before_parenthesis' => true,
],
);
};
4 changes: 3 additions & 1 deletion src/BootstrapAsset.php
Expand Up @@ -26,6 +26,8 @@ public function __construct()
$cssFiles = $environment === 'prod' ? 'bootstrap.min.css' : 'bootstrap.css';

$this->css = [$cssFiles];
$this->publishOptions = ['filter' => $pathMatcher->only("**/css/{$cssFiles}", "**/css/{$cssFiles}.map")];
$this->publishOptions = [
'filter' => $pathMatcher->only("**/css/{$cssFiles}", "**/css/{$cssFiles}.map"),
];
}
}
4 changes: 3 additions & 1 deletion src/BootstrapPluginAsset.php
Expand Up @@ -27,6 +27,8 @@ public function __construct()
$jsFiles = $environment === 'prod' ? 'bootstrap.bundle.min.js' : 'bootstrap.bundle.js';

$this->js = [$jsFiles];
$this->publishOptions = ['filter' => $pathMatcher->only("**/js/{$jsFiles}", "**/js/{$jsFiles}.map")];
$this->publishOptions = [
'filter' => $pathMatcher->only("**/js/{$jsFiles}", "**/js/{$jsFiles}.map"),
];
}
}
8 changes: 6 additions & 2 deletions tests/BootstrapAssetTest.php
Expand Up @@ -23,7 +23,9 @@ public function testRegister(): void

$this->assertInstanceOf(AssetBundle::class, $this->assetManager->getBundle(BootstrapAsset::class));
$this->assertSame(
['/55145ba9/bootstrap.css' => ['/55145ba9/bootstrap.css']],
[
'/55145ba9/bootstrap.css' => ['/55145ba9/bootstrap.css'],
],
$this->assetManager->getCssFiles()
);
$this->assertFileExists(__DIR__ . '/Support/runtime/55145ba9/bootstrap.css');
Expand All @@ -41,7 +43,9 @@ public function testRegisterWithEnvironmentProd(): void

$this->assertInstanceOf(AssetBundle::class, $this->assetManager->getBundle(BootstrapAsset::class));
$this->assertSame(
['/55145ba9/bootstrap.min.css' => ['/55145ba9/bootstrap.min.css']],
[
'/55145ba9/bootstrap.min.css' => ['/55145ba9/bootstrap.min.css'],
],
$this->assetManager->getCssFiles()
);
$this->assertFileExists(__DIR__ . '/Support/runtime/55145ba9/bootstrap.min.css');
Expand Down
16 changes: 12 additions & 4 deletions tests/BootstrapPluginAssetTest.php
Expand Up @@ -21,7 +21,9 @@ public function testRegister(): void
$this->assetManager->register(BootstrapPluginAsset::class);

$this->assertSame(
['/55145ba9/bootstrap.css' => ['/55145ba9/bootstrap.css']],
[
'/55145ba9/bootstrap.css' => ['/55145ba9/bootstrap.css'],
],
$this->assetManager->getCssFiles()
);
$this->assertFileExists(__DIR__ . '/Support/runtime/55145ba9/bootstrap.css');
Expand All @@ -30,7 +32,9 @@ public function testRegister(): void
$this->assertFileDoesNotExist(__DIR__ . '/Support/runtime/55145ba9/bootstrap.min.css.map');

$this->assertSame(
['/16b8de20/bootstrap.bundle.js' => ['/16b8de20/bootstrap.bundle.js']],
[
'/16b8de20/bootstrap.bundle.js' => ['/16b8de20/bootstrap.bundle.js'],
],
$this->assetManager->getJsFiles()
);
$this->assertFileExists(__DIR__ . '/Support/runtime/16b8de20/bootstrap.bundle.js');
Expand All @@ -49,13 +53,17 @@ public function testRegisterWithEnvironmentProd(): void
$this->assetManager->register(BootstrapPluginAsset::class);

$this->assertSame(
['/55145ba9/bootstrap.min.css' => ['/55145ba9/bootstrap.min.css']],
[
'/55145ba9/bootstrap.min.css' => ['/55145ba9/bootstrap.min.css'],
],
$this->assetManager->getCssFiles()
);
$this->assertFileExists(__DIR__ . '/Support/runtime/55145ba9/bootstrap.min.css');
$this->assertFileExists(__DIR__ . '/Support/runtime/55145ba9/bootstrap.min.css.map');
$this->assertSame(
['/16b8de20/bootstrap.bundle.min.js' => ['/16b8de20/bootstrap.bundle.min.js']],
[
'/16b8de20/bootstrap.bundle.min.js' => ['/16b8de20/bootstrap.bundle.min.js'],
],
$this->assetManager->getJsFiles()
);
$this->assertFileExists(__DIR__ . '/Support/runtime/16b8de20/bootstrap.bundle.min.js');
Expand Down
5 changes: 4 additions & 1 deletion tests/Support/main.php
@@ -1,4 +1,7 @@
<?php
/* @var $this \yii\web\View */

declare(strict_types=1);

/** @var \yii\web\View $this */
?>
<?php $this->beginPage();?>1<?php $this->head();?>2<?php $this->beginBody();?>3<?php $this->endBody();?>4<?php $this->endPage();

0 comments on commit ca22404

Please sign in to comment.