Skip to content

Commit

Permalink
NarrowPublicClassMethodParamTypeRule: Added failling test-case
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jul 8, 2024
1 parent 7a96f32 commit b05a37c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture;

use PhpParser\Node;

final class SkipPhpDoc
{
public function called($node)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public function testRule(array $filePaths, array $expectedErrorsWithLines): void

public static function provideData(): Iterator
{
// skip phpdoc types
yield [[
__DIR__ . '/Fixture/SkipPhpDoc.php',
__DIR__ . '/Source/SkipPhpDoc/CallByPhpDoc.php',
__DIR__ . '/Source/SkipPhpDoc/CallByPhpDocString.php',
], []];

yield [[__DIR__ . '/Fixture/SkipNonPublicClassMethod.php'], []];

// skip first class callables as anything can be passed there
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Source\ExpectedThisType;

use Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture\SkipPhpDoc;
use Rector\TypePerfect\Tests\Rules\NarrowPublicClassMethodParamTypeRule\Fixture\SkipThisPassedExactType;

final class CallByPhpDoc
{
/**
* @param int $i
*/
public function run(SkipPhpDoc $skipPhpDoc, $i): void
{
$skipPhpDoc->called($i);
}
}

0 comments on commit b05a37c

Please sign in to comment.