PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
gsherwood on master
Fixed docblocks Because custom… (compare)
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)
;
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
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?
exclude-pattern
(absolute
or relative
) is not supported: https://github.com/squizlabs/PHP_CodeSniffer/blob/a2bde796c6a6313e0a8ed730d33a0eb2cabeafa8/src/Ruleset.php#L1230-L1237
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
$object = new \Abc();
- is there any sniff available that forces me to import that class instead of using the full class name?
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?
<file>./src/</file>
<exclude-pattern>var/*</exclude-pattern>
<exclude-pattern >vendor/*</exclude-pattern>
<file>./src/</file>
<exclude-pattern type="relative">^./var/*</exclude-pattern>
<exclude-pattern type="relative">^./vendor/*</exclude-pattern>
develop
, I can help you get that working, but I'd need a little more information on how you've installed and are running PHPCS/PHPCompatibility (Phar, clones, Composer).