Closed FlorentTorregrosa closed 1 year ago
On PHPCS Fixer 3.35.1, I had even more deprecations.
I made a change on my stack https://gitlab.com/florenttorregrosa-drupal/docker-drupal-project/-/merge_requests/160 which fixes the deprecations.
If you want @drupol, I will make a PR to update it directly here after some testing on projects.
The only thing I can't figure out is the indentation of elseif
and else
which is removed.
@WengerK as you have been active recently on this repository, do you also encountered this problem?
Thanks for any help!
Hi!
Yes, please provide a PR here and we'll check from here.
I'll check on a D10 project on monday and come back to you.
Thanks both of you for the quick replies.
Let's follow the discussion in https://github.com/drupol/phpcsfixer-configs-drupal/pull/10
Also PR created on https://github.com/drupol/phpcsfixer-configs-php/pull/52, because deprecated rules are spread on both repositories :p.
For the record:
friendsofphp/php-cs-fixer v3.35.1
drupol/phpcsfixer-configs-drupal dev-master 5ee55ec
drupol/phpcsfixer-configs-php 2.0.19
Detected deprecations in use:
- Option "tokens: use_trait" used in `no_extra_blank_lines` rule is deprecated, use the rule `class_attributes_separation` with `elements: trait_import` instead.
- Rule "braces" is deprecated. Use "single_space_around_construct", "control_structure_braces", "control_structure_continuation_position", "declare_parentheses", "no_multiple_statements_per_line", "curly_braces_position", "statement_indentation" and "no_extra_blank_lines" instead.
- Rule "compact_nullable_typehint" is deprecated. Use "compact_nullable_type_declaration" instead.
- Rule "curly_braces_position" is deprecated. Use "braces_position" instead.
- Rule "function_typehint_space" is deprecated. Use "type_declaration_spaces" instead.
- Rule "native_function_type_declaration_casing" is deprecated. Use "native_type_declaration_casing" instead.
- Rule "new_with_braces" is deprecated. Use "new_with_parentheses" instead.
- Rule "no_spaces_inside_parenthesis" is deprecated. Use "spaces_inside_parentheses" instead.
- Rule "no_trailing_comma_in_list_call" is deprecated. Use "no_trailing_comma_in_singleline" instead.
- Rule "no_unneeded_curly_braces" is deprecated. Use "no_unneeded_braces" instead.
Thanks, :) I'm so surprised this project is still being used...
Should we think about creating a ruleset for D10 exclusively ? That will fox all those dépréciations ?
Why not... I don't (want to) use Drupal any more, so I don't mind at all.
I upgrade to friendsofphp/php-cs-fixer
v3.35.1
on a Drupal 10.1.3
project and I have the exact same issue with else
/ elseif
. Otherwise, I have nothing that has been changed that is not compliant with DrupalCoder (phpcs with Drupal rulesets).
- elseif ($limit) {
+elseif ($limit) {
Here is my own configuration that seems fairly simpler than the one you use @FlorentTorregrosa. Do you really need all those override on yours ?
I used mine on a wide variety of project (decoupled, monolithic, ...) with a lot of custom development. Most - if not all - of our Drupal projects use this config.
# .php-cs-fixer.php
<?php
use drupol\PhpCsFixerConfigsDrupal\Config\Drupal8;
$finder = PhpCsFixer\Finder::create()
->in(['web/modules/custom'])
->name('*.module')
->name('*.inc')
->name('*.install')
->name('*.test')
->name('*.profile')
->name('*.theme')
->notPath('*.md')
->notPath('*.info.yml')
;
$config = new Drupal8();
$config->setFinder($finder);
$rules = $config->getRules();
$rules['global_namespace_import'] = FALSE;
$rules['no_superfluous_phpdoc_tags'] = FALSE;
$rules['ordered_class_elements']['sort_algorithm'] = 'none';
unset($rules['blank_lines_before_namespace']);
$rules['curly_braces_position']['classes_opening_brace'] = 'same_line';
$rules['curly_braces_position']['functions_opening_brace'] = 'same_line';
$config->setRules($rules);
return $config;
I'll check how to prevent the elseif
else
strange behaviour. Open for suggestions if anybody found it.
About the deprecation. Indeed we should update the phpcsfixer.rules.yml
but this should be marked as a BC and we will need to enforce a minimal specific version support of php-cs-fixer then in this new release. Should be processed later. Will check the elseif
else
behavior in priority
Well I found the bug seems to be on Drupal/control_structure_braces_else
.
This should move the else on the next line, but seems to break the indentation.
When unsetting, the issue is "fixed" (still the bracket is not moved to the next line so it's not realy fixed).
unset($rules['Drupal/control_structure_braces_else']);
Fixing this should also add a tests coverage on https://github.com/drupol/phpcsfixer-configs-drupal/blob/master/tests/functional/fixtures/scenario0/[good|bad.php]
Could you please have 2 distrincts issues @FlorentTorregrosa for both problemes here:
Once done, I will update my PR with proper issue reference
@WengerK Thanks for the investigations.
Thanks for sharing your PHPCS Fixer configuration. It will help me to see why non .php files are not detected with my configuration.
Here is my own configuration that seems fairly simpler than the one you use
Yes, not all the PHPCS Fixer I have in my config file is intended to be put back in this repository :)
Or you also mean that to be Drupal compliant some stuff can be removed?
Could you please have 2 distrincts issues
I see that you have created #11, so is a new issue needed?
I see that you have created https://github.com/drupol/phpcsfixer-configs-drupal/pull/11, so is a new issue needed?
Needed for further discussion before merging this changes.
Let's keep this thread about the deprecation changes to be merged with #10 and new discussion about the else/if in a new dedicated issue.
Ok, #12 created.
I am on it to check minimum requirements.
Also found that in https://github.com/drupol/phpcsfixer-configs-php/pull/52 I deleted a wrong line.
I will provide a fix with minimum requirements too.
Steps required to reproduce the problem
When using the
-vvv
option to see the rules used for #7. I saw some deprecations.