website/errors/generics.deprecatedClassDefault.md
<?php declare(strict_types = 1);
/** @deprecated Use NewFormatter instead */
class OldFormatter
{
}
/**
* @template T = OldFormatter
*/
class Pipeline
{
}
This error is reported by the phpstan-deprecation-rules extension.
A @template tag uses a deprecated class as its default type value. The @template T = DefaultClass syntax specifies a default type for a generic parameter, but when DefaultClass is deprecated, the generic class creates a dependency on a class planned for removal. Any usage of Pipeline without an explicit type argument would implicitly use the deprecated OldFormatter.
In the example above, the template parameter T defaults to OldFormatter, which is marked as @deprecated.
Replace the deprecated default type with the recommended replacement:
<?php declare(strict_types = 1);
/**
- * @template T = OldFormatter
+ * @template T = NewFormatter
*/
class Pipeline
{
}
Alternatively, remove the default if there is no suitable non-deprecated replacement:
<?php declare(strict_types = 1);
/**
- * @template T = OldFormatter
+ * @template T
*/
class Pipeline
{
}