Is it possible to manipulate phantom types in Psalm using @param-out
for this
or self
? Example:
/**
* @template T
*/
class Foo
{
/**
* @param T $t
*/
public function __construct($t)
{
$this->t = $t;
}
/**
* WRONG:
* @param-out Test<S> $this
*/
public function test()
{
// Also this doesn't work:
$this->t = new S();
}
}
A use-case for this could be e.g. a file class with phantom type set to Open
or Closed
, and calling $file->open();
changes T
to Open
.
No. There's a pull request about it that might or might not be merged, using @param-self-out
.