Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass static class name to ReturnTypeAnalyzer #7366

Merged
merged 1 commit into from Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Psalm/Internal/Analyzer/ClassAnalyzer.php
Expand Up @@ -1942,6 +1942,7 @@ public static function analyzeClassMethodReturnType(
$method_analyzer,
$interface_return_type,
$interface_class,
$original_fq_classlike_name,
$interface_return_type_location,
[$analyzed_method_id->__toString()],
$did_explicitly_return
Expand Down Expand Up @@ -1969,6 +1970,7 @@ function ($method_id) {
$method_analyzer,
$return_type,
$fq_classlike_name,
$original_fq_classlike_name,
$return_type_location,
$overridden_method_ids,
$did_explicitly_return
Expand Down
Expand Up @@ -80,6 +80,7 @@ public static function verifyReturnType(
FunctionLikeAnalyzer $function_like_analyzer,
?Union $return_type = null,
?string $fq_class_name = null,
?string $static_fq_class_name = null,
?CodeLocation $return_type_location = null,
array $compatible_method_ids = [],
bool $did_explicitly_return = false,
Expand Down Expand Up @@ -425,7 +426,7 @@ static function (Union $union_type): bool {
$codebase,
$return_type,
$self_fq_class_name,
$self_fq_class_name,
$static_fq_class_name,
$parent_class,
true,
true,
Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
Expand Up @@ -1420,6 +1420,7 @@ public function verifyReturnType(
$this,
$return_type,
$fq_class_name,
$fq_class_name,
$return_type_location,
[],
$did_explicitly_return,
Expand Down
21 changes: 21 additions & 0 deletions tests/ReturnTypeTest.php
Expand Up @@ -247,6 +247,27 @@ class B extends A {
'$bees' => 'array<int, B>',
],
],
'extendsStaticConstReturnType' => [
'<?php
class A {
/** @var int */
private const FOO = 1;

/** @return static::FOO */
public function getFoo() {
return self::FOO;
}
}

class B extends A {
/** @var int */
private const FOO = 2;

public function getFoo() {
return self::FOO;
}
}',
],
'issetReturnType' => [
'<?php
/**
Expand Down