Skip to content

Commit

Permalink
Allow the return type checks to run with php 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey committed Jul 4, 2022
1 parent b45ab0f commit cefdefd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions psalm.xml.dist
Expand Up @@ -166,5 +166,12 @@
<directory name="vendor/nikic/php-parser" />
</errorLevel>
</MixedAssignment>

<UndefinedMethod>
<errorLevel type="suppress">
<referencedMethod name="ReflectionFunction::getTentativeReturnType"/>
<referencedMethod name="ReflectionFunction::hasTentativeReturnType"/>
</errorLevel>
</UndefinedMethod>
</issueHandlers>
</psalm>
7 changes: 6 additions & 1 deletion tests/Internal/Codebase/InternalCallMapHandlerTest.php
Expand Up @@ -765,7 +765,12 @@ private function assertParameter(array $normalizedEntry, ReflectionParameter $pa
*/
public function assertEntryReturnType(ReflectionFunction $function, string $entryReturnType): void
{
$expectedType = $function->hasTentativeReturnType() ? $function->getTentativeReturnType() : $function->getReturnType();
if (version_compare(PHP_VERSION, '8.1.0', '>=')) {
/** @var \ReflectionType|null $expectedType */
$expectedType = $function->hasTentativeReturnType() ? $function->getTentativeReturnType() : $function->getReturnType();
} else {
$expectedType = $function->getReturnType();
}
if ($expectedType === null) {
$this->assertSame('', $entryReturnType, 'CallMap entry has incorrect return type');
return;
Expand Down

0 comments on commit cefdefd

Please sign in to comment.