Skip to content

Commit 24fc9ea

Browse files
committed
Test: Add test for PhpDoc property fixer/sniff
1 parent 0f34419 commit 24fc9ea

File tree

5 files changed

+55
-27
lines changed

5 files changed

+55
-27
lines changed

tests/Integration/CodingStandardTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function provideFilesToFix(): array
3636
__DIR__ . '/Fixtures/NewPhpFeatures.wrong.php.inc',
3737
__DIR__ . '/Fixtures/NewPhpFeatures.correct.php.inc',
3838
],
39+
'PhpDoc' => [__DIR__ . '/Fixtures/PhpDoc.wrong.php.inc', __DIR__ . '/Fixtures/PhpDoc.correct.php.inc'],
3940
];
4041
}
4142

tests/Integration/Fixtures/Basic.correct.php.inc

-13
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,6 @@ class Basic extends AbstractBasic implements InterfaceFromThisNamespace // Fully
127127
];
128128
}
129129

130-
/**
131-
* Very well documented method.
132-
* It tests PhpdocAlignFixer, NoSuperfluousPhpdocTagsFixer and possibly other Phpdoc rules.
133-
* @param int|float $second Second parameter does have a comment, unlike the first one.
134-
* @param string|null $third Third parameter is optional and has a default value.
135-
* @return mixed There is also information about return type.
136-
* @throws \Exception
137-
*/
138-
public function veryWellDocumented(string $first, int|float $second, ?string $third = '3rd'): mixed
139-
{
140-
return $first . $third;
141-
}
142-
143130
public function emptyFunction1(): void {} // SingleLineEmptyBodyFixer
144131

145132
public function emptyFunction2(

tests/Integration/Fixtures/Basic.wrong.php.inc

-14
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,6 @@ but should be heredoc instead';
120120
];
121121
}
122122

123-
/**
124-
* Very well documented method.
125-
* It tests PhpdocAlignFixer, NoSuperfluousPhpdocTagsFixer and possibly other Phpdoc rules.
126-
* @param string $first
127-
* @throws \Exception
128-
* @param int|float $second Second parameter does have a comment, unlike the first one.
129-
* @param string|null $third Third parameter is optional and has a default value.
130-
* @return mixed There is also information about return type.
131-
*/
132-
public function veryWellDocumented(string $first, int|float $second, ?string $third = '3rd'): mixed
133-
{
134-
return $first . $third;
135-
}
136-
137123
public function emptyFunction1(): void {
138124
} // SingleLineEmptyBodyFixer
139125

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Lmc\CodingStandard\Integration\Fixtures;
4+
5+
class PhpDoc
6+
{
7+
// PhpdocToPropertyTypeFixer, PropertyTypeHintSniff
8+
private int $integerValue = 3;
9+
private $undefinedTypeValue = 3;
10+
private mixed $undeclaredMixedType;
11+
private \DateTimeImmutable $nonScalarType;
12+
13+
/**
14+
* Very well documented method.
15+
* It tests PhpdocAlignFixer, NoSuperfluousPhpdocTagsFixer and possibly other Phpdoc rules.
16+
* @param int|float $second Second parameter does have a comment, unlike the first one.
17+
* @param string|null $third Third parameter is optional and has a default value.
18+
* @return mixed There is also information about return type.
19+
* @throws \Exception
20+
*/
21+
public function veryWellDocumented(string $first, int|float $second, ?string $third = '3rd'): mixed
22+
{
23+
return $first . $third;
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Lmc\CodingStandard\Integration\Fixtures;
4+
5+
class PhpDoc
6+
{
7+
// PhpdocToPropertyTypeFixer, PropertyTypeHintSniff
8+
/** @var int */
9+
private $integerValue = 3;
10+
private $undefinedTypeValue = 3;
11+
/** @var mixed */
12+
private $undeclaredMixedType;
13+
/** @var \DateTimeImmutable */
14+
private $nonScalarType;
15+
16+
/**
17+
* Very well documented method.
18+
* It tests PhpdocAlignFixer, NoSuperfluousPhpdocTagsFixer and possibly other Phpdoc rules.
19+
* @param string $first
20+
* @throws \Exception
21+
* @param int|float $second Second parameter does have a comment, unlike the first one.
22+
* @param string|null $third Third parameter is optional and has a default value.
23+
* @return mixed There is also information about return type.
24+
*/
25+
public function veryWellDocumented(string $first, int|float $second, ?string $third = '3rd'): mixed
26+
{
27+
return $first . $third;
28+
}
29+
}

0 commit comments

Comments
 (0)