Skip to content

Commit d4257ee

Browse files
committed
Fix PHP7.4 deprecation errors, related to #102
1 parent 98700fb commit d4257ee

4 files changed

+31
-6
lines changed

tests/AbstractTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testCoverAllMethods()
5656
}
5757

5858
if ($allMissedMethods) {
59-
$this->markTestIncomplete('Methods ' . join($allMissedMethods, ', ') . ' are not implemented');
59+
$this->markTestIncomplete('Methods ' . join(', ', $allMissedMethods) . ' are not implemented');
6060
}
6161
}
6262

tests/ReflectionFunctionTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,12 @@ public function testGetReturnTypeMethod()
125125
$originalReturnType = $originalRefFunction->getReturnType();
126126
$this->assertSame($originalReturnType->allowsNull(), $parsedReturnType->allowsNull());
127127
$this->assertSame($originalReturnType->isBuiltin(), $parsedReturnType->isBuiltin());
128-
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString());
128+
// TODO: To prevent deprecation error in tests
129+
if (PHP_VERSION_ID < 70400) {
130+
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString());
131+
} else {
132+
$this->assertSame($originalReturnType->getName(), $parsedReturnType->__toString());
133+
}
129134
} else {
130135
$this->assertSame(
131136
$originalRefFunction->getReturnType(),

tests/ReflectionParameterTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,12 @@ public function testGetTypeMethod()
279279
$originalReturnType = $originalRefParameter->getType();
280280
$this->assertSame($originalReturnType->allowsNull(), $parsedReturnType->allowsNull(), $message);
281281
$this->assertSame($originalReturnType->isBuiltin(), $parsedReturnType->isBuiltin(), $message);
282-
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString(), $message);
282+
// TODO: To prevent deprecation error in tests
283+
if (PHP_VERSION_ID < 70400) {
284+
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString(), $message);
285+
} else {
286+
$this->assertSame($originalReturnType->getName(), $parsedReturnType->__toString(), $message);
287+
}
283288
} else {
284289
$this->assertSame(
285290
$originalRefParameter->getType(),

tests/ReflectionTypeTest.php

+18-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ public function testTypeConvertToDisplayTypeWithNativeType()
2828
$this->assertCount(2, $nativeParamRefArr);
2929
$this->assertEquals(\ReflectionParameter::class, get_class($nativeParamRefArr[0]));
3030
$nativeTypeRef = $nativeParamRefArr[0]->getType();
31-
$this->assertEquals('string', (string)$nativeTypeRef);
31+
// TODO: To prevent deprecation error in tests
32+
if (PHP_VERSION_ID < 70400) {
33+
$this->assertEquals('string', (string)$nativeTypeRef);
34+
} else {
35+
$this->assertEquals('string', $nativeTypeRef->getName());
36+
}
3237
$this->assertNotContains('\\', get_class($nativeTypeRef));
3338
$this->assertInstanceOf(\ReflectionType::class, $nativeTypeRef);
3439
$this->assertEquals('string', \Go\ParserReflection\ReflectionType::convertToDisplayType($nativeTypeRef));
@@ -49,7 +54,12 @@ public function testTypeConvertToDisplayTypeWithNullableNativeType()
4954
$this->assertCount(2, $nativeParamRefArr);
5055
$this->assertEquals(\ReflectionParameter::class, get_class($nativeParamRefArr[0]));
5156
$nativeTypeRef = $nativeParamRefArr[0]->getType();
52-
$this->assertEquals('string', (string)$nativeTypeRef);
57+
// TODO: To prevent deprecation error in tests
58+
if (PHP_VERSION_ID < 70400) {
59+
$this->assertEquals('string', (string)$nativeTypeRef);
60+
} else {
61+
$this->assertEquals('string', $nativeTypeRef->getName());
62+
}
5363
$this->assertNotContains('\\', get_class($nativeTypeRef));
5464
$this->assertInstanceOf(\ReflectionType::class, $nativeTypeRef);
5565
$this->assertEquals('string or NULL', \Go\ParserReflection\ReflectionType::convertToDisplayType($nativeTypeRef));
@@ -71,7 +81,12 @@ public function testTypeConvertToDisplayTypeImplicitlyNullable()
7181
$this->assertEquals(\ReflectionParameter::class, get_class($nativeParamRefArr[0]));
7282
$nativeTypeRef = $nativeParamRefArr[0]->getType();
7383
$this->assertTrue($nativeTypeRef->allowsNull());
74-
$this->assertEquals('string', (string)$nativeTypeRef);
84+
// TODO: To prevent deprecation error in tests
85+
if (PHP_VERSION_ID < 70400) {
86+
$this->assertEquals('string', (string)$nativeTypeRef);
87+
} else {
88+
$this->assertEquals('string', $nativeTypeRef->getName());
89+
}
7590
$this->assertNotContains('\\', get_class($nativeTypeRef));
7691
$this->assertInstanceOf(\ReflectionType::class, $nativeTypeRef);
7792
$this->assertEquals('string or NULL', \Go\ParserReflection\ReflectionType::convertToDisplayType($nativeTypeRef));

0 commit comments

Comments
 (0)