mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #2785 - parse wildcards in variables better
This commit is contained in:
parent
89a0b101e4
commit
41af71556d
@ -186,7 +186,7 @@ class DocComment
|
||||
$docblock = trim($docblock);
|
||||
|
||||
$docblock = preg_replace('@^/\*\*@', '', $docblock);
|
||||
$docblock = preg_replace('@\*/$@', '', $docblock);
|
||||
$docblock = preg_replace('@\*\*?/$@', '', $docblock);
|
||||
|
||||
// Normalize multi-line @specials.
|
||||
$lines = explode("\n", $docblock);
|
||||
@ -219,7 +219,7 @@ class DocComment
|
||||
list($data, $data_offset) = $data_info;
|
||||
|
||||
if (strpos($data, '*')) {
|
||||
$data = rtrim(preg_replace('/[ \t]*\*\s*$/', '', $data));
|
||||
$data = rtrim(preg_replace('/^[ \t]*\*\s*$/', '', $data));
|
||||
}
|
||||
|
||||
$docblock = str_replace($full_match, '', $docblock);
|
||||
|
@ -551,7 +551,7 @@ class ParseTree
|
||||
&& strtolower($nexter_token[0]) !== 'class')
|
||||
) {
|
||||
throw new TypeParseTreeException(
|
||||
'Invalid class constant'
|
||||
'Invalid class constant ' . ($nexter_token[0] ?? '<empty>')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,7 @@ class ConstantTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'keyOf' => [
|
||||
'keyOf' => [
|
||||
'<?php
|
||||
class A {
|
||||
const C = [
|
||||
@ -658,6 +658,34 @@ class ConstantTest extends TestCase
|
||||
A::foo(3);
|
||||
A::foo(A::D_4);',
|
||||
],
|
||||
'wildcardVarAndReturn' => [
|
||||
'<?php
|
||||
class Numbers {
|
||||
public const ONE = 1;
|
||||
public const TWO = 2;
|
||||
}
|
||||
|
||||
class Number {
|
||||
/**
|
||||
* @var Numbers::*
|
||||
*/
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @param Numbers::* $number
|
||||
*/
|
||||
public function __construct($number) {
|
||||
$this->number = $number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Numbers::*
|
||||
*/
|
||||
public function get(): int {
|
||||
return $this->number;
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user