Skip to content

Commit

Permalink
Fix PHP7.4 deprecation errors, related to #102
Browse files Browse the repository at this point in the history
  • Loading branch information
lisachenko committed Aug 13, 2020
1 parent 98700fb commit d4257ee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testCoverAllMethods()
}

if ($allMissedMethods) {
$this->markTestIncomplete('Methods ' . join($allMissedMethods, ', ') . ' are not implemented');
$this->markTestIncomplete('Methods ' . join(', ', $allMissedMethods) . ' are not implemented');
}
}

Expand Down
7 changes: 6 additions & 1 deletion tests/ReflectionFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ public function testGetReturnTypeMethod()
$originalReturnType = $originalRefFunction->getReturnType();
$this->assertSame($originalReturnType->allowsNull(), $parsedReturnType->allowsNull());
$this->assertSame($originalReturnType->isBuiltin(), $parsedReturnType->isBuiltin());
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString());
// TODO: To prevent deprecation error in tests
if (PHP_VERSION_ID < 70400) {
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString());
} else {
$this->assertSame($originalReturnType->getName(), $parsedReturnType->__toString());
}
} else {
$this->assertSame(
$originalRefFunction->getReturnType(),
Expand Down
7 changes: 6 additions & 1 deletion tests/ReflectionParameterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ public function testGetTypeMethod()
$originalReturnType = $originalRefParameter->getType();
$this->assertSame($originalReturnType->allowsNull(), $parsedReturnType->allowsNull(), $message);
$this->assertSame($originalReturnType->isBuiltin(), $parsedReturnType->isBuiltin(), $message);
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString(), $message);
// TODO: To prevent deprecation error in tests
if (PHP_VERSION_ID < 70400) {
$this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString(), $message);
} else {
$this->assertSame($originalReturnType->getName(), $parsedReturnType->__toString(), $message);
}
} else {
$this->assertSame(
$originalRefParameter->getType(),
Expand Down
21 changes: 18 additions & 3 deletions tests/ReflectionTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public function testTypeConvertToDisplayTypeWithNativeType()
$this->assertCount(2, $nativeParamRefArr);
$this->assertEquals(\ReflectionParameter::class, get_class($nativeParamRefArr[0]));
$nativeTypeRef = $nativeParamRefArr[0]->getType();
$this->assertEquals('string', (string)$nativeTypeRef);
// TODO: To prevent deprecation error in tests
if (PHP_VERSION_ID < 70400) {
$this->assertEquals('string', (string)$nativeTypeRef);
} else {
$this->assertEquals('string', $nativeTypeRef->getName());
}
$this->assertNotContains('\\', get_class($nativeTypeRef));
$this->assertInstanceOf(\ReflectionType::class, $nativeTypeRef);
$this->assertEquals('string', \Go\ParserReflection\ReflectionType::convertToDisplayType($nativeTypeRef));
Expand All @@ -49,7 +54,12 @@ public function testTypeConvertToDisplayTypeWithNullableNativeType()
$this->assertCount(2, $nativeParamRefArr);
$this->assertEquals(\ReflectionParameter::class, get_class($nativeParamRefArr[0]));
$nativeTypeRef = $nativeParamRefArr[0]->getType();
$this->assertEquals('string', (string)$nativeTypeRef);
// TODO: To prevent deprecation error in tests
if (PHP_VERSION_ID < 70400) {
$this->assertEquals('string', (string)$nativeTypeRef);
} else {
$this->assertEquals('string', $nativeTypeRef->getName());
}
$this->assertNotContains('\\', get_class($nativeTypeRef));
$this->assertInstanceOf(\ReflectionType::class, $nativeTypeRef);
$this->assertEquals('string or NULL', \Go\ParserReflection\ReflectionType::convertToDisplayType($nativeTypeRef));
Expand All @@ -71,7 +81,12 @@ public function testTypeConvertToDisplayTypeImplicitlyNullable()
$this->assertEquals(\ReflectionParameter::class, get_class($nativeParamRefArr[0]));
$nativeTypeRef = $nativeParamRefArr[0]->getType();
$this->assertTrue($nativeTypeRef->allowsNull());
$this->assertEquals('string', (string)$nativeTypeRef);
// TODO: To prevent deprecation error in tests
if (PHP_VERSION_ID < 70400) {
$this->assertEquals('string', (string)$nativeTypeRef);
} else {
$this->assertEquals('string', $nativeTypeRef->getName());
}
$this->assertNotContains('\\', get_class($nativeTypeRef));
$this->assertInstanceOf(\ReflectionType::class, $nativeTypeRef);
$this->assertEquals('string or NULL', \Go\ParserReflection\ReflectionType::convertToDisplayType($nativeTypeRef));
Expand Down

0 comments on commit d4257ee

Please sign in to comment.