Skip to content

Commit 0fba710

Browse files
#248: Added PHP CS Fixer to build plan
1 parent 3bd91e3 commit 0fba710

18 files changed

+76
-31
lines changed

.github/workflows/build.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ jobs:
3838
- name: 'PHPStan'
3939
run: 'vendor/bin/phpstan analyze --no-progress --ansi'
4040

41+
php-cs-fixer:
42+
name: 'PHP CS Fixer'
43+
runs-on: 'ubuntu-24.04'
44+
steps:
45+
- name: 'Checkout'
46+
uses: 'actions/checkout@v4'
47+
- name: 'Setup PHP'
48+
uses: 'shivammathur/setup-php@v2'
49+
with:
50+
php-version: '8.0'
51+
- name: 'Composer Install'
52+
uses: 'ramsey/composer-install@v3'
53+
- name: 'PHP CS Fixer'
54+
run: 'vendor/bin/php-cs-fixer fix --diff --dry-run --show-progress=none --ansi'
55+
4156
phpunit:
4257
name: 'PHPUnit'
4358
runs-on: 'ubuntu-24.04'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.idea/
2+
/.php-cs-fixer.cache
23
/.phpunit.cache/
34
/composer.lock
45
/vendor/

.php-cs-fixer.dist.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = (new PhpCsFixer\Finder())
6+
->in(__DIR__);
7+
8+
return (new PhpCsFixer\Config())
9+
->setRules([
10+
'@PhpCsFixer' => true,
11+
'@PSR1' => true,
12+
'@PSR2' => true,
13+
'@PSR12' => true,
14+
'@Symfony' => true,
15+
'concat_space' => ['spacing' => 'one'], // overrules @Symfony
16+
'global_namespace_import' => ['import_classes' => false],
17+
'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], // overrules @PhpCsFixer
18+
'no_superfluous_elseif' => false, // overrules @PhpCsFixer
19+
'phpdoc_align' => ['tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var'], 'align' => 'left'], // overrules @Symfony
20+
'yoda_style' => false, // overrules @Symfony
21+
])
22+
->setFinder($finder);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Total Downloads](https://poser.pugx.org/darkwebdesign/symfony-addon-form-types/downloads?format=flat)](https://packagist.org/packages/darkwebdesign/symfony-addon-form-types)
55
[![License](https://poser.pugx.org/darkwebdesign/symfony-addon-form-types/license?format=flat)](https://packagist.org/packages/darkwebdesign/symfony-addon-form-types)
66

7-
[![Build Status](https://app.travis-ci.com/darkwebdesign/symfony-addon-form-types.svg?branch=6.0)](https://app.travis-ci.com/darkwebdesign/symfony-addon-form-types)
7+
[![Build Status](https://github.com/darkwebdesign/symfony-addon-form-types/actions/workflows/build.yaml/badge.svg?branch=6.0)](https://github.com/darkwebdesign/symfony-addon-form-types/actions/workflows/build.yaml)
88
[![Coverage Status](https://codecov.io/gh/darkwebdesign/symfony-addon-form-types/branch/6.0/graph/badge.svg)](https://codecov.io/gh/darkwebdesign/symfony-addon-form-types)
99
[![PHP Version](https://img.shields.io/badge/php-8.0%2B-777BB3.svg)](https://php.net/)
1010
[![Symfony Version](https://img.shields.io/badge/symfony-6.0-93C74B.svg)](https://symfony.com/)

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"require-dev": {
1818
"darkwebdesign/symfony-addon-transformers": "6.0.*",
1919
"doctrine/orm": "^2.7",
20+
"friendsofphp/php-cs-fixer": "^3.58",
2021
"phpstan/extension-installer": "^1.3",
2122
"phpstan/phpstan": "^1.11",
2223
"phpstan/phpstan-doctrine": "^1.4",

src/BirthdayType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2017 DarkWeb Design
3+
* Copyright (c) 2017 DarkWeb Design.
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

src/BooleanToYesNoSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021 DarkWeb Design
3+
* Copyright (c) 2021 DarkWeb Design.
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

src/BooleanType.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2017 DarkWeb Design
3+
* Copyright (c) 2017 DarkWeb Design.
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal
@@ -47,20 +47,17 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
4747

4848
public function configureOptions(OptionsResolver $resolver): void
4949
{
50-
$labelTrueNormalizer = fn(Options $options, $value) =>
51-
!is_null($value) ? (string) $value : $this->humanize((string) $options['value_true']);
50+
$labelTrueNormalizer = fn (Options $options, $value) => !is_null($value) ? (string) $value : $this->humanize((string) $options['value_true']);
51+
$labelFalseNormalizer = fn (Options $options, $value) => !is_null($value) ? (string) $value : $this->humanize((string) $options['value_false']);
5252

53-
$labelFalseNormalizer = fn(Options $options, $value) =>
54-
!is_null($value) ? (string) $value : $this->humanize((string) $options['value_false']);
55-
56-
$choicesNormalizer = fn(Options $options) => [
53+
$choicesNormalizer = fn (Options $options) => [
5754
$options['label_true'] => $options['value_true'],
5855
$options['label_false'] => $options['value_false'],
5956
];
6057

61-
$expandedNormalizer = fn(Options $options) => 'choice' !== $options['widget'];
58+
$expandedNormalizer = fn (Options $options) => 'choice' !== $options['widget'];
6259

63-
$multipleNormalizer = fn() => false;
60+
$multipleNormalizer = fn () => false;
6461

6562
$resolver->setDefaults([
6663
'label_true' => null,

src/EntityType.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2017 DarkWeb Design
3+
* Copyright (c) 2017 DarkWeb Design.
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal
@@ -78,16 +78,13 @@ public function configureOptions(OptionsResolver $resolver): void
7878
$entityManager = $registry->getManagerForClass($options['class']);
7979

8080
if (null === $entityManager) {
81-
throw new RuntimeException(sprintf(
82-
'Class "%s" seems not to be a managed Doctrine entity. Did you forget to map it?',
83-
$options['class']
84-
));
81+
throw new RuntimeException(sprintf('Class "%s" seems not to be a managed Doctrine entity. Did you forget to map it?', $options['class']));
8582
}
8683

8784
return $entityManager;
8885
};
8986

90-
$compoundNormalizer = fn() => false;
87+
$compoundNormalizer = fn () => false;
9188

9289
$resolver->setDefaults([
9390
'entity_manager' => null,

src/JsonSchemaSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021 DarkWeb Design
3+
* Copyright (c) 2021 DarkWeb Design.
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)