Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yoda_style does not work with require and ternary #7280

Closed
nicohell opened this issue Sep 8, 2023 · 0 comments · Fixed by #7325
Closed

yoda_style does not work with require and ternary #7280

nicohell opened this issue Sep 8, 2023 · 0 comments · Fixed by #7325
Labels

Comments

@nicohell
Copy link

nicohell commented Sep 8, 2023

Bug report

Description

require is included in ternary test

Used command

php-cs-fixer fix scr/test.php --using-cache=no --rules=@Symfony -vvv
PHP CS Fixer 3.26.0 Crank Cake by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 8.2.6
Loaded config default.
F                                                                                                             1 / 1 (100%)
Legend: .-no changes, F-fixed, S-skipped (cached or empty file), I-invalid file syntax (file ignored), E-error
   1) scr/test.php (elseif, single_space_around_construct, no_unneeded_control_parentheses, increment_style, single_quote, no_useless_concat_operator, spaces_inside_parentheses, array_syntax, single_line_comment_spacing, blank_line_after_opening_tag, concat_space, no_singleline_whitespace_before_semicolons, no_spaces_around_offset, yoda_style, control_structure_continuation_position, no_trailing_whitespace, curly_braces_position, statement_indentation, cast_spaces, no_whitespace_in_blank_line, no_extra_blank_lines, binary_operator_spaces)

Fixed 1 of 1 files in 0.106 seconds, 6.000 MB memory used

Configuration file

<?php
  
$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__)
    ->exclude('somedir')
;

$config = new PhpCsFixer\Config();
return $config->setRules([
        '@Symfony' => true,
    ])
    ->setFinder($finder)
;

Code snippet that reproduces the problem

require $var == "false" ? "../scr/file.php" : "../scr/other_file.php";

is transformed to

'false' == require $var ? '../scr/file.php' : '../scr/other_file.php';

Expected result

require 'false' == $var ? '../scr/file.php' : '../scr/other_file.php';
@Wirone Wirone changed the title require included in ternary test yoda_style does not work with require and ternary Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant