Compare commits

...

6 Commits

Author SHA1 Message Date
ErickSkrauch
390cfbd1f2
Fix composer.lock 2024-01-24 03:51:14 +01:00
ErickSkrauch
b80c930d01
Update year in the LICENSE 2024-01-23 06:07:47 +01:00
ErickSkrauch
30b1946616
Upgrade ruleset up to PHP-CS-Fixer v3.48 2024-01-23 06:07:12 +01:00
ErickSkrauch
259b5cc89c
Fix an error in the code style sample 😅 2024-01-23 05:20:06 +01:00
ErickSkrauch
ca58c15e3f
Prepare 1.0.1 release 2023-07-21 06:12:46 +02:00
ErickSkrauch
e6bac9d44b
Adjust comment_to_phpdoc fixer to exclude PHPStan error supression tags 2023-07-21 05:37:25 +02:00
7 changed files with 200 additions and 412 deletions

View File

@ -48,4 +48,4 @@ jobs:
- name: PHP-CS-Fixer
if: matrix.php-versions == '8.1'
run: vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle | cs2pr
run: vendor/bin/php-cs-fixer check --format=checkstyle | cs2pr

View File

@ -5,6 +5,23 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- `align_multiline_comment` fixer.
- `nullable_type_declaration` fixer.
- `php_unit_data_provider_return_type` fixer.
- `attribute_empty_parentheses` fixer.
- `numeric_literal_separator` fixer.
### Fixed
- Replace `compact_nullable_typehint` with `compact_nullable_type_declaration` (deprecated).
- Replace `curly_braces_position` with `braces_position` (deprecated).
- Replace `function_typehint_space` with `type_declaration_spaces` (deprecated).
- Replace `native_function_type_declaration_casing` with `native_type_declaration_casing` (deprecated).
- Replace `new_with_braces` with `new_with_parentheses` (deprecated).
## [1.0.1] - 2023-07-21
### Changed
- `comment_to_phpdoc` no longer fixes PHPStan error suppression and the `todo` tag.
## [1.0.0] - 2023-05-17
### Added
@ -161,7 +178,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- First release
[Unreleased]: https://github.com/elyby/php-code-style/compare/1.0.0...HEAD
[Unreleased]: https://github.com/elyby/php-code-style/compare/1.0.1...HEAD
[1.0.1]: https://github.com/elyby/php-code-style/compare/1.0.0...1.0.1
[1.0.0]: https://github.com/elyby/php-code-style/compare/0.5.0...1.0.0
[0.5.0]: https://github.com/elyby/php-code-style/compare/0.4.0...0.5.0
[0.4.0]: https://github.com/elyby/php-code-style/compare/0.3.0...0.4.0

View File

@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2023 Ely.by (https://ely.by)
Copyright 2024 Ely.by (https://ely.by)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -77,9 +77,9 @@ class Foo extends Bar implements FooInterface {
private const SAMPLE_1 = 123;
private const SAMPLE_2 = 321;
public Typed $field1;
public $field1;
public $field2;
public Typed $field2;
public function sampleFunction(
int $a,

View File

@ -21,9 +21,8 @@
"require": {
"php": "^7.4 || ^8.0",
"erickskrauch/php-cs-fixer-custom-fixers": "^1.0.1",
"friendsofphp/php-cs-fixer": "^3.16",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.13",
"symfony/polyfill-php80": "^1.15"
"friendsofphp/php-cs-fixer": "^3.47",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.13"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.28"

547
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@ namespace Ely\CS;
final class Rules {
// Last fixers review has been done on PHP-CS-Fixer v3.48
public static function create(array $overwrittenRules = []): array {
return array_merge([
'@PSR2' => true,
@ -33,8 +34,11 @@ final class Rules {
'trim_array_spaces' => true,
'whitespace_after_comma_in_array' => true,
// Attribute notation
'attribute_empty_parentheses' => true,
// Basic
'curly_braces_position' => [
'braces_position' => [
'functions_opening_brace' => 'same_line',
'classes_opening_brace' => 'same_line',
],
@ -42,6 +46,7 @@ final class Rules {
'non_printable_character' => [
'use_escape_sequences_in_strings' => true,
],
'numeric_literal_separator' => true,
'octal_notation' => PHP_MAJOR_VERSION >= 8 && PHP_MINOR_VERSION >= 1,
'psr_autoloading' => true,
@ -52,7 +57,7 @@ final class Rules {
'magic_constant_casing' => true,
'magic_method_casing' => true,
'native_function_casing' => true,
'native_function_type_declaration_casing' => true,
'native_type_declaration_casing' => true,
// Cast Notation
'cast_spaces' => [
@ -83,7 +88,15 @@ final class Rules {
'visibility_required' => true,
// Comment
'comment_to_phpdoc' => true,
'comment_to_phpdoc' => [
'ignored_tags' => [
'todo',
// https://phpstan.org/user-guide/ignoring-errors
'phpstan-ignore',
'phpstan-ignore-line',
'phpstan-ignore-next-line',
],
],
'multiline_comment_opening_closing' => true,
'no_empty_comment' => true,
'single_line_comment_spacing' => true,
@ -115,7 +128,6 @@ final class Rules {
'closure_function_spacing' => 'none',
'closure_fn_spacing' => 'none',
],
'function_typehint_space' => true,
'implode_call' => true,
'lambda_not_used_import' => true,
'return_type_declaration' => true,
@ -136,6 +148,7 @@ final class Rules {
'dir_constant' => true,
'function_to_constant' => true,
'is_null' => true,
'nullable_type_declaration' => true,
'single_space_around_construct' => true,
// List Notation
@ -155,7 +168,7 @@ final class Rules {
'spacing' => 'one',
],
'logical_operators' => true,
'new_with_braces' => [
'new_with_parentheses' => [
'anonymous_class' => false,
],
'no_useless_concat_operator' => true,
@ -173,6 +186,7 @@ final class Rules {
// PHPUnit
'php_unit_construct' => true,
'php_unit_data_provider_return_type' => true,
'php_unit_dedicate_assert_internal_type' => true,
'php_unit_expectation' => true,
'php_unit_fqcn_annotation' => true,
@ -187,6 +201,9 @@ final class Rules {
'call_type' => 'this',
],
// PHPDoc
'align_multiline_comment' => true,
// Return Notation
'no_useless_return' => true,
'return_assignment' => true,
@ -209,7 +226,7 @@ final class Rules {
// Whitespace
'array_indentation' => true,
'compact_nullable_typehint' => true,
'compact_nullable_type_declaration' => true,
'method_chaining_indentation' => true,
'no_extra_blank_lines' => [
'tokens' => [
@ -230,6 +247,7 @@ final class Rules {
],
'no_spaces_around_offset' => true,
'no_whitespace_in_blank_line' => true,
'type_declaration_spaces' => true,
'types_spaces' => [
'space_multiple_catch' => 'none',
],
@ -241,7 +259,7 @@ final class Rules {
// Our custom or extended fixers
'ErickSkrauch/align_multiline_parameters' => [
'variables' => false,
'variables' => null,
'defaults' => false,
],
'ErickSkrauch/blank_line_around_class_body' => [