mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix get_class-inferred templating
This commit is contained in:
parent
6ab3e732fb
commit
59e7f69d7b
@ -829,6 +829,8 @@ class UnionTemplateHandler
|
||||
} else {
|
||||
$valid_input_atomic_types[] = new Atomic\TObject();
|
||||
}
|
||||
} elseif ($input_atomic_type instanceof Atomic\GetClassT) {
|
||||
$valid_input_atomic_types[] = new Atomic\TObject();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -791,6 +791,26 @@ class FunctionClassStringTemplateTest extends TestCase
|
||||
f(C::class);',
|
||||
'error_message' => 'InvalidArgument',
|
||||
],
|
||||
'bindToClassString' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template TClass as object
|
||||
*
|
||||
* @param class-string<TClass> $className
|
||||
* @param TClass $realInstance
|
||||
*
|
||||
* @return Closure(TClass) : void
|
||||
* @psalm-suppress InvalidReturnType
|
||||
*/
|
||||
function createInitializer(string $className, object $realInstance) : Closure {}
|
||||
|
||||
function foo(object $realInstance) : void {
|
||||
$className = get_class($realInstance);
|
||||
/** @psalm-trace $i */
|
||||
$i = createInitializer($className, $realInstance);
|
||||
}',
|
||||
'error_message' => 'Trace - src/somefile.php:16:25 - $i: Closure(object):void'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user