Skip to content

Commit

Permalink
Merge pull request #48 from geerteltink/fix/native-typhint-autofix
Browse files Browse the repository at this point in the history
Disable automatic missing native typehint fixing
  • Loading branch information
geerteltink committed Oct 25, 2020
2 parents 38d9a9a + 02cd847 commit e636343
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
3 changes: 3 additions & 0 deletions src/LaminasCodingStandard/ruleset.xml
Expand Up @@ -808,6 +808,9 @@
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>

<!-- The asterisks in a DocBlock should align, and there should be one
Expand Down
10 changes: 5 additions & 5 deletions test/expected-report.txt
Expand Up @@ -11,10 +11,10 @@ test/fixable/2.5.KeywordsAndTypes.php 8 0
test/fixable/2.6.Variables.php 3 0
test/fixable/2.7.Arrays.php 9 0
test/fixable/3.DeclareNamespaceAndImport.php 12 0
test/fixable/4.1.ExtendsAndImplements.php 5 0
test/fixable/4.1.ExtendsAndImplements.php 6 0
test/fixable/4.2.UsingTraits.php 5 0
test/fixable/4.3.PropertiesAndConstants.php 7 0
test/fixable/4.4.MethodsAndFunctions.php 27 0
test/fixable/4.4.MethodsAndFunctions.php 26 0
test/fixable/4.5.MethodAndFunctionArguments.php 66 0
test/fixable/4.6.AbstractFinalAndStatic.php 5 0
test/fixable/4.7.MethodAndFunctionCalls.php 11 0
Expand All @@ -30,14 +30,14 @@ test/fixable/6.1.UnaryOperators.php 6 0
test/fixable/6.2.BinaryOperators.php 35 0
test/fixable/6.3.TernaryOperators.php 13 0
test/fixable/6.Operators.php 97 0
test/fixable/7.Closures.php 4 0
test/fixable/7.Closures.php 2 0
test/fixable/8.AnonymousClasses.php 1 0
test/fixable/9.CommentingAndDocBlocks.php 17 0
test/fixable/9.GenericTypeHintSyntax.php 4 0
----------------------------------------------------------------------
A TOTAL OF 568 ERRORS AND 2 WARNINGS WERE FOUND IN 31 FILES
A TOTAL OF 566 ERRORS AND 2 WARNINGS WERE FOUND IN 31 FILES
----------------------------------------------------------------------
PHPCBF CAN FIX 484 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
PHPCBF CAN FIX 483 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


5 changes: 5 additions & 0 deletions test/fixable/4.1.ExtendsAndImplements.php
Expand Up @@ -16,6 +16,11 @@ class ExtendsAndImplements
ArrayAccess,
Countable,
Serializable {
public function testImplementedMethodWithoutTypeHint()
{
// This method should not have the missing return type added after
// running the fixer.
}
public function testClassDeclaration(): void
{
// The extends and implements keywords MUST be declared on the same line
Expand Down
8 changes: 6 additions & 2 deletions test/fixable/7.Closures.php
Expand Up @@ -41,6 +41,10 @@ public function testClosures(): void
echo "$arg1, $arg2";
};

$closureWithoutReturnType = function ($arg1, $arg2) {
echo "$arg1, $arg2";
};

$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2): void {
echo "$arg1, $arg2, $var1, $var2";
};
Expand All @@ -49,7 +53,7 @@ public function testClosures(): void
return $arg1 === $arg2 && $var1 === $var2;
};

$multiLineCLosre = function (
$multiLineClosure = function (
$arg1,
$arg2
) use (
Expand All @@ -65,7 +69,7 @@ public function testInheritedVariablesMustBeUsed(): void
// Inherited variables passed via `use` MUST be used in closures.

$message = 'world';
$example = function ($arg) use ($message, $extraVar) {
$example = function ($arg) use ($message, $extraVar): void {
echo "$arg $message";
};
$example('hello');
Expand Down
6 changes: 6 additions & 0 deletions test/fixed/4.1.ExtendsAndImplements.php
Expand Up @@ -14,6 +14,12 @@ class ExtendsAndImplements extends ParentClass implements
Countable,
Serializable
{
public function testImplementedMethodWithoutTypeHint()
{
// This method should not have the missing return type added after
// running the fixer.
}

public function testClassDeclaration(): void
{
// The extends and implements keywords MUST be declared on the same line
Expand Down
2 changes: 1 addition & 1 deletion test/fixed/4.4.MethodsAndFunctions.php
Expand Up @@ -6,7 +6,7 @@

class MethodsAndFunctions
{
public function testMethodsAndFunctions($arg1, &$arg2, $arg3 = []): void
public function testMethodsAndFunctions($arg1, &$arg2, $arg3 = [])
{
// Visibility MUST be declared on all methods.
//
Expand Down
6 changes: 5 additions & 1 deletion test/fixed/7.Closures.php
Expand Up @@ -41,6 +41,10 @@ public function testClosures(): void
echo "$arg1, $arg2";
};

$closureWithoutReturnType = function ($arg1, $arg2) {
echo "$arg1, $arg2";
};

$closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2): void {
echo "$arg1, $arg2, $var1, $var2";
};
Expand All @@ -49,7 +53,7 @@ public function testClosures(): void
return $arg1 === $arg2 && $var1 === $var2;
};

$multiLineCLosre = function (
$multiLineClosure = function (
$arg1,
$arg2
) use (
Expand Down

0 comments on commit e636343

Please sign in to comment.