Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a2f1a1f

Browse files
[cs] update coding standard to allow PHP 8 and Slevomat CS 6.4 (phpstan#58)
1 parent 35c6094 commit a2f1a1f

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

‎build-cs/composer.json‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
2+
"require": {
3+
"php": "^7.1 || ^8.0"
4+
},
25
"require-dev": {
3-
"consistence/coding-standard": "^3.5",
4-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
5-
"slevomat/coding-standard": "^4.7.2"
6+
"consistence/coding-standard": "^3.10",
7+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
8+
"slevomat/coding-standard": "^6.4.1"
69
}
710
}

‎build.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<arg value="install"/>
6161
<arg value="--working-dir"/>
6262
<arg path="build-cs"/>
63+
<arg value="--ignore-platform-reqs"/>
6364
<arg value="--ansi"/>
6465
</exec>
6566
<exec

‎phpcs.xml‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0"?>
22
<ruleset name="PHPStan PHPDoc Parser">
3+
<config name="php_version" value="70100"/>
34
<rule ref="build-cs/vendor/consistence/coding-standard/Consistence/ruleset.xml">
45
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat"/>
56
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/>
@@ -20,19 +21,15 @@
2021
<property name="newlinesCountBetweenOpenTagAndDeclare" value="0"/>
2122
</properties>
2223
</rule>
23-
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
24-
<properties>
25-
<property name="usefulAnnotations" type="array" value="
26-
@dataProvider,
27-
@requires
28-
"/>
29-
<property name="enableObjectTypeHint" value="false"/>
30-
</properties>
31-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/>
32-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification"/>
24+
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"/>
25+
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
26+
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
27+
</rule>
28+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
29+
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
3330
</rule>
3431
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
35-
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/>
32+
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
3633
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
3734
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
3835
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>

‎src/Parser/ConstExprParser.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ public function parse(TokenIterator $tokens, bool $trimStrings = false): Ast\Con
1414
$value = $tokens->currentTokenValue();
1515
$tokens->next();
1616
return new Ast\ConstExpr\ConstExprFloatNode($value);
17+
}
1718

18-
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_INTEGER)) {
19+
if ($tokens->isCurrentTokenType(Lexer::TOKEN_INTEGER)) {
1920
$value = $tokens->currentTokenValue();
2021
$tokens->next();
2122
return new Ast\ConstExpr\ConstExprIntegerNode($value);
23+
}
2224

23-
} elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) {
25+
if ($tokens->isCurrentTokenType(Lexer::TOKEN_SINGLE_QUOTED_STRING)) {
2426
$value = $tokens->currentTokenValue();
2527
if ($trimStrings) {
2628
$value = trim($tokens->currentTokenValue(), "'");

‎src/Parser/TypeParser.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ private function parseAtomic(TokenIterator $tokens): Ast\Type\TypeNode
4747
}
4848

4949
return $type;
50-
} elseif ($tokens->tryConsumeTokenType(Lexer::TOKEN_THIS_VARIABLE)) {
50+
}
51+
52+
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_THIS_VARIABLE)) {
5153
$type = new Ast\Type\ThisTypeNode();
5254

5355
if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /