Skip to content

Commit

Permalink
Merge pull request #7 from vossik/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
peldax committed May 18, 2021
2 parents dfaa823 + e8267fd commit 1fbe30c
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.0'
env:
update: true

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
.idea/*
vendor/*
Expand Up @@ -72,10 +72,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $variablePointer
$phpcsFile->fixer->endChangeset();
}

/**
* @return int|bool|null
*/
private function findVisibilityPointer(\PHP_CodeSniffer\Files\File $phpcsFile, $variablePointer)
private function findVisibilityPointer(\PHP_CodeSniffer\Files\File $phpcsFile, $variablePointer) : int|bool|null
{
$visibilityPointer = $phpcsFile->findPrevious([\T_PUBLIC, \T_PROTECTED, \T_PRIVATE], $variablePointer);

Expand Down
Expand Up @@ -127,13 +127,7 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr) : voi
}
}

/**
* @param \PHP_CodeSniffer\Files\File $phpcsFile
* @param int|bool|null $stackPtr
* @param int|null $end
* @return bool|int
*/
private function findNextCase(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr, ?int $end = null)
private function findNextCase(\PHP_CodeSniffer\Files\File $phpcsFile, int|bool|null $stackPtr, ?int $end = null) : bool|int
{
$tokens = $phpcsFile->getTokens();

Expand Down
Expand Up @@ -31,28 +31,28 @@ public function process(\PHP_CodeSniffer\Files\File $phpcsFile, $usePointer) : v
$tokens = $phpcsFile->getTokens();
$nextTokenPointer = TokenHelper::findNextEffective($phpcsFile, $usePointer + 1);
\assert(\is_int($nextTokenPointer));

if ($tokens[$nextTokenPointer]['code'] === \T_STRING
&& ($tokens[$nextTokenPointer]['content'] === 'function' || $tokens[$nextTokenPointer]['content'] === 'const')
) {
$nextTokenPointer = TokenHelper::findNextEffective($phpcsFile, $nextTokenPointer + 1);
\assert(\is_int($nextTokenPointer));
}

if ($tokens[$nextTokenPointer]['code'] === \T_NS_SEPARATOR) {
return;
}

$fix = $phpcsFile->addFixableError(
'Use statement must start with a backslash.',
$nextTokenPointer,
self::CODE_DOES_NOT_START_WITH_BACKSLASH,
);

if (!$fix) {
return;
}

$phpcsFile->fixer->beginChangeset();
$phpcsFile->fixer->addContentBefore($nextTokenPointer, '\\');
$phpcsFile->fixer->endChangeset();
Expand Down
Expand Up @@ -14,6 +14,7 @@ class MemberVarSpacingSniff extends \PHP_CodeSniffer\Sniffs\AbstractVariableSnif
* @return int|void
*/
//@phpcs:ignore Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
//@phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
protected function processMemberVar(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
Expand Down
18 changes: 1 addition & 17 deletions InfinityloopCodingStandard/ruleset.xml
Expand Up @@ -8,10 +8,6 @@
<arg value="s"/> <!-- Display name of sniff used to detect/fix issue -->
<arg value="p"/> <!-- Display progress -->
<config name="installed_paths" value="./../../slevomat/coding-standard,./../../infinityloop-dev/coding-standard"/>
<file>./../../../../../../app</file> <!-- Files to check - relative from ruleset location -->
<file>./../../../../../../bin</file>
<file>./../../../../../../tests</file>
<file>./../../../../../../www</file>
<exclude-pattern>*/tests/*/data/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/vendor-bin/*</exclude-pattern>
Expand Down Expand Up @@ -255,7 +251,6 @@
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming">
Expand Down Expand Up @@ -423,17 +418,6 @@
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword">
<properties>
<property name="keywordsToCheck" type="array">
<element value="T_EXTENDS"/>
<element value="T_IMPLEMENTS"/>
<element value="T_USE"/>
<element value="T_NEW"/>
<element value="T_THROW"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
Expand Down Expand Up @@ -484,7 +468,7 @@
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<rule ref="SlevomatCodingStandard.Functions.TrailingCommaInCall"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
<rule ref="SlevomatCodingStandard.Numbers.DisallowNumericLiteralSeparator"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -6,15 +6,15 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.4",
"squizlabs/php_codesniffer": "~3.5.3",
"slevomat/coding-standard": "~6.3.8"
"php": "^8.0",
"squizlabs/php_codesniffer": "~3.6.0",
"slevomat/coding-standard": "~7.0.8"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.2"
},
"scripts": {
"codestyle": "phpcs --standard=vendor-bin/phpcs/vendor/infinityloop-dev/coding-standard/InfinityloopCodingStandard/ruleset.xml --extensions=php InfinityloopCodingStandard"
"codestyle": "phpcs --standard=InfinityloopCodingStandard --extensions=php InfinityloopCodingStandard"
},
"autoload": {
"psr-4": {
Expand Down

0 comments on commit 1fbe30c

Please sign in to comment.