Skip to content

Commit eb48166

Browse files
committed
misc
1 parent 3702711 commit eb48166

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
composer.lock
22
/vendor
3+
4+
.phpunit.result.cache

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Tests for compatibility with PHPStand and PHPUnit preload magic",
44
"require-dev": {
55
"php": "^8.2",
6-
"phpunit/phpunit": "^9.6|^10.*|^11.*|^12.*",
6+
"phpunit/phpunit": "^9.6|10.*|11.*|12.*",
77
"rector/rector": "^2.2",
88
"phpstan/phpstan": "^2.1"
99
},

phpunit.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
>
9+
<testsuites>
10+
<testsuite name="Project Tests">
11+
<directory>tests</directory>
12+
</testsuite>
13+
</testsuites>
14+
</phpunit>

src/PHPStan/CustomPHPStanRule.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
final class CustomPHPStanRule implements Rule
1818
{
19+
public const ERROR_MESSAGE = 'Class "%s" is not final.';
20+
1921
public function getNodeType(): string
2022
{
2123
return Class_::class;
@@ -32,7 +34,7 @@ public function processNode(Node $node, Scope $scope): array
3234
}
3335

3436
$ruleErrorMessage = RuleErrorBuilder::message(
35-
sprintf('Class "%s" is not final.', $node->name->toString())
37+
sprintf(self::ERROR_MESSAGE, $node->name->toString())
3638
)->build();
3739

3840
return [$ruleErrorMessage];

tests/PHPStan/CustomPHPStanRule/CustomPHPStanRuleTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Rector\RectorCompatTests\Tests\PHPStan\CustomPHPStanRule;
46

57
use PHPStan\Rules\Rule;
@@ -8,7 +10,12 @@
810

911
final class CustomPHPStanRuleTest extends RuleTestCase
1012
{
11-
// @todo
13+
public function testRule(): void
14+
{
15+
$this->analyse([__DIR__ . '/Fixture/NonFinalClass.php'], [
16+
[sprintf(CustomPHPStanRule::ERROR_MESSAGE, "NonFinalClass"), 7]
17+
]);
18+
}
1219

1320
protected function getRule(): Rule
1421
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\RectorCompatTests\Tests\PHPStan\CustomPHPStanRule\Fixture;
6+
7+
class NonFinalClass
8+
{
9+
10+
}

0 commit comments

Comments
 (0)