mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix null ref
This commit is contained in:
parent
44b51cdf8e
commit
e28bf1a29b
@ -577,9 +577,9 @@ class CommentAnalyzer
|
||||
|| isset($comments['specials']['extends'])
|
||||
) {
|
||||
$all_inheritance = array_merge(
|
||||
$comments['specials']['template-extends'] ?: [],
|
||||
$comments['specials']['inherits'] ?: [],
|
||||
$comments['specials']['extends'] ?: []
|
||||
$comments['specials']['template-extends'] ?? [],
|
||||
$comments['specials']['inherits'] ?? [],
|
||||
$comments['specials']['extends'] ?? []
|
||||
);
|
||||
|
||||
foreach ($all_inheritance as $template_line) {
|
||||
|
@ -1627,6 +1627,56 @@ class TemplateTest extends TestCase
|
||||
'$f2' => 'Foo',
|
||||
]
|
||||
],
|
||||
'supportBareExtends' => [
|
||||
'<?php
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
abstract class Container
|
||||
{
|
||||
/**
|
||||
* @return T
|
||||
*/
|
||||
public abstract function getItem();
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @extends Container<Foo>
|
||||
*/
|
||||
class FooContainer extends Container
|
||||
{
|
||||
/**
|
||||
* @return Foo
|
||||
*/
|
||||
public function getItem()
|
||||
{
|
||||
return new Foo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template TItem
|
||||
* @param Container<TItem> $c
|
||||
* @return TItem
|
||||
*/
|
||||
function getItemFromContainer(Container $c) {
|
||||
return $c->getItem();
|
||||
}
|
||||
|
||||
$fc = new FooContainer();
|
||||
|
||||
$f1 = $fc->getItem();
|
||||
$f2 = getItemFromContainer($fc);',
|
||||
[
|
||||
'$fc' => 'FooContainer',
|
||||
'$f1' => 'Foo',
|
||||
'$f2' => 'Foo',
|
||||
]
|
||||
],
|
||||
'allowExtendingParameterisedTypeParam' => [
|
||||
'<?php
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user