Skip to content

Commit 4080605

Browse files
#248: Added PHP CS Fixer to build plan
1 parent 78d1aae commit 4080605

12 files changed

+56
-13
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-transformers/downloads?format=flat)](https://packagist.org/packages/darkwebdesign/symfony-addon-transformers)
55
[![License](https://poser.pugx.org/darkwebdesign/symfony-addon-transformers/license?format=flat)](https://packagist.org/packages/darkwebdesign/symfony-addon-transformers)
66

7-
[![Build Status](https://app.travis-ci.com/darkwebdesign/symfony-addon-transformers.svg?branch=6.0)](https://app.travis-ci.com/darkwebdesign/symfony-addon-transformers)
7+
[![Build Status](https://github.com/darkwebdesign/symfony-addon-transformers/actions/workflows/build.yaml/badge.svg?branch=6.0)](https://github.com/darkwebdesign/symfony-addon-transformers/actions/workflows/build.yaml)
88
[![Coverage Status](https://codecov.io/gh/darkwebdesign/symfony-addon-transformers/branch/6.0/graph/badge.svg)](https://codecov.io/gh/darkwebdesign/symfony-addon-transformers)
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
@@ -14,6 +14,7 @@
1414
},
1515
"require-dev": {
1616
"doctrine/orm": "^2.7",
17+
"friendsofphp/php-cs-fixer": "^3.58",
1718
"phpstan/extension-installer": "^1.3",
1819
"phpstan/phpstan": "^1.11",
1920
"phpstan/phpstan-doctrine": "^1.4",

src/BooleanToValueTransformer.php

Lines changed: 2 additions & 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
@@ -27,6 +27,7 @@
2727

2828
/**
2929
* @template R of string|int|float|bool
30+
*
3031
* @template-implements DataTransformerInterface<bool, R>
3132
*
3233
* @author Raymond Schouten

src/EntityToIdentifierTransformer.php

Lines changed: 3 additions & 4 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
@@ -38,6 +38,7 @@
3838
/**
3939
* @template T of object
4040
* @template R of mixed
41+
*
4142
* @template-implements DataTransformerInterface<T, R>
4243
*
4344
* @author Raymond Schouten
@@ -120,9 +121,7 @@ public function reverseTransform(mixed $value): ?object
120121
$entity = $this->repository->find($value);
121122

122123
if (null === $entity) {
123-
throw new TransformationFailedException(
124-
sprintf('Entity %s with identifier "%s" not found.', $this->className, $value)
125-
);
124+
throw new TransformationFailedException(sprintf('Entity %s with identifier "%s" not found.', $this->className, $value));
126125
}
127126

128127
return $entity;

tests/BooleanToValueTransformerTest.php

Lines changed: 5 additions & 3 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
@@ -28,6 +28,8 @@
2828

2929
/**
3030
* @covers \DarkWebDesign\SymfonyAddonTransformers\BooleanToValueTransformer
31+
*
32+
* @internal
3133
*/
3234
class BooleanToValueTransformerTest extends TestCase
3335
{
@@ -155,7 +157,7 @@ public function providerNoBool(): array
155157
'float' => [1.2],
156158
'string' => ['foo'],
157159
'array' => [['foo', 'bar']],
158-
'object' => [new \stdClass],
160+
'object' => [new \stdClass()],
159161
'resource' => [tmpfile()],
160162
'callable' => [function () {}],
161163
];
@@ -168,7 +170,7 @@ public function providerNoScalar(): array
168170
{
169171
return [
170172
'array' => [['foo', 'bar']],
171-
'object' => [new \stdClass],
173+
'object' => [new \stdClass()],
172174
'resource' => [tmpfile()],
173175
'callable' => [function () {}],
174176
];

tests/EntityToIdentifierTransformerTest.php

Lines changed: 3 additions & 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
@@ -35,6 +35,8 @@
3535

3636
/**
3737
* @covers \DarkWebDesign\SymfonyAddonTransformers\EntityToIdentifierTransformer
38+
*
39+
* @internal
3840
*/
3941
class EntityToIdentifierTransformerTest extends TestCase
4042
{

tests/Models/AbstractPerson.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) 2018 DarkWeb Design
3+
* Copyright (c) 2018 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)