Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable automatic missing native typehint fixing #48

Merged
merged 1 commit into from Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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