Skip to content

Commit 137a898

Browse files
committed
Merge branch 'php-cs-fixer-3'
2 parents ad25ce8 + d4092c6 commit 137a898

24 files changed

+3140
-1718
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
Build:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php-versions:
15+
- '7.4'
16+
- '8.0'
17+
- '8.1'
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php-versions }}
27+
extensions: ctype, mbstring
28+
tools: cs2pr
29+
30+
- name: Get Composer's cache directory
31+
id: composer-cache-path
32+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
33+
34+
- name: Cache Composer dependencies
35+
uses: actions/cache@v3
36+
id: composer-cache
37+
with:
38+
path: ${{ steps.composer-cache-path.outputs.dir }}
39+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
40+
restore-keys: ${{ runner.os }}-composer-
41+
42+
- name: Install dependencies
43+
run: composer install
44+
45+
- name: Normalize composer.json
46+
if: matrix.php-versions == '8.1'
47+
run: composer normalize --dry-run
48+
49+
- name: PHP-CS-Fixer
50+
if: matrix.php-versions == '8.1'
51+
run: vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle | cs2pr
52+
53+
# https://github.com/marketplace/actions/setup-php-action#phpunit
54+
- name: Setup problem matchers for PHPUnit
55+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
56+
57+
- name: PHPUnit
58+
run: vendor/bin/phpunit

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
vendor
22
dist
3-
.php_cs
4-
.php_cs.cache
3+
.phpunit.result.cache
4+
.php-cs-fixer
5+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
$finder = PhpCsFixer\Finder::create()
5+
->in(__DIR__);
6+
7+
return Ely\CS\Config::create([
8+
// Disable "parameters" and "match" to keep compatibility with PHP 7.4
9+
'trailing_comma_in_multiline' => [
10+
'elements' => ['arrays', 'arguments'],
11+
],
12+
])->setFinder($finder);

.php_cs.dist

Lines changed: 0 additions & 9 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,47 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
- `php_unit_mock_short_will_return` fixer.
1313
- `php_unit_dedicate_assert_internal_type` fixer.
1414
- `php_unit_no_expectation_annotation` fixer.
15+
- `modernize_strpos` fixer.
16+
- `no_multiple_statements_per_line` fixer.
17+
- `octal_notation` fixer.
18+
- `class_reference_name_casing` fixer.
19+
- `integer_literal_case` fixer.
20+
- `no_unset_cast` fixer.
21+
- `no_null_property_initialization` fixer.
22+
- `comment_to_phpdoc` fixer.
23+
- `multiline_comment_opening_closing` fixer.
24+
- `no_empty_comment` fixer.
25+
- `single_line_comment_spacing` fixer.
26+
- `single_line_comment_style` fixer.
27+
- `empty_loop_body` fixer.
28+
- `empty_loop_condition` fixer.
29+
- `switch_continue_to_break` fixer.
30+
- `yoda_style` fixer in non-yoda mode.
31+
- `function_typehint_space` fixer.
32+
- `lambda_not_used_import` fixer.
33+
- `no_unneeded_import_alias` fixer.
34+
- `combine_consecutive_unsets` fixer.
35+
- `declare_parentheses` fixer.
36+
- `clean_namespace` fixer.
37+
- `assign_null_coalescing_to_coalesce_equal` fixer.
38+
- `no_useless_nullsafe_operator` fixer.
39+
- `operator_linebreak` fixer.
40+
- `php_unit_fqcn_annotation` fixer.
41+
- `php_unit_test_case_static_method_calls` fixer.
42+
- `simplified_null_return` fixer.
43+
- `no_empty_statement` fixer.
44+
- `no_singleline_whitespace_before_semicolons` fixer.
45+
- `semicolon_after_instruction` fixer.
46+
- `types_spaces` fixer.
47+
- `no_trailing_comma_in_singleline` fixer.
1548

1649
### Changed
17-
- `friendsofphp/php-cs-fixer` version bumped to `^2.15.0`.
50+
- `friendsofphp/php-cs-fixer` version bumped to `^3`.
51+
- `braces` fixer now enables rule `allow_single_line_anonymous_class_with_empty_body`.
52+
- `class_attributes_separation` fixer now fixes `const` in the `only_if_meta` mode.
1853

1954
### Removed
55+
- `Ely/new_with_braces` since all its functionality is now included in the original fixer.
2056
- `self_accessor` fixer because it leads to errors in interfaces, that returns self.
2157

2258
## [0.3.0] - 2019-02-23

README.md

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -246,27 +246,6 @@ and `do-while`.
246246
$c = 'next statement';
247247
```
248248

249-
### `Ely/new_with_braces`
250-
251-
This is the extended version of the original `new_with_braces` fixer. It allows you to remove braces around
252-
an anonymous class declaration in a case when said class constructor doesn't contain any arguments.
253-
254-
```diff
255-
--- Original
256-
+++ New
257-
@@ @@
258-
<?php
259-
-$a = new Foo;
260-
+$a = new Foo();
261-
-$b = new class() extends Foo {};
262-
+$b = new class extends Foo {};
263-
```
264-
265-
**Configuration:**
266-
267-
* `remove_for_anonymous_classes` - if its set to `true`, then braces for anonymous classes without constructor
268-
arguments will be removed. **Default**: `false`.
269-
270249
### `Ely/remove_class_name_method_usages` (Yii2)
271250

272251
Replaces Yii2 [`BaseObject::className()`](https://github.com/yiisoft/yii2/blob/e53fc0ded1/framework/base/BaseObject.php#L84)
@@ -286,9 +265,9 @@ usages with native `::class` keyword, introduced in PHP 5.5.
286265
[ico-version]: https://img.shields.io/packagist/v/ely/php-code-style.svg?style=flat-square
287266
[ico-license]: https://img.shields.io/badge/license-Apache-green.svg?style=flat-square
288267
[ico-downloads]: https://img.shields.io/packagist/dt/ely/php-code-style.svg?style=flat-square
289-
[ico-build-status]: https://img.shields.io/travis/elyby/php-code-style/master.svg?style=flat-square
268+
[ico-build-status]: https://img.shields.io/github/workflow/status/elyby/php-code-style/CI.svg?style=flat-square
290269

291270
[link-packagist]: https://packagist.org/packages/ely/php-code-style
292271
[link-contributors]: ../../contributors
293272
[link-downloads]: https://packagist.org/packages/ely/php-code-style/stats
294-
[link-build-status]: https://travis-ci.org/elyby/php-code-style
273+
[link-build-status]: https://github.com/elyby/php-code-style/actions

composer.json

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"name": "ely/php-code-style",
33
"description": "Set of PHP-CS-Fixer rules used in the development of Ely.by PHP projects",
4-
"keywords": ["php-cs-fixer", "code style"],
5-
"homepage": "https://github.com/elyby/php-code-style",
4+
"license": "Apache-2.0",
5+
"type": "library",
6+
"keywords": [
7+
"php-cs-fixer",
8+
"code style"
9+
],
610
"authors": [
711
{
812
"name": "Ely.by team",
@@ -13,14 +17,20 @@
1317
"email": "erickskrauch@ely.by"
1418
}
1519
],
16-
"license": "Apache-2.0",
17-
"type": "library",
20+
"homepage": "https://github.com/elyby/php-code-style",
1821
"require": {
19-
"php": "^7.0|^8.0",
20-
"friendsofphp/php-cs-fixer": "^2.15.0"
22+
"php": "^7.4 || ^8.0",
23+
"friendsofphp/php-cs-fixer": "^3"
2124
},
2225
"require-dev": {
23-
"phpunit/phpunit": "^6.5.1"
26+
"ergebnis/composer-normalize": "^2.28",
27+
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2",
28+
"phpspec/prophecy": "^1.15",
29+
"phpspec/prophecy-phpunit": "^2.0",
30+
"phpunit/phpunit": "^9.5",
31+
"phpunitgoodpractices/polyfill": "^1.5",
32+
"phpunitgoodpractices/traits": "^1.9.1",
33+
"symfony/phpunit-bridge": "^6.0"
2434
},
2535
"autoload": {
2636
"psr-4": {
@@ -29,12 +39,16 @@
2939
},
3040
"autoload-dev": {
3141
"psr-4": {
32-
"Ely\\CS\\Test\\": "tests/"
42+
"Ely\\CS\\Test\\": "tests/",
43+
"PhpCsFixer\\Tests\\": "vendor/friendsofphp/php-cs-fixer/tests/"
3344
}
3445
},
3546
"config": {
36-
"platform": {
37-
"php": "7.0.8"
47+
"allow-plugins": {
48+
"ergebnis/composer-normalize": true
49+
},
50+
"preferred-install": {
51+
"friendsofphp/php-cs-fixer": "source"
3852
}
3953
}
4054
}

0 commit comments

Comments
 (0)