Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 10 2018 21:39
    @SpacePossum banned @jewome62_gitlab
Tom Klingenberg
@ktomk
which I think is unsupported by PHP-CS-Fixer.
btw. did you get some feedback on that fixer it would have been over-reaching?
nice to see DataProviderNameFixer.
if it would be me, no problem to see it in any of the Phpunit groups :)
Tom Klingenberg
@ktomk
@kubawerlos Maybe you have an idea about it: When I install your custom fixers via composer require, I need to update PHP-CS-Fixer also from 2.16.3 to 2.16.4. Somehow I can't tell composer to update it with the require command. I tried as well with --update-with-{all-,}dependencies, but no luck. Wondering if it's possible with one composer command.
Tom Klingenberg
@ktomk
@kubawerlos thanks again, this helped a lot. I'm also through with the list of all the other custom fixers and took in some more. Most noteworthy feedback from my end: For the data-provider fixer it was over-reaching for my taste, as I only have the requirement that those should be prefixed with "provide", so the fixer was doing too much for me. I also liked the param fixer, however I sometimes have @psalm-param annotations and the fixer was not aware of them a equal @param annotations so I could only use it temporary and then cherry-pick. All in all a nice collection!
Dave van der Brugge
@dmvdbrugge

@ktomk did I see correctly you were looking to add a space like this

-if(true){
+if (true) {

Because if you are, braces does that already. (See here why braces does too much.)

Tom Klingenberg
@ktomk
@dmvdbrugge specifically foreach (similar language constructs like if as well, but the issue was with foreach).
Checking braces as well now.
Dave van der Brugge
@dmvdbrugge
It's the same kind of language construct, yes it works for foreach as well
Tom Klingenberg
@ktomk
hmm, just seeing in that project I hadn't had it activated. I'll give it a try going back in time.
Tom Klingenberg
@ktomk
@dmvdbrugge works like a charm. thanks for the tip!
Simon Brüchner
@powtac
Can I use --diff --dry-run both at the same time?
Tom Klingenberg
@ktomk
@powtac yes
Dave van der Brugge
@dmvdbrugge
Doesn't dryrun automatically show the diff?
Or does that happen because I always use -vvv?
Tom Klingenberg
@ktomk
@dmvdbrugge neither. -vvv does not do that with --dry-run. --diff does (with --dry-run)
Dave van der Brugge
@dmvdbrugge
Then my scripts probably just use the combination lol, couldn't fully remember
Chin Leung
@chinleung
I activated the is_null rule, but it is using yoda_style by default even though I did not activate the yoda_style rule. I can fix this by setting use_yoda_style to false, but it says DEPRECATED: use yoda_style fixer instead in the doc. So how should I proceed?
Kuba Werłos
@kubawerlos
@chinleung use yoda_style with set up to make non-Yoda conditions, like this: https://github.com/kubawerlos/php-cs-fixer-config/blob/v1.4.0/src/Rules/LibraryRules.php#L310
Chin Leung
@chinleung
@kubawerlos Thanks! ✌🏼
Diar
@Diarselimi
Hi Guys,
I am looking for Arrow Functions rules to add in the fixer, is it supported?
Faithu
@Faithu
anyone online to help?
Ghost
@ghost~5f502287d73408ce4fede8bb
Hi guys, I'm trying to make work a local project configuration of PHP-CS-Fixer (using @PhpCsFixer rules) to work with PHP Code Sniffer (using PSR2 rules), there are lots of conflicts between the rulesets .php_cs config and phpcs.xml; is there available some ruleset converter to "make the ends meet"?
Scott Collier
@out-of-band

Is there a setting to control how imports are cleaned up in relation to docblocks? Assuming I'm using no_unused_imports=true. If I've got something like ...

/** @var Foo[] $foo */
$foo = ...

When I try to add use Foo;, php-cs-fixer removes it.

Ghost
@ghost~5f61f368d73408ce4fef0f66
Hey guys, I have a (hopefully) quick question about the config
PHP-CS-Fixer seems to be set to change class names to self when applicable (e.g. it would change Models\User to self within the class Models\User)
Can this be turned off easily, if so how?
Ghost
@ghost~5f61f368d73408ce4fef0f66

I found this
https://mlocati.github.io/php-cs-fixer-configurator/#version:2.16|fixer:self_accessor

It says that this fixer is not configurable, does that mean it can't be turned off? (aside from not allowing risky changes)

Kuba Werłos
@kubawerlos

Hi @FonsAtabix, every fixer can be very easily turned off, by having:

'self_accessor' => false

in the rules

Ghost
@ghost~5f61f368d73408ce4fef0f66
@kubawerlos Oh now I see where I need to change what!
Thanks a lot!
MGatner
@MGatner
Anyone here? I just discovered PHP-CS-Fixer, recommended by a friend. Great tool! I've been using a few others but non and support to convert alternative control structures. I was able to do that just fine with fix rules=no_alternative_syntax but now have an issue...
I need the braces it creates from this to be on the next line. I found 'braces' => ['position_after_control_structures' => 'next'] and dropped it in a config file with 'no_alternative_syntax' => true but no matter what I do it still applies a bunch of other rules (like changed indentation type). What am I doing wrong??
Here's my config file:
$finder = PhpCsFixer\Finder::create()
    ->exclude('app/Views')
    ->in(__DIR__);

return PhpCsFixer\Config::create()
    ->setRules([
        '@PhpCsFixer' => false,
        'no_alternative_syntax' => true,
        'braces' => ['position_after_control_structures' => 'next'],
    ])
    ->setFinder($finder);
(You see where I tried to turn off @PhpCsFixer in case that was automatically on with config files or something)
MGatner
@MGatner
Okay, got it! It wasn't that it was applying other rules, it was using spaces for indents (which wasn't a problem until I used a rule with newlines). Add ->setIndent("\t") and it's working great.
Andrew Hoffmann
@hamdrew
Hi! I am a PHP developer looking to contribute to this project, inspired by Hacktoberfest (but not necessarily motivated by it). I've already been poking around the Issues board, getting the project set up, and playing around in the code. While I am happy to grab something from the Issues board on my own, if there is any prioritization you could provide, that will be helpful! I am currently looking at the PSR-12 issue, as that seems urgent since PSR-2 is deprecated.
I was going to grab one of the TODOs in the checklist.
Julien Falque
@julienfalque
Hi @hamdrew, that's awesome, thanks! :)
Andrew Hoffmann
@hamdrew
Also, I am really curious what a space possum is.
Julien Falque
@julienfalque
indeed PSR-12 is quite urgent, but IMHO PHP 8 support is even more: missing PSR-12 rules does not prevent running the tool, incompatibility with PHP 8 will
Andrew Hoffmann
@hamdrew
Makes sense!
Julien Falque
@julienfalque
but if you prefer grabbing a PSR-12 issue, that's fine, such contributions are very welcome anyway :)
Andrew Hoffmann
@hamdrew
Thank you for the guidance! I'll take a look at php8 and see where I can help
vajexal
@vajexal
Hi! Could you please help me with question about function_declaration rule? Maybe spacing configuration option for arrow functions should be added? For case when closures should be formatted with whitespace before open parenthesis and arrow functions without
`function() {}` => `function () {}`
`fn () => ...` => `fn() => ...`
codigoergosum
@codigoergosum

I've just started using PHP-CS-Fixer and run across an oddity. I looked in the bugs and didn't find one. So I wonder if it's a misconfiguration on my part.
We're using Allman style braces--initial curly on the next line--and it works great except for switch statements, where the initial curly is still on the same line. Do I need to configure differently?

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'@PhpCsFixer' => true,
'braces' => ['position_after_control_structures' => 'next'],
'concat_space' => ['spacing' => 'one'],
'yoda_style' => ['equal' => null, 'identical' => null],
])
;

Lukas Oppermann
@lukasoppermann

Hey, I have an old project that I want to add some fixes too. However when I run vendor/bin/php-cs-fixer fix -v --diff --dry-run I get:

Loaded config from "/Users/lukasoppermann/Repos/http-status/.php_cs"
E.EE
Legend: ?-unknown, I-invalid file syntax, file ignored, .-no changes, F-fixed, E-error
Checked all files in 0.288 seconds, 6.000 MB memory used

Files that were not fixed due to internal error:
1) Httpstatus.php
2) HttpstatuscodesTest.php
3) HttpstatusTest.php

I am at a loss what I can do now. How to I find out what errors are there?

SpacePossum
@SpacePossum
hi!
can try running the tool with -vvv to see if you get any more details?
Lukas Oppermann
@lukasoppermann
Hey, I got it figured out now, was an issue with updating the php_cs file. Thank you for the help.
SpacePossum
@SpacePossum
good to hear! : )
codigoergosum
@codigoergosum

I just had self-update fail. I originally installed vscode-php-cs-fixer-0.4.0, which came with php-cs-fixer 2.15.8.
C:\Users\Lee.vscode\extensions\fterrag.vscode-php-cs-fixer-0.4.0>php c:\Users\Lee.vscode\extensions\fterrag.vscode-php-cs-fixer-0.4.0/php-cs-fixer self-update -vvv Unable to determine newest version: Failed to load tags at "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/tags".

Working around this, I did:
curl -L https://cs.symfony.com/download/php-cs-fixer-v2.phar -o php-cs-fixer
which got 2.16.4. Then I explicitly got
curl -L https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.5/php-cs-fixer.phar -o php-cs-fixer

But self-update failed the same way with all versions. Are there install troubleshooting tips anywhere? self-update seems like a handy feature to have; I'd like to get it working for me.

Thanks!