1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Strip text from end of @psalm-type

This commit is contained in:
Matthew Brown 2019-06-16 12:39:07 -04:00
parent a553adb232
commit f46ccf0a5d
2 changed files with 62 additions and 37 deletions

View File

@ -135,7 +135,7 @@ class ConstFetchAnalyzer
false,
true
) === false) {
return false;
return;
}
}
}
@ -183,7 +183,7 @@ class ConstFetchAnalyzer
}
if (!$stmt->name instanceof PhpParser\Node\Identifier) {
return null;
return;
}
$const_id = $fq_class_name . '::' . $stmt->name;
@ -248,7 +248,7 @@ class ConstFetchAnalyzer
}
}
return false;
return;
}
if ($context->calling_method_id) {
@ -352,7 +352,7 @@ class ConstFetchAnalyzer
if ($stmt->class instanceof PhpParser\Node\Expr) {
if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->class, $context) === false) {
return false;
return;
}
}

View File

@ -515,43 +515,68 @@ class AnnotationTest extends TestCase
],
'megaClosureAnnotationWithSpacing' => [
'<?php
/** @var array{
a: Closure() : (array<mixed, mixed>|null),
b?: Closure() : array<mixed, mixed>,
c?: Closure() : array<mixed, mixed>,
d?: Closure() : array<mixed, mixed>,
e?: Closure() : (array{
f: null|string,
g: null|string,
h: null|string,
i: string,
j: mixed,
k: mixed,
l: mixed,
m: mixed,
n: bool,
o?: array{0:string}
}|null),
p?: Closure() : (array{
f: null|string,
g: null|string,
h: null|string,
q: string,
i: string,
j: mixed,
k: mixed,
l: mixed,
m: mixed,
n: bool,
o?: array{0:string}
}|null),
r?: Closure() : (array<mixed, mixed>|null),
s: array<mixed, mixed>
} */
/**
* @var array{
* a: Closure() : (array<mixed, mixed>|null),
* b?: Closure() : array<mixed, mixed>,
* c?: Closure() : array<mixed, mixed>,
* d?: Closure() : array<mixed, mixed>,
* e?: Closure() : (array{
* f: null|string,
* g: null|string,
* h: null|string,
* i: string,
* j: mixed,
* k: mixed,
* l: mixed,
* m: mixed,
* n: bool,
* o?: array{0:string}
* }|null),
* p?: Closure() : (array{
* f: null|string,
* g: null|string,
* h: null|string,
* q: string,
* i: string,
* j: mixed,
* k: mixed,
* l: mixed,
* m: mixed,
* n: bool,
* o?: array{0:string}
* }|null),
* r?: Closure() : (array<mixed, mixed>|null),
* s: array<mixed, mixed>
* }
*
* Some text
*/
$arr = [];
$arr["a"]();',
],
'multipeLineGenericArray' => [
'<?php
/**
* @psalm-type MiddlewareArray = array<
* class-string<\Exception>,
* array<int, string>
* >
*
* @psalm-type RuleArray = array{
* rule: string,
* controller?: class-string<\Exception>,
* redirect?: string,
* code?: int,
* type?: string,
* middleware?: MiddlewareArray
* }
*
* Foo Bar
*/
class A {}',
],
'slashAfter?' => [
'<?php
namespace ns;