Skip to content

Commit 33fef70

Browse files
#248: Added PHP CS Fixer to build plan
1 parent eb6ffdb commit 33fef70

17 files changed

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

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

src/Bsn.php

Lines changed: 1 addition & 2 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
@@ -26,7 +26,6 @@
2626

2727
/**
2828
* @Annotation
29-
*
3029
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
3130
*
3231
* @author Raymond Schouten

src/BsnValidator.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/Collection.php

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

2929
/**
3030
* @Annotation
31-
*
3231
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
3332
*
3433
* @author Raymond Schouten
@@ -46,19 +45,11 @@ public function __construct(mixed $options = null)
4645

4746
foreach ($this->constraints as $constraint) {
4847
if (!$constraint instanceof Constraint) {
49-
throw new ConstraintDefinitionException(
50-
sprintf('The value %s is not an instance of Constraint in constraint %s', $constraint, self::class)
51-
);
48+
throw new ConstraintDefinitionException(sprintf('The value %s is not an instance of Constraint in constraint %s', $constraint, self::class));
5249
}
5350

5451
if ($constraint instanceof Valid) {
55-
throw new ConstraintDefinitionException(
56-
sprintf(
57-
'The constraint Valid cannot be nested inside constraint %s. ' .
58-
'You can only declare the Valid constraint directly on a field or method.',
59-
self::class
60-
)
61-
);
52+
throw new ConstraintDefinitionException(sprintf('The constraint Valid cannot be nested inside constraint %s. You can only declare the Valid constraint directly on a field or method.', self::class));
6253
}
6354
}
6455
}

src/CollectionValidator.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/Json.php

Lines changed: 1 addition & 2 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
@@ -26,7 +26,6 @@
2626

2727
/**
2828
* @Annotation
29-
*
3029
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
3130
*
3231
* @author Raymond Schouten

0 commit comments

Comments
 (0)