-
Notifications
You must be signed in to change notification settings - Fork 651
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
Issue with template inheritance #5496
Labels
Comments
I found these snippets: https://psalm.dev/r/a9385e48ec<?php
/**
* @phpstan-template T of object
*/
interface AA {
/**
* @phpstan-return class-string<T>
*/
public function foo(): string;
}
/**
* @phpstan-template T of object
*/
class B
{
/**
* @var string
* @phpstan-var class-string<T>
*/
protected $classs;
/**
* @phpstan-param class-string<T> $class
*/
public function __construct(string $class)
{
$this->classs = $class;
}
}
/**
* @phpstan-template T of object
* @phpstan-extends B<T>
* @phpstan-implements AA<T>
*/
class A extends B implements AA {
public function foo(): string
{
return $this->classs;
}
}
https://psalm.dev/r/498a052aff<?php
/**
* @phpstan-template T of object
*/
interface AA {
/**
* @phpstan-return class-string<T>
*/
public function foo(): string;
}
/**
* @phpstan-template T of object
*/
class B
{
/**
* @var string
* @phpstan-var class-string<T>
*/
protected $classs;
/**
* @phpstan-param class-string<T> $class
*/
public function __construct(string $class)
{
$this->classs = $class;
}
}
/**
* @phpstan-template T of object
* @phpstan-extends B<T>
* @phpstan-implements AA<T>
*/
class A extends B implements AA {
/**
* @var string
* @phpstan-var class-string<T>
*/
protected $classs;
public function foo(): string
{
return $this->classs;
}
}
|
Simplified: https://psalm.dev/r/f32dc309ac |
I found these snippets: https://psalm.dev/r/f32dc309ac<?php
/** @template T of object */
abstract class B {
/** @var class-string<T> */
protected $classs;
/** @return class-string<T> */
abstract public function foo(): string;
}
/**
* @template T of object
* @extends B<T>
* @psalm-suppress MissingConstructor
*/
class A extends B {
public function foo(): string {
/** @psalm-trace $this->classs */;
return $this->classs;
}
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following code is valid with phpstan
https://phpstan.org/r/3475a9a3-539c-49d8-a476-77fb11b77d98
But not with psalm https://psalm.dev/r/a9385e48ec
Copy pasting the
$classs
property fix the issuehttps://psalm.dev/r/498a052aff
The text was updated successfully, but these errors were encountered: