by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 22:52
    jrfnl commented #2387
  • Jan 31 2019 22:41
    valeryan commented #2386
  • Jan 31 2019 22:40
    valeryan commented #2386
  • Jan 31 2019 22:40
    valeryan commented #2386
  • Jan 31 2019 22:17
    gsherwood commented #2387
  • Jan 31 2019 22:14
    gsherwood milestoned #2387
  • Jan 31 2019 22:13
    gsherwood labeled #2386
  • Jan 31 2019 22:13
    gsherwood commented #2386
  • Jan 31 2019 22:05
    gsherwood milestoned #2388
  • Jan 31 2019 22:03
    gsherwood labeled #2394
  • Jan 31 2019 22:02
    gsherwood commented #2394
  • Jan 31 2019 22:02
    gsherwood closed #2394
  • Jan 31 2019 22:02

    gsherwood on master

    Fixed docblocks Because custom… (compare)

  • Jan 31 2019 22:02
    gsherwood milestoned #2394
  • Jan 31 2019 16:50
  • Jan 31 2019 16:00
    SteepDevs starred squizlabs/PHP_CodeSniffer
  • Jan 31 2019 15:22
  • Jan 31 2019 14:39
    sebastiaanluca commented #2304
  • Jan 31 2019 14:38
    sebastiaanluca commented #2304
  • Jan 31 2019 13:09
    rlauenroth starred squizlabs/PHP_CodeSniffer
Alex
@aik099
I've found a hack (or maybe it's officially supported way) to add specific sniff codes as ignored for a specific lines in real time (from "process" method of the sniff like this):
$tokens = $phpcsFile->getTokens();
$phpcsFile->tokenizer->ignoredLines[$tokens[$stackPtr]['line']] = array(
    'CodingStandard.Commenting.FunctionComment.TypeHintMissing' => true,
);
Greg Sherwood
@gsherwood
@aik099 There is no officially supported way of doing this
Alex
@aik099
Any chance the code I’ve shown would continue to work in the future?
Greg Sherwood
@gsherwood
@aik099 I think I changed the way that code worked last year, so it's possible I wont change it again for a while, but I absolutely can't commit to that. If it needs to change to fix a bug or support new features, I'd change it.
Bfg10k
@bfg10k

Hi there, i'm using docker and i'm having a problem integrating a containerized php executable into PhpStorm with PHP CS. The problem is, as I guess you know, that containers should be remplazable and have as less persistance as it's possible but, for PHP CS to work as expected, i need to add the installed_paths so it knows about the symfony standard.

TLDR: I'm using a docker container and do not have a local PHP (neither I want) and the container does not know about the "installed_paths" when it's run.

PS: When I talk about installed Paths I mean the ones that refer to the avaliable standards.
Bfg10k
@bfg10k
Anyone can shred some light?
Kevin Nowaczyk
@Beakerboy
@bfg10k
When I created a new standard, I just passed the path to the standard in the command line like `phpcs —standard=/dev/Standard/
Kevin Nowaczyk
@Beakerboy
Hey everyone...I developed a new tokenizer type for PHPCS and I’m trying to test it in isolation. Since the constructor in the parent Tokenizer class does way more than construct, I needed to override this in a new Test class. My test class extends my new tokenizer and replaces __construct() with one that just saves the provided $string to a protected class member. Unfortunately, when I try to run everything I get an error that
“Use of undefined constant T_OPEN_CURLY_BRACKET - assumed 'T_OPEN_CURLY_BRACKET' (this will throw an Error in a future version of PHP)”
So this constant is defined in Util\Tokens. I added a use PHP_CodeSniffer\Util\Tokens; to my test case. What else do I need to do to get my test to see these constants?
Kevin Nowaczyk
@Beakerboy
I should say that adding a require() for this particular file in my phpunit bootstrap file did work. However, I feel the auto-loader should have been able to do it on its own...no?
Will Otterburn
@IkeLutra
Is there a sniff that detects when use statements aren't in alphabetical order?
Brian Smith
@justageek
in sublime text 3 with php cs and the Drupal standard, I cannot get the unused use statement to ever work, anyone know if there is some config option that must be specified?
Amir hossein Hossein Zadeh Karimi
@AmirHosseinKarimi
Hi, I'm try to add a rule to php-cbf for add a space character after end of php tags which the line will end with no other character.
Is there someone to help me?
mercurykd
@mercurykd

Hi, is it possible to extend phpcs rules(ruleset.xml) with phpcsfixer rules like yoda_style?

$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->notPath('')
->in(DIR)
;

$config = [
'@PSR2' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'yoda_style' => true,
];

return PhpCsFixer\Config::create()
->setUsingCache(false)
->setRules($config)
->setFinder($finder)
;

harrisdt15f
@harrisdt15f
Hello everyone which rule to be use for qualifier to use as import
image.png
I am trying to avoid this kind of warning occurs. please tell me which rule to cover it.
Greg Sherwood
@gsherwood
@harrisdt15f That's not a built-in PHPCS rule. I don't know which coding standard you are using, but you'll probably need to ask whoever maintains it.
harrisdt15f
@harrisdt15f
hello everyone I got this error need help please

root@faaab3cb17ad:/var/www/xuanwutenant/vendor/bin# ./phpcs --standard=/var/www/xuanwutenant/phpcs.xml /var/www/xuanwutenant/app/Http/Controllers/FrontendApi/FrontendAuthController.php
PHP Fatal error: Uncaught ReflectionException: Function SjczTDG4TDK0Tweg() does not exist in /var/www/xuanwutenant/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php:37
Stack trace:

#0 /var/www/xuanwutenant/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php(37): ReflectionFunction->construct('SjczTDG4TDK0Twe...')

#1 /var/www/xuanwutenant/vendor/squizlabs/php_codesniffer/src/Ruleset.php(1196): PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\DeprecatedFunctionsSniff->
construct()

#2 /var/www/xuanwutenant/vendor/squizlabs/php_codesniffer/src/Ruleset.php(217): PHP_CodeSniffer\Ruleset->populateTokenListeners()

#3 /var/www/xuanwutenant/vendor/squizlabs/php_codesniffer/src/Runner.php(332): PHP_CodeSniffer\Ruleset->__construct(Object(PHP_CodeSniffer\Config))

#4 /var/www/xuanwutenant/vendor/squizlabs/php_codesniffer/src/Runner.php(70): PHP_CodeSniffer\Runner->init()

#5 /var/www/xuanwutenant/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSn in /var/www/xuanwutenant/vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php on line 37

Greg Sherwood
@gsherwood
@harrisdt15f That sniff gets a list of all defined functions, then uses the reflection API to see if the functions marked "internal" are deprecated. I don't know why a function called SjczTDG4TDK0Tweg would be marked as an internal function by PHP, so I'm not sure how to help. Anything special you are doing that might cause this?
Kwadz
@Kwadz

Hello guys, on the Drupal forum, we are wondering if we should keep the Fully Qualified Class Name in phpDoc comment blocks.

So, in case of Unqualified Class Name used with use statement, do you know if PHP_CodeSniffer would complain about the "unused use statement" rule?

Alex
@aik099
Hi @Kwadz , no it won't complain. It doesn't check for that at all.
Kwadz
@Kwadz
Thanks!
TaylorSasser
@TaylorSasser
Hello, Is it possible to have phpcs flag class properties with no type? Is it also possible to phpcbf add in a property type based off what is set inside of the constructor?
Greg Sherwood
@gsherwood
@TaylorSasser You can use the PSR2.Classes.PropertyDeclaration sniff to enforce that member vars have visibility declared (or just use the PSR2 standard) but PHPCBF will not add visibility automatically for you. If visibility is not provided the member var is obviously public so it could be auto-fixed, but I prefer for PHPCBF to only make formatting fixes (or move code around) and not add new code for you. Missing visibility doesn't necessarily mean the developer wants the member var to be public - they may have just forgotten to set it - so it feels like a code review thing.
zainwah24
@zainwah24
Hi, is there a chat room for web developers.
C-Duv
@C-Duv
Hello, It looks like the type of path exclude-pattern (absolute or relative) is not supported: https://github.com/squizlabs/PHP_CodeSniffer/blob/a2bde796c6a6313e0a8ed730d33a0eb2cabeafa8/src/Ruleset.php#L1230-L1237
Glen
@glen-84
Will PHPCS 4 drop support for PHP < 7.2, so that we can use parameter type hints, etc. (in custom rules)? PHP 5.6 has been EOL for a long time now.
Juliette
@jrfnl
@glen-84 What's holding you back from doing that for your own standard already ?
Glen
@glen-84
@jrfnl
phpcs: Declaration of Glen84\Sniffs\Strings\DoubleQuoteUsageSniff::process(PHP_CodeSniffer\Files\File $phpcsFile, int $stackPtr) must be compatible with PHP_CodeSniffer\Sniffs\Sniff::process(PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr) in D:\Programming\Standards\phpcs\Glen84\Sniffs\Strings\DoubleQuoteUsageSniff.php on line 15
Glen
@glen-84
Why is the activity section to the right of Gitter not up-to-date?
Juliette
@jrfnl
@glen-84 Sorry about that, I was getting confused with return type declarations which can be added without an issue: https://3v4l.org/I0NaA
Glen
@glen-84
No problem. :slight_smile:
Nico Haase
@NicoHaase
Hi there! I'm searching for a specific sniff, but cannot find it - probably, because I'm unsure about the proper search terms.... Within some classes, I use code from other classes and instantiate it using $object = new \Abc(); - is there any sniff available that forces me to import that class instead of using the full class name?
harrisdt15f
@harrisdt15f
image.png
hello everyone which rule is able to use to check for commenting in constant.
Nico Haase
@NicoHaase
@harrisdt15f what do you mean by that? I don't see any comment in that constant
harrisdt15f
@harrisdt15f
@NicoHaase Thank you for your reply, I want to analyze like this kind of constant without having any comment, I means which rule can check to avoid writhing such kind of constant without having comments
Anton Samoylenko
@Fantom409
Hello. I got Codesniffer checking based on PSR12, but I need to include Generic.PHP.RequireStrictTypes also. Can I include this sniff via phpcs option or I need to create new ruleset that will include this sniff?
Greg Sherwood
@gsherwood
@Fantom409 You need to create a new ruleset for this
Shaunak Sontakke
@ssontakke
Does PHP_CodeSniffer integrate with Phabricator? I want to see PHP_CodeSniffer violations while I do code reviews on Phabricator.
Ricardo Puerto
@djibarian

Hello, I’m having this error:

 487 | ERROR | [x] Line indented incorrectly; expected 5 tabs, found
     |       |     6
     |       |     (Generic.WhiteSpace.ScopeIndent.IncorrectExact)

for the following code:

if(blah)
foreach(blah){
}

I guess is caused by the lack of brackets in the first line. Is that a bug of ScopeIndent or is there a flag or sniff that should be used to fix the error?

sorry the chat deleted the spaces in the second and third line, but there is 1 tab
of course if I add brackets to the if the error disappears