1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Support mixed type natively

This commit is contained in:
Brown 2020-08-30 13:38:03 -04:00 committed by Daniil Gentili
parent 65c855a4d3
commit 36b1a21fcf
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 20 additions and 1 deletions

View File

@ -224,7 +224,11 @@ abstract class Atomic implements TypeNode
return $php_version !== null ? new TNamedObject($value) : new TNull();
case 'mixed':
return $php_version !== null ? new TNamedObject($value) : new TMixed();
if ($php_version === null || $php_version[0] >= 8) {
return new TMixed();
}
return new TNamedObject($value);
case 'callable-object':
return new TCallableObject();

View File

@ -865,6 +865,8 @@ class ReturnTypeTest extends TestCase
],
'returnStaticThis' => [
'<?php
namespace Foo;
class A {
public function getThis() : static {
return $this;
@ -877,6 +879,19 @@ class ReturnTypeTest extends TestCase
(new B)->getThis()->foo();',
],
'returnMixed' => [
'<?php
namespace Foo;
class A {
public function getThis() : mixed {
return $this;
}
}',
[],
[],
'8.0'
],
];
}