-
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathTranslationInterfaceNullArgumentRuleTest.php
More file actions
77 lines (71 loc) · 3.34 KB
/
TranslationInterfaceNullArgumentRuleTest.php
File metadata and controls
77 lines (71 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
declare(strict_types=1);
namespace mglaman\PHPStanDrupal\Tests\Rules;
use mglaman\PHPStanDrupal\Tests\DrupalRuleTestCase;
use PHPStan\Rules\FunctionCallParametersCheck;
use PHPStan\Rules\Methods\CallMethodsRule;
use PHPStan\Rules\Methods\MethodCallCheck;
use PHPStan\Rules\Rule;
use PHPUnit\Framework\Attributes\DataProvider;
final class TranslationInterfaceNullArgumentRuleTest extends DrupalRuleTestCase
{
protected function getRule(): Rule
{
$container = self::getContainer();
/** @phpstan-ignore phpstanApi.constructor */
return new CallMethodsRule(
/** @phpstan-ignore phpstanApi.classConstant */
$container->getByType(MethodCallCheck::class),
/** @phpstan-ignore phpstanApi.classConstant */
$container->getByType(FunctionCallParametersCheck::class),
);
}
/**
* @param list<array{0: string, 1: int, 2?: string|null}> $errorMessages
*/
#[DataProvider('resultData')]
public function testRule(string $path, array $errorMessages): void
{
$this->analyse([$path], $errorMessages);
}
public static function resultData(): \Generator
{
yield [
__DIR__ . '/data/translation-interface-null-argument.php',
[
[
"Parameter #2 \$args of method Drupal\Core\StringTranslation\TranslationInterface::translate() expects array<non-empty-string, string|Stringable>, array{'@name': null} given.",
10,
],
[
"Parameter #4 \$args of method Drupal\Core\StringTranslation\TranslationInterface::formatPlural() expects array<non-empty-string, string|Stringable>, array{'@name': null} given.",
11,
],
[
"Parameter #2 \$args of method Drupal\Core\StringTranslation\TranslationInterface::translate() expects array<non-empty-string, string|Stringable>, array{'@name': string|null} given.",
15,
],
[
"Parameter #4 \$args of method Drupal\Core\StringTranslation\TranslationInterface::formatPlural() expects array<non-empty-string, string|Stringable>, array{'@name': string|null} given.",
16,
],
[
"Parameter #2 \$args of method Drupal\Core\StringTranslation\TranslationInterface::translate() expects array<non-empty-string, string|Stringable>, array{'': string} given.",
35,
],
[
"Parameter #4 \$args of method Drupal\Core\StringTranslation\TranslationInterface::formatPlural() expects array<non-empty-string, string|Stringable>, array{'': string} given.",
36,
],
[
"Parameter #2 \$args of method Drupal\Core\StringTranslation\TranslationInterface::translate() expects array<non-empty-string, string|Stringable>, non-empty-array<string, string> given.",
40,
],
[
"Parameter #4 \$args of method Drupal\Core\StringTranslation\TranslationInterface::formatPlural() expects array<non-empty-string, string|Stringable>, non-empty-array<string, string> given.",
41,
],
],
];
}
}