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:
parent
65c855a4d3
commit
36b1a21fcf
@ -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();
|
||||
|
@ -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'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user