Skip to content

Commit d373e33

Browse files
tests improvements: make data provider methods static (#466)
1 parent 47e02e3 commit d373e33

File tree

4 files changed

+55
-55
lines changed

4 files changed

+55
-55
lines changed

tests/Unit/Analyzer/FileVisitorTest.php

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,88 +1374,88 @@ public function test_it_parse_enums(string $code): void
13741374
}
13751375
}
13761376

1377-
public function provide_enums(): \Generator
1377+
public static function provide_enums(): \Generator
13781378
{
13791379
yield 'default enum' => [
13801380
<<< 'EOF'
1381-
<?php
1382-
namespace App\Foo;
1381+
<?php
1382+
namespace App\Foo;
13831383
1384-
enum DefaultEnum
1385-
{
1386-
case FOO;
1387-
}
1388-
EOF
1384+
enum DefaultEnum
1385+
{
1386+
case FOO;
1387+
}
1388+
EOF
13891389
];
13901390

13911391
yield 'string enum' => [
13921392
<<< 'EOF'
1393-
<?php
1394-
namespace App\Foo;
1393+
<?php
1394+
namespace App\Foo;
13951395
1396-
enum StringEnum: string
1397-
{
1398-
case BAR: 'bar';
1399-
}
1400-
EOF
1396+
enum StringEnum: string
1397+
{
1398+
case BAR: 'bar';
1399+
}
1400+
EOF
14011401
];
14021402

14031403
yield 'integer enum' => [
14041404
<<< 'EOF'
1405-
<?php
1406-
namespace App\Foo;
1405+
<?php
1406+
namespace App\Foo;
14071407
1408-
enum IntEnum: int
1409-
{
1410-
case BAZ: 42;
1411-
}
1412-
EOF
1408+
enum IntEnum: int
1409+
{
1410+
case BAZ: 42;
1411+
}
1412+
EOF
14131413
];
14141414

14151415
yield 'multiple enums' => [
14161416
<<< 'EOF'
1417-
<?php
1418-
namespace App\Foo;
1417+
<?php
1418+
namespace App\Foo;
14191419
1420-
enum DefaultEnum
1421-
{
1422-
case FOO;
1423-
}
1420+
enum DefaultEnum
1421+
{
1422+
case FOO;
1423+
}
14241424
1425-
enum IntEnum: int
1426-
{
1427-
case BAZ: 42;
1428-
}
1425+
enum IntEnum: int
1426+
{
1427+
case BAZ: 42;
1428+
}
14291429
1430-
enum IntEnum: int
1431-
{
1432-
case BAZ: 42;
1433-
}
1434-
EOF
1430+
enum IntEnum: int
1431+
{
1432+
case BAZ: 42;
1433+
}
1434+
EOF
14351435
];
14361436
}
14371437

14381438
public function test_it_parse_property_hooks(): void
14391439
{
14401440
$code = <<< 'EOF'
1441-
<?php
1442-
namespace App\Foo;
1441+
<?php
1442+
namespace App\Foo;
14431443
1444-
class User {
1445-
private string $firstName;
1446-
private string $lastName;
1444+
class User {
1445+
private string $firstName;
1446+
private string $lastName;
14471447
1448-
public function __construct(string $firstName, string $lastName) {
1449-
$this->firstName = $firstName;
1450-
$this->lastName = $lastName;
1451-
}
1448+
public function __construct(string $firstName, string $lastName) {
1449+
$this->firstName = $firstName;
1450+
$this->lastName = $lastName;
1451+
}
14521452
1453-
public string $fullName {
1454-
get => $this->firstName . ' ' . $this->lastName;
1455-
set {[$this->firstName, $this->lastName] = explode(' ', $value, 2);}
1456-
}
1457-
}
1458-
EOF;
1453+
public string $fullName {
1454+
get => $this->firstName . ' ' . $this->lastName;
1455+
set {[$this->firstName, $this->lastName] = explode(' ', $value, 2);}
1456+
}
1457+
}
1458+
EOF;
14591459

14601460
/** @var FileParser $fp */
14611461
$fp = FileParserFactory::createFileParser(TargetPhpVersion::create('8.4'));

tests/Unit/Analyzer/FullyQualifiedClassNameTest.php

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

99
class FullyQualifiedClassNameTest extends TestCase
1010
{
11-
public function patternProvider(): array
11+
public static function patternProvider(): array
1212
{
1313
return [
1414
['Food\Vegetables\Fruits\Banana', 'Food\Vegetables\Fruits\Banana', true],

tests/Unit/Analyzer/PatternStringTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function test_wildcard_is_for_alphanumeric(string $string, string $patter
2323
$this->assertEquals($expectedResult, (new PatternString($string))->matches($pattern));
2424
}
2525

26-
public function providePatterns(): array
26+
public static function providePatterns(): array
2727
{
2828
return [
2929
['SoThisIsAnExample', '*This*', true],

tests/Unit/Expressions/ForClasses/ResideInOneOfTheseNamespacesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class ResideInOneOfTheseNamespacesTest extends TestCase
1313
{
14-
public function shouldMatchNamespacesProvider(): array
14+
public static function shouldMatchNamespacesProvider(): array
1515
{
1616
return [
1717
['Food\Vegetables', 'Food\Vegetables\Carrot', 'matches a class in the root namespace'],

0 commit comments

Comments
 (0)