Skip to content

Commit 743465a

Browse files
committed
Fix CS
1 parent 1b5bc4d commit 743465a

File tree

7 files changed

+107
-98
lines changed

7 files changed

+107
-98
lines changed

phpcs.xml.dist

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
<?xml version="1.0"?>
22
<ruleset>
3-
<file>bootstrap.php</file>
4-
<file>src/</file>
5-
<file>tests/</file>
3+
<file>bootstrap.php</file>
4+
<file>src/</file>
5+
<file>tests/</file>
66

7-
<exclude-pattern>tests/data</exclude-pattern>
8-
<exclude-pattern>tests/functions.php</exclude-pattern>
7+
<exclude-pattern>tests/data/*</exclude-pattern>
8+
<exclude-pattern>tests/functions.php</exclude-pattern>
99

10-
<rule ref="PSR12NeutronRuleset">
11-
<exclude name="Generic.Files.LineLength"/>
12-
<exclude name="PEAR.Commenting.ClassComment"/>
13-
<exclude name="PEAR.Commenting.FileComment"/>
14-
</rule>
10+
<rule ref="PSR12NeutronRuleset">
11+
<exclude name="Generic.Files.LineLength"/>
12+
<exclude name="PEAR.Commenting.ClassComment"/>
13+
<exclude name="PEAR.Commenting.FileComment"/>
14+
</rule>
1515

16-
<rule ref="NeutronStandard.Functions.TypeHint">
17-
<exclude-pattern>*/tests/*</exclude-pattern>
18-
</rule>
19-
20-
<rule ref="NeutronStandard.Globals.DisallowGlobalFunctions">
21-
<exclude-pattern>*/tests/*</exclude-pattern>
22-
</rule>
23-
24-
<rule ref="WordPress.PHP.DiscouragedPHPFunctions">
25-
<exclude-pattern>*/tests/*</exclude-pattern>
26-
</rule>
27-
28-
<rule ref="WordPress.Security.NonceVerification">
29-
<exclude-pattern>*/tests/*</exclude-pattern>
30-
</rule>
16+
<!-- PHPCS does not understand yield -->
17+
<rule ref="NeutronStandard.Functions.TypeHint.UnusedReturnType">
18+
<exclude-pattern>tests/DynamicReturnTypeExtensionTest.php</exclude-pattern>
19+
</rule>
3120
</ruleset>

phpunit.xml.dist

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<phpunit
2-
bootstrap="tests/bootstrap.php"
3-
colors="true"
4-
failOnRisky="true"
5-
failOnWarning="true"
2+
bootstrap="tests/bootstrap.php"
3+
colors="true"
4+
failOnRisky="true"
5+
failOnWarning="true"
66
>
7-
<testsuites>
8-
<testsuite name="main">
9-
<directory>./tests/</directory>
10-
</testsuite>
11-
</testsuites>
7+
<testsuites>
8+
<testsuite name="main">
9+
<directory>./tests/</directory>
10+
</testsuite>
11+
</testsuites>
1212
</phpunit>

tests/DynamicReturnTypeExtensionTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66

77
class DynamicReturnTypeExtensionTest extends \PHPStan\Testing\TypeInferenceTestCase
88
{
9-
109
/**
1110
* @return iterable<mixed>
1211
*/
1312
public function dataFileAsserts(): iterable
1413
{
15-
// path to a file with actual asserts of expected types:
14+
// Path to a file with actual asserts of expected types:
1615
yield from $this->gatherAssertTypes(__DIR__ . '/data/_get_list_table.php');
1716
yield from $this->gatherAssertTypes(__DIR__ . '/data/apply_filters.php');
1817
yield from $this->gatherAssertTypes(__DIR__ . '/data/current_time.php');
@@ -35,7 +34,7 @@ public function testFileAsserts(string $assertType, string $file, ...$args): voi
3534

3635
public static function getAdditionalConfigFiles(): array
3736
{
38-
// path to your project's phpstan.neon, or extension.neon in case of custom extension packages
39-
return [__DIR__ . '/../extension.neon'];
37+
// Path to your project's phpstan.neon, or extension.neon in case of custom extension packages.
38+
return [dirname(__DIR__) . '/extension.neon'];
4039
}
4140
}

tests/HookDocsRuleTest.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ protected function getRule(): \PHPStan\Rules\Rule
2222
$ruleLevelHelper = self::getContainer()->getByType(RuleLevelHelper::class);
2323

2424
// getRule() method needs to return an instance of the tested rule
25-
return new HookDocsRule(
26-
$fileTypeMapper,
27-
$ruleLevelHelper
28-
);
25+
return new HookDocsRule($fileTypeMapper, $ruleLevelHelper);
2926
}
3027

3128
// phpcs:ignore NeutronStandard.Functions.LongFunction.LongFunction
@@ -41,43 +38,43 @@ public function testRule(): void
4138
[
4239
[
4340
'Expected 2 @param tags, found 1.',
44-
14,
41+
22,
4542
],
4643
[
4744
'Expected 2 @param tags, found 3.',
48-
23,
45+
31,
4946
],
5047
[
5148
'@param string $one does not accept actual type of parameter: int|string.',
52-
34,
49+
43,
5350
],
5451
[
5552
'@param string $one does not accept actual type of parameter: int.',
56-
43,
53+
53,
5754
],
5855
[
5956
'@param tag must not be named $this. Choose a descriptive alias, for example $instance.',
60-
70,
57+
82,
6158
],
6259
[
6360
'Expected 2 @param tags, found 1.',
64-
85,
61+
97,
6562
],
6663
[
6764
'@param ChildTestClass $one does not accept actual type of parameter: ParentTestClass.',
68-
119,
65+
134,
6966
],
7067
[
7168
'@param string $one does not accept actual type of parameter: string|null.',
72-
138,
69+
155,
7370
],
7471
[
7572
'One or more @param tags has an invalid name or invalid syntax.',
76-
153,
73+
170,
7774
],
7875
[
7976
'One or more @param tags has an invalid name or invalid syntax.',
80-
179,
77+
206,
8178
],
8279
]
8380
);

tests/bootstrap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace SzepeViktor\PHPStan\WordPress\Tests;
66

7+
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting
78
error_reporting(E_ALL);
89

9-
require_once __DIR__ . '/../vendor/autoload.php';
10+
require_once dirname(__DIR__) . '/vendor/autoload.php';
1011
require_once __DIR__ . '/functions.php';

0 commit comments

Comments
 (0)