Skip to content

Commit 1e3ea64

Browse files
committed
chore: fix phpstan and phpcs errors
1 parent 26c929d commit 1e3ea64

File tree

5 files changed

+152
-84
lines changed

5 files changed

+152
-84
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: phpstan
3636

3737
- name: Run PHPCS
38-
run: phpcs --standard=PSR12 src
38+
run: phpcs --standard=PSR12 src tests
3939

4040
- name: Run test suite
4141
run: php vendor/bin/codecept run

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"require": {
2626
"php": "^8.2",
2727
"codeception/codeception": "*@dev",
28-
"phpunit/phpunit": "^11.5 | ^12"
28+
"phpunit/phpunit": "^11.5 | ^12",
29+
"ext-dom": "*"
2930
},
3031
"conflict": {
3132
"codeception/codeception": "<5.0"

src/Codeception/Util/Shared/InheritedAsserts.php

Lines changed: 116 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ protected function assertClassHasAttribute(string $attributeName, string $classN
4646
* Asserts that a class has a specified static attribute.
4747
* @param class-string $className
4848
*/
49-
protected function assertClassHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
50-
{
49+
protected function assertClassHasStaticAttribute(
50+
string $attributeName,
51+
string $className,
52+
string $message = ''
53+
): void {
5154
trigger_error(__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10', E_USER_DEPRECATED);
5255

5356
Assert::assertTrue(self::hasStaticAttribute($attributeName, $className), $message);
@@ -67,8 +70,11 @@ protected function assertClassNotHasAttribute(string $attributeName, string $cla
6770
* Asserts that a class does not have a specified static attribute.
6871
* @param class-string $className
6972
*/
70-
protected function assertClassNotHasStaticAttribute(string $attributeName, string $className, string $message = ''): void
71-
{
73+
protected function assertClassNotHasStaticAttribute(
74+
string $attributeName,
75+
string $className,
76+
string $message = ''
77+
): void {
7278
trigger_error(__FUNCTION__ . ' was removed from PHPUnit since PHPUnit 10', E_USER_DEPRECATED);
7379
Assert::assertFalse(self::hasStaticAttribute($attributeName, $className), $message);
7480
}
@@ -93,11 +99,16 @@ protected function assertContainsEquals(mixed $needle, iterable $haystack, strin
9399

94100
/**
95101
* Asserts that a haystack contains only values of a given type.
96-
* @param 'array'|'bool'|'boolean'|'callable'|'double'|'float'|'int'|'integer'|'iterable'|'null'|'numeric'|'object'|'real'|'resource'|'resource (closed)'|'scalar'|'string'|class-string $type
102+
* @param 'array'|'bool'|'boolean'|'callable'|'double'|'float'|'int'|'integer'|'iterable'
103+
* |'null'|'numeric'|'object'|'real'|'resource'|'resource (closed)'|'scalar'|'string'|class-string $type
97104
* @param iterable<mixed> $haystack
98105
*/
99-
protected function assertContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
100-
{
106+
protected function assertContainsOnly(
107+
string $type,
108+
iterable $haystack,
109+
?bool $isNativeType = null,
110+
string $message = ''
111+
): void {
101112
/** @phpstan-ignore-next-line */
102113
Assert::assertContainsOnly($type, $haystack, $isNativeType, $message);
103114
}
@@ -729,48 +740,65 @@ protected function assertJson(string $actualJson, string $message = ''): void
729740
/**
730741
* Asserts that two JSON files are equal.
731742
*/
732-
protected function assertJsonFileEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
733-
{
743+
protected function assertJsonFileEqualsJsonFile(
744+
string $expectedFile,
745+
string $actualFile,
746+
string $message = ''
747+
): void {
734748
Assert::assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message);
735749
}
736-
737750
/**
738751
* Asserts that two JSON files are not equal.
739752
*/
740-
protected function assertJsonFileNotEqualsJsonFile(string $expectedFile, string $actualFile, string $message = ''): void
741-
{
753+
protected function assertJsonFileNotEqualsJsonFile(
754+
string $expectedFile,
755+
string $actualFile,
756+
string $message = ''
757+
): void {
742758
Assert::assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message);
743759
}
744760

745761
/**
746762
* Asserts that the generated JSON encoded object and the content of the given file are equal.
747763
*/
748-
protected function assertJsonStringEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
749-
{
764+
protected function assertJsonStringEqualsJsonFile(
765+
string $expectedFile,
766+
string $actualJson,
767+
string $message = ''
768+
): void {
750769
Assert::assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message);
751770
}
752771

753772
/**
754773
* Asserts that two given JSON encoded objects or arrays are equal.
755774
*/
756-
protected function assertJsonStringEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
757-
{
775+
protected function assertJsonStringEqualsJsonString(
776+
string $expectedJson,
777+
string $actualJson,
778+
string $message = ''
779+
): void {
758780
Assert::assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message);
759781
}
760782

761783
/**
762784
* Asserts that the generated JSON encoded object and the content of the given file are not equal.
763785
*/
764-
protected function assertJsonStringNotEqualsJsonFile(string $expectedFile, string $actualJson, string $message = ''): void
765-
{
786+
protected function assertJsonStringNotEqualsJsonFile(
787+
string $expectedFile,
788+
string $actualJson,
789+
string $message = ''
790+
): void {
766791
Assert::assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message);
767792
}
768793

769794
/**
770795
* Asserts that two given JSON encoded objects or arrays are not equal.
771796
*/
772-
protected function assertJsonStringNotEqualsJsonString(string $expectedJson, string $actualJson, string $message = ''): void
773-
{
797+
protected function assertJsonStringNotEqualsJsonString(
798+
string $expectedJson,
799+
string $actualJson,
800+
string $message = ''
801+
): void {
774802
Assert::assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message);
775803
}
776804

@@ -826,11 +854,16 @@ protected function assertNotContains(mixed $needle, iterable $haystack, string $
826854

827855
/**
828856
* Asserts that a haystack does not contain only values of a given type.
829-
* @param 'array'|'bool'|'boolean'|'callable'|'double'|'float'|'int'|'integer'|'iterable'|'null'|'numeric'|'object'|'real'|'resource'|'resource (closed)'|'scalar'|'string'|class-string $type
857+
* @param 'array'|'bool'|'boolean'|'callable'|'double'|'float'|'int'|'integer'|'iterable'|'null'
858+
* |'numeric'|'object'|'real'|'resource'|'resource (closed)'|'scalar'|'string'|class-string $type
830859
* @param iterable<mixed> $haystack
831860
*/
832-
protected function assertNotContainsOnly(string $type, iterable $haystack, ?bool $isNativeType = null, string $message = ''): void
833-
{
861+
protected function assertNotContainsOnly(
862+
string $type,
863+
iterable $haystack,
864+
?bool $isNativeType = null,
865+
string $message = ''
866+
): void {
834867
/** @phpstan-ignore-next-line */
835868
Assert::assertNotContainsOnly($type, $haystack, $isNativeType, $message);
836869
}
@@ -957,8 +990,11 @@ protected function assertNotSame($expected, $actual, string $message = ''): void
957990
* @param \Countable|iterable<mixed> $expected
958991
* @param \Countable|iterable<mixed> $actual
959992
*/
960-
protected function assertNotSameSize(\Countable|iterable $expected, \Countable|iterable $actual, string $message = ''): void
961-
{
993+
protected function assertNotSameSize(
994+
\Countable|iterable $expected,
995+
\Countable|iterable $actual,
996+
string $message = ''
997+
): void {
962998
Assert::assertNotSameSize($expected, $actual, $message);
963999
}
9641000

@@ -1035,8 +1071,11 @@ protected function assertSame(mixed $expected, mixed $actual, string $message =
10351071
* @param \Countable|iterable<mixed> $expected
10361072
* @param \Countable|iterable<mixed> $actual
10371073
*/
1038-
protected function assertSameSize(\Countable|iterable $expected, \Countable|iterable $actual, string $message = ''): void
1039-
{
1074+
protected function assertSameSize(
1075+
\Countable|iterable $expected,
1076+
\Countable|iterable $actual,
1077+
string $message = ''
1078+
): void {
10401079
Assert::assertSameSize($expected, $actual, $message);
10411080
}
10421081

@@ -1045,8 +1084,11 @@ protected function assertStringContainsString(string $needle, string $haystack,
10451084
Assert::assertStringContainsString($needle, $haystack, $message);
10461085
}
10471086

1048-
protected function assertStringContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
1049-
{
1087+
protected function assertStringContainsStringIgnoringCase(
1088+
string $needle,
1089+
string $haystack,
1090+
string $message = ''
1091+
): void {
10501092
Assert::assertStringContainsStringIgnoringCase($needle, $haystack, $message);
10511093
}
10521094

@@ -1079,25 +1121,31 @@ protected function assertStringEqualsFile(string $expectedFile, string $actualSt
10791121
/**
10801122
* Asserts that the contents of a string is equal to the contents of a file (canonicalizing).
10811123
*/
1082-
protected function assertStringEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
1083-
{
1124+
protected function assertStringEqualsFileCanonicalizing(
1125+
string $expectedFile,
1126+
string $actualString,
1127+
string $message = ''
1128+
): void {
10841129
Assert::assertStringEqualsFileCanonicalizing($expectedFile, $actualString, $message);
10851130
}
10861131

10871132
/**
1088-
* Asserts that the contents of a string is equal to the contents of a file (ignoring case).
1133+
* Asserts that a string matches a given format string.
10891134
*/
1090-
protected function assertStringEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
1135+
protected function assertStringMatchesFormat(string $format, string $string, string $message = ''): void
10911136
{
1092-
Assert::assertStringEqualsFileIgnoringCase($expectedFile, $actualString, $message);
1137+
Assert::assertStringMatchesFormat($format, $string, $message);
10931138
}
10941139

10951140
/**
1096-
* Asserts that a string matches a given format string.
1141+
* Asserts that the contents of a string is equal to the contents of a file (ignoring case).
10971142
*/
1098-
protected function assertStringMatchesFormat(string $format, string $string, string $message = ''): void
1099-
{
1100-
Assert::assertStringMatchesFormat($format, $string, $message);
1143+
protected function assertStringEqualsFileIgnoringCase(
1144+
string $expectedFile,
1145+
string $actualString,
1146+
string $message = ''
1147+
): void {
1148+
Assert::assertStringEqualsFileIgnoringCase($expectedFile, $actualString, $message);
11011149
}
11021150

11031151
/**
@@ -1113,8 +1161,11 @@ protected function assertStringNotContainsString(string $needle, string $haystac
11131161
Assert::assertStringNotContainsString($needle, $haystack, $message);
11141162
}
11151163

1116-
protected function assertStringNotContainsStringIgnoringCase(string $needle, string $haystack, string $message = ''): void
1117-
{
1164+
protected function assertStringNotContainsStringIgnoringCase(
1165+
string $needle,
1166+
string $haystack,
1167+
string $message = ''
1168+
): void {
11181169
Assert::assertStringNotContainsStringIgnoringCase($needle, $haystack, $message);
11191170
}
11201171

@@ -1129,16 +1180,22 @@ protected function assertStringNotEqualsFile(string $expectedFile, string $actua
11291180
/**
11301181
* Asserts that the contents of a string is not equal to the contents of a file (canonicalizing).
11311182
*/
1132-
protected function assertStringNotEqualsFileCanonicalizing(string $expectedFile, string $actualString, string $message = ''): void
1133-
{
1183+
protected function assertStringNotEqualsFileCanonicalizing(
1184+
string $expectedFile,
1185+
string $actualString,
1186+
string $message = ''
1187+
): void {
11341188
Assert::assertStringNotEqualsFileCanonicalizing($expectedFile, $actualString, $message);
11351189
}
11361190

11371191
/**
11381192
* Asserts that the contents of a string is not equal to the contents of a file (ignoring case).
11391193
*/
1140-
protected function assertStringNotEqualsFileIgnoringCase(string $expectedFile, string $actualString, string $message = ''): void
1141-
{
1194+
protected function assertStringNotEqualsFileIgnoringCase(
1195+
string $expectedFile,
1196+
string $actualString,
1197+
string $message = ''
1198+
): void {
11421199
Assert::assertStringNotEqualsFileIgnoringCase($expectedFile, $actualString, $message);
11431200
}
11441201

@@ -1217,16 +1274,22 @@ protected function assertXmlFileEqualsXmlFile(string $expectedFile, string $actu
12171274
/**
12181275
* Asserts that two XML files are not equal.
12191276
*/
1220-
protected function assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile, string $message = ''): void
1221-
{
1277+
protected function assertXmlFileNotEqualsXmlFile(
1278+
string $expectedFile,
1279+
string $actualFile,
1280+
string $message = ''
1281+
): void {
12221282
Assert::assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message);
12231283
}
12241284

12251285
/**
12261286
* Asserts that two XML documents are equal.
12271287
*/
1228-
protected function assertXmlStringEqualsXmlFile(string $expectedFile, \DOMDocument|string $actualXml, string $message = ''): void
1229-
{
1288+
protected function assertXmlStringEqualsXmlFile(
1289+
string $expectedFile,
1290+
\DOMDocument|string $actualXml,
1291+
string $message = ''
1292+
): void {
12301293
if ($actualXml instanceof \DOMDocument) {
12311294
$actualXml = $actualXml->saveXML();
12321295
if ($actualXml === false) {
@@ -1239,8 +1302,11 @@ protected function assertXmlStringEqualsXmlFile(string $expectedFile, \DOMDocume
12391302
/**
12401303
* Asserts that two XML documents are equal.
12411304
*/
1242-
protected function assertXmlStringEqualsXmlString(\DOMDocument|string $expectedXml, \DOMDocument|string $actualXml, string $message = ''): void
1243-
{
1305+
protected function assertXmlStringEqualsXmlString(
1306+
\DOMDocument|string $expectedXml,
1307+
\DOMDocument|string $actualXml,
1308+
string $message = ''
1309+
): void {
12441310
if ($actualXml instanceof \DOMDocument) {
12451311
$actualXml = $actualXml->saveXML();
12461312
if ($actualXml === false) {

tests/Support/Data/DummyClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ class DummyClass
1515
* @phpstan-ignore-next-line
1616
*/
1717
private static int $staticFoo;
18-
}
18+
}

0 commit comments

Comments
 (0)