From 604afdf225f3fbc60a3ea04382e3a00bd8626445 Mon Sep 17 00:00:00 2001
From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com>
Date: Mon, 16 Sep 2024 22:13:54 +0700
Subject: [PATCH] build: update coding style (#9)
---
.gitignore | 4 +-
.phive/phars.xml | 4 ++
.php-cs-fixer.dist.php | 39 +++++++++++++++++++
CHANGELOG.md | 1 +
Makefile | 10 ++++-
config/services_test.php | 23 +++++++----
.../RekalogikaPsr16SimpleCacheExtension.php | 6 ++-
.../RekalogikaPsr16SimpleCachePass.php | 4 +-
src/RekalogikaPsr16SimpleCacheBundle.php | 2 +
tests/Kernel.php | 7 ++--
tests/Psr16Test.php | 2 +
11 files changed, 85 insertions(+), 17 deletions(-)
create mode 100644 .phive/phars.xml
create mode 100644 .php-cs-fixer.dist.php
diff --git a/.gitignore b/.gitignore
index 7f07e6f..5a6d7d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
composer.lock
vendor
.phpunit.cache
-var
\ No newline at end of file
+var
+.php-cs-fixer.cache
+tools
\ No newline at end of file
diff --git a/.phive/phars.xml b/.phive/phars.xml
new file mode 100644
index 0000000..2b1f5c8
--- /dev/null
+++ b/.phive/phars.xml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 0000000..40479f2
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,39 @@
+in(__DIR__ . '/src')
+ ->in(__DIR__ . '/config')
+ ->in(__DIR__ . '/tests');
+
+$config = new PhpCsFixer\Config();
+
+return $config->setRules([
+ '@PER-CS2.0' => true,
+ '@PER-CS2.0:risky' => true,
+ 'fully_qualified_strict_types' => true,
+ 'global_namespace_import' => [
+ 'import_classes' => false,
+ 'import_constants' => false,
+ 'import_functions' => false,
+ ],
+ 'no_unneeded_import_alias' => true,
+ 'no_unused_imports' => true,
+ 'ordered_imports' => [
+ 'sort_algorithm' => 'alpha',
+ 'imports_order' => ['class', 'function', 'const']
+ ],
+ 'declare_strict_types' => true,
+ 'native_function_invocation' => ['include' => ['@compiler_optimized']],
+ 'header_comment' => [
+ 'header' => <<
+
+For the full copyright and license information, please view the LICENSE file
+that was distributed with this source code.
+EOF,
+ ]
+])
+ ->setFinder($finder)
+;
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a2a375..0b5e05d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
* build: update phpunit
* build: add dependabot config
* feat: support PHP 8.4
+* build: update coding style
## 1.1.0
diff --git a/Makefile b/Makefile
index b15a5e0..e3d4eca 100644
--- a/Makefile
+++ b/Makefile
@@ -11,4 +11,12 @@ psalm:
.PHONY: phpunit
phpunit:
- vendor/bin/phpunit
\ No newline at end of file
+ vendor/bin/phpunit
+
+.PHONY: php-cs-fixer
+php-cs-fixer: tools/php-cs-fixer
+ $< fix --config=.php-cs-fixer.dist.php --verbose --allow-risky=yes
+
+.PHONY: tools/php-cs-fixer
+tools/php-cs-fixer:
+ phive install php-cs-fixer
\ No newline at end of file
diff --git a/config/services_test.php b/config/services_test.php
index e832540..875c95c 100644
--- a/config/services_test.php
+++ b/config/services_test.php
@@ -1,5 +1,8 @@
set(
- 'cache.app',
- ArrayAdapter::class
- )
+ $services
+ ->set(
+ 'cache.app',
+ ArrayAdapter::class,
+ )
->tag('cache.pool');
- $services->alias('test.cache.app.simple', 'cache.app.simple')->public();
- $services->alias('test.' . CacheInterface::class, CacheInterface::class)->public();
+ $services
+ ->alias('test.cache.app.simple', 'cache.app.simple')
+ ->public();
+
+ $services
+ ->alias('test.' . CacheInterface::class, CacheInterface::class)
+ ->public();
};
diff --git a/src/DependencyInjection/RekalogikaPsr16SimpleCacheExtension.php b/src/DependencyInjection/RekalogikaPsr16SimpleCacheExtension.php
index 36e4334..05d6194 100644
--- a/src/DependencyInjection/RekalogikaPsr16SimpleCacheExtension.php
+++ b/src/DependencyInjection/RekalogikaPsr16SimpleCacheExtension.php
@@ -1,5 +1,7 @@
load('services_test.php');
}
diff --git a/src/DependencyInjection/RekalogikaPsr16SimpleCachePass.php b/src/DependencyInjection/RekalogikaPsr16SimpleCachePass.php
index 2555657..77bf7d8 100644
--- a/src/DependencyInjection/RekalogikaPsr16SimpleCachePass.php
+++ b/src/DependencyInjection/RekalogikaPsr16SimpleCachePass.php
@@ -1,5 +1,7 @@
addTag('cache.pool.simple');
- $simpleId = $id.'.simple';
+ $simpleId = $id . '.simple';
$container->setDefinition($simpleId, $definition);
if ($simpleId == 'cache.app.simple') {
diff --git a/src/RekalogikaPsr16SimpleCacheBundle.php b/src/RekalogikaPsr16SimpleCacheBundle.php
index 4c1c427..cc13550 100644
--- a/src/RekalogikaPsr16SimpleCacheBundle.php
+++ b/src/RekalogikaPsr16SimpleCacheBundle.php
@@ -1,5 +1,7 @@