mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Enforce class-string in is_subclass_of()
This commit is contained in:
parent
e5b797c764
commit
621c4dd8d1
@ -6538,7 +6538,7 @@ return [
|
||||
'is_scalar' => ['bool', 'value'=>'mixed'],
|
||||
'is_soap_fault' => ['bool', 'object'=>'mixed'],
|
||||
'is_string' => ['bool', 'value'=>'mixed'],
|
||||
'is_subclass_of' => ['bool', 'object_or_class'=>'object|string', 'class'=>'string', 'allow_string='=>'bool'],
|
||||
'is_subclass_of' => ['bool', 'object_or_class'=>'object|string', 'class'=>'class-string', 'allow_string='=>'bool'],
|
||||
'is_tainted' => ['bool', 'string'=>'string'],
|
||||
'is_uploaded_file' => ['bool', 'filename'=>'string'],
|
||||
'is_writable' => ['bool', 'filename'=>'string'],
|
||||
|
@ -12294,7 +12294,7 @@ return [
|
||||
'is_scalar' => ['bool', 'value'=>'mixed'],
|
||||
'is_soap_fault' => ['bool', 'object'=>'mixed'],
|
||||
'is_string' => ['bool', 'value'=>'mixed'],
|
||||
'is_subclass_of' => ['bool', 'object_or_class'=>'object|string', 'class'=>'string', 'allow_string='=>'bool'],
|
||||
'is_subclass_of' => ['bool', 'object_or_class'=>'object|string', 'class'=>'class-string', 'allow_string='=>'bool'],
|
||||
'is_tainted' => ['bool', 'string'=>'string'],
|
||||
'is_uploaded_file' => ['bool', 'filename'=>'string'],
|
||||
'is_writable' => ['bool', 'filename'=>'string'],
|
||||
|
@ -387,25 +387,6 @@ class ClassLikeStringTest extends TestCase
|
||||
return $s;
|
||||
}',
|
||||
],
|
||||
'createClassOfTypeFromStringUsingIsSubclassOfString' => [
|
||||
'<?php
|
||||
class A {}
|
||||
|
||||
/**
|
||||
* @return class-string<A> $s
|
||||
*/
|
||||
function foo(string $s) : string {
|
||||
if (!class_exists($s)) {
|
||||
throw new \UnexpectedValueException("bad");
|
||||
}
|
||||
|
||||
if (!is_subclass_of($s, "\A")) {
|
||||
throw new \UnexpectedValueException("bad");
|
||||
}
|
||||
|
||||
return $s;
|
||||
}',
|
||||
],
|
||||
'checkSubclassOfAbstract' => [
|
||||
'<?php
|
||||
interface Foo {
|
||||
|
Loading…
Reference in New Issue
Block a user