Skip to content

Commit c05e3c0

Browse files
Update cdn77/coding-standard requirement from ^5.0 to ^6.0 (#27)
Updates the requirements on [cdn77/coding-standard](https://github.com/cdn77/coding-standard) to permit the latest version. - [Release notes](https://github.com/cdn77/coding-standard/releases) - [Commits](cdn77/coding-standard@v5.0.0...6.0.0) --- updated-dependencies: - dependency-name: cdn77/coding-standard dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Simon Podlipsky <simon@podlipsky.net> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Simon Podlipsky <simon@podlipsky.net>
1 parent 49714da commit c05e3c0

14 files changed

+44
-78
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"thecodingmachine/safe": "^1.0.2"
2222
},
2323
"require-dev": {
24-
"cdn77/coding-standard": "^5.0",
24+
"cdn77/coding-standard": "^6.0",
2525
"infection/infection": "^0.26.0",
2626
"phpstan/extension-installer": "^1.0",
2727
"phpstan/phpstan": "^1",

src/Stub.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class Stub
2222
*
2323
* @template T of object
2424
*/
25-
public static function create(string $class, array $properties = []) : object
25+
public static function create(string $class, array $properties = []): object
2626
{
2727
$reflection = new ReflectionClass($class);
2828

@@ -49,7 +49,7 @@ public static function create(string $class, array $properties = []) : object
4949
*
5050
* @template T of object
5151
*/
52-
public static function extend(object $stub, array $newProperties = []) : object
52+
public static function extend(object $stub, array $newProperties = []): object
5353
{
5454
// phpstan has problem with analyzing this still
5555
// phpcs:ignore SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall
@@ -77,7 +77,7 @@ public static function extend(object $stub, array $newProperties = []) : object
7777
*
7878
* @template T of object
7979
*/
80-
private static function getClosestProperty(ReflectionClass $class, string $property) : ?ReflectionProperty
80+
private static function getClosestProperty(ReflectionClass $class, string $property): ReflectionProperty|null
8181
{
8282
if ($class->hasProperty($property)) {
8383
return $class->getProperty($property);
@@ -103,7 +103,7 @@ private static function getClosestProperty(ReflectionClass $class, string $prope
103103
*
104104
* @template T of object
105105
*/
106-
private static function getAllProperties(ReflectionClass $reflection, array $properties = []) : array
106+
private static function getAllProperties(ReflectionClass $reflection, array $properties = []): array
107107
{
108108
$properties = array_merge($reflection->getProperties(), $properties);
109109

src/TestCheck/EveryTestHasGroup.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,15 @@
1313

1414
final class EveryTestHasGroup implements TestCheck
1515
{
16-
/** @var list<string> */
17-
private array $allowedGroups;
18-
19-
/** @var iterable<string> */
20-
private iterable $filePathNames;
21-
2216
/**
2317
* @param iterable<string> $filePathNames
2418
* @param list<string> $allowedGroups
2519
*/
26-
public function __construct(iterable $filePathNames, array $allowedGroups)
20+
public function __construct(private iterable $filePathNames, private array $allowedGroups)
2721
{
28-
$this->allowedGroups = $allowedGroups;
29-
$this->filePathNames = $filePathNames;
3022
}
3123

32-
public function run(TestCase $testCaseContext) : void
24+
public function run(TestCase $testCaseContext): void
3325
{
3426
foreach ($this->filePathNames as $filePathName) {
3527
$classReflection = new ReflectionClass(ClassExtractor::get($filePathName));
@@ -39,7 +31,7 @@ public function run(TestCase $testCaseContext) : void
3931
}
4032

4133
/** @param ReflectionClass<object> $reflectionClass */
42-
private function validateDocComment(TestCase $testCaseContext, ReflectionClass $reflectionClass) : void
34+
private function validateDocComment(TestCase $testCaseContext, ReflectionClass $reflectionClass): void
4335
{
4436
$docComment = $reflectionClass->getDocComment();
4537
if ($docComment === false) {

src/TestCheck/EveryTestHasSameNamespaceAsTestedClass.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,15 @@ final class EveryTestHasSameNamespaceAsTestedClass implements TestCheck
2121
{
2222
private const PATTERN = '~\* @testedClass (?<targetClass>.+?)(?:\n| \*/)~';
2323

24-
/** @var iterable<string> $filePathNames */
25-
private iterable $filePathNames;
26-
2724
private string $testsNamespaceSuffix;
2825

2926
/** @param iterable<string> $filePathNames */
30-
public function __construct(iterable $filePathNames, string $testsNamespaceSuffix = 'Tests')
27+
public function __construct(private iterable $filePathNames, string $testsNamespaceSuffix = 'Tests')
3128
{
32-
$this->filePathNames = $filePathNames;
3329
$this->testsNamespaceSuffix = '\\' . $testsNamespaceSuffix . '\\';
3430
}
3531

36-
public function run(TestCase $testCaseContext) : void
32+
public function run(TestCase $testCaseContext): void
3733
{
3834
$testCaseContext::assertTrue(true);
3935

src/TestCheck/EveryTestInheritsFromTestCaseBaseClass.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,15 @@
1212

1313
final class EveryTestInheritsFromTestCaseBaseClass implements TestCheck
1414
{
15-
/** @var iterable<string> $filePathNames */
16-
private iterable $filePathNames;
17-
18-
/** @var class-string<TestCase> */
19-
private string $testCaseBaseClass;
20-
2115
/**
2216
* @param iterable<string> $filePathNames
2317
* @param class-string<TestCase> $testCaseBaseClass
2418
*/
25-
public function __construct(iterable $filePathNames, string $testCaseBaseClass)
19+
public function __construct(private iterable $filePathNames, private string $testCaseBaseClass)
2620
{
27-
$this->filePathNames = $filePathNames;
28-
$this->testCaseBaseClass = $testCaseBaseClass;
2921
}
3022

31-
public function run(TestCase $testCaseContext) : void
23+
public function run(TestCase $testCaseContext): void
3224
{
3325
$testCaseContext::assertTrue(true);
3426

@@ -62,8 +54,8 @@ public function run(TestCase $testCaseContext) : void
6254
private function assertParentClass(
6355
TestCase $testCaseContext,
6456
ReflectionClass $classReflection,
65-
ReflectionClass $parentClassReflection
66-
) : void {
57+
ReflectionClass $parentClassReflection,
58+
): void {
6759
if ($parentClassReflection->getName() === $this->testCaseBaseClass) {
6860
return;
6961
}

src/TestCheck/EveryTestIsFinal.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,12 @@
1212

1313
final class EveryTestIsFinal implements TestCheck
1414
{
15-
/** @var iterable<string> $filePathNames */
16-
private iterable $filePathNames;
17-
1815
/** @param iterable<string> $filePathNames */
19-
public function __construct(iterable $filePathNames)
16+
public function __construct(private iterable $filePathNames)
2017
{
21-
$this->filePathNames = $filePathNames;
2218
}
2319

24-
public function run(TestCase $testCaseContext) : void
20+
public function run(TestCase $testCaseContext): void
2521
{
2622
foreach ($this->filePathNames as $filePathName) {
2723
$classReflection = new ReflectionClass(ClassExtractor::get($filePathName));

src/TestCheck/TestCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88

99
interface TestCheck
1010
{
11-
public function run(TestCase $testCaseContext) : void;
11+
public function run(TestCase $testCaseContext): void;
1212
}

tests/SimpleClass.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,24 @@
66

77
final class SimpleClass extends SimpleParentClass
88
{
9-
private string $property1;
10-
11-
private string $property2;
12-
139
private string $propertyWithDefaultValue = 'default value';
1410

15-
public function __construct(string $property1, string $property2, string $property3)
11+
public function __construct(private string $property1, private string $property2, string $property3)
1612
{
17-
$this->property1 = $property1;
18-
$this->property2 = $property2;
19-
2013
parent::__construct($property3);
2114
}
2215

23-
public function getProperty1() : string
16+
public function getProperty1(): string
2417
{
2518
return $this->property1;
2619
}
2720

28-
public function getProperty2() : string
21+
public function getProperty2(): string
2922
{
3023
return $this->property2;
3124
}
3225

33-
public function getPropertyWithDefaultValue() : string
26+
public function getPropertyWithDefaultValue(): string
3427
{
3528
return $this->propertyWithDefaultValue;
3629
}

tests/SimpleParentClass.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66

77
class SimpleParentClass
88
{
9-
private string $parentProperty;
10-
11-
public function __construct(string $parentProperty)
9+
public function __construct(private string $parentProperty)
1210
{
13-
$this->parentProperty = $parentProperty;
1411
}
1512

16-
public function getParentProperty() : string
13+
public function getParentProperty(): string
1714
{
1815
return $this->parentProperty;
1916
}

tests/StubTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
final class StubTest extends BaseTestCase
1212
{
13-
public function testValueIsDefaultWhenNotSet() : void
13+
public function testValueIsDefaultWhenNotSet(): void
1414
{
1515
$this->expectException(Error::class);
1616
$this->expectExceptionMessage('must not be accessed before initialization');
@@ -20,29 +20,29 @@ public function testValueIsDefaultWhenNotSet() : void
2020
$stub->getProperty1();
2121
}
2222

23-
public function testPropertyIsSetBypassingConstructor() : void
23+
public function testPropertyIsSetBypassingConstructor(): void
2424
{
2525
$stub = Stub::create(SimpleClass::class, ['property1' => 'value']);
2626

2727
self::assertSame('value', $stub->getProperty1());
2828
}
2929

30-
public function testParentPropertyIsSetBypassingConstructor() : void
30+
public function testParentPropertyIsSetBypassingConstructor(): void
3131
{
3232
$stub = Stub::create(SimpleClass::class, ['parentProperty' => 'value']);
3333

3434
self::assertSame('value', $stub->getParentProperty());
3535
}
3636

37-
public function testSettingNonexistentPropertyThrowsException() : void
37+
public function testSettingNonexistentPropertyThrowsException(): void
3838
{
3939
$this->expectException(ReflectionException::class);
4040
$this->expectExceptionMessage('Property "nonexistentProperty" not found');
4141

4242
Stub::create(SimpleClass::class, ['nonexistentProperty' => 'value']);
4343
}
4444

45-
public function testExtend() : void
45+
public function testExtend(): void
4646
{
4747
$stub = Stub::create(SimpleClass::class, ['property1' => 'value']);
4848

0 commit comments

Comments
 (0)