Skip to content

Commit

Permalink
Fix self parsing for psalm-if-this-is and psalm-self-out
Browse files Browse the repository at this point in the history
  • Loading branch information
klimick committed Jan 16, 2022
1 parent de824d6 commit 10012c9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ function (FunctionLikeParameter $p): bool {
$docblock_info->self_out['type'],
$aliases,
$function_template_types + $class_template_types,
$type_aliases
$type_aliases,
$classlike_storage ? $classlike_storage->name : null
),
null,
$function_template_types + $class_template_types,
Expand All @@ -319,7 +320,8 @@ function (FunctionLikeParameter $p): bool {
$docblock_info->if_this_is['type'],
$aliases,
$function_template_types + $class_template_types,
$type_aliases
$type_aliases,
$classlike_storage ? $classlike_storage->name : null
),
null,
$function_template_types + $class_template_types,
Expand Down
22 changes: 22 additions & 0 deletions tests/IfThisIsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,28 @@ class F extends G
$f->test();
'
],
'ifThisIsWithSelfAlias' => [
'<?php
/**
* @template T of string
*/
final class App
{
/**
* @psalm-if-this-is self<"idle">
* @psalm-this-out self<"started">
*/
public function start(): void
{
throw new RuntimeException("???");
}
}
/** @var App<"idle"> */
$app = new App();
$app->start();
'
],
'ifThisIsAndThisOutAtTheSameTime' => [
'<?php
/**
Expand Down

0 comments on commit 10012c9

Please sign in to comment.