Menu

← Back to callable.*

Error Identifier: callable.shadowTemplate

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

/**
 * @template T
 */
class Collection
{
	/**
	 * @param callable<T>(T): T $callback
	 */
	public function map(callable $callback): void
	{
	}
}

Why is it reported? #

A generic callable type in a PHPDoc tag defines a template type parameter with the same name as an existing template on the enclosing function or class. In the example above, both the class and the map method define a template named T, which creates ambiguity about which T is being referred to inside the callable type.

How to fix it #

Rename the template type parameter in the callable to avoid shadowing:

 <?php declare(strict_types = 1);
 
 /**
  * @template T
  */
 class Collection
 {
 	/**
-	 * @param callable<T>(T): T $callback
+	 * @param callable<U>(U): U $callback
 	 */
 	public function map(callable $callback): void
 	{
 	}
 }

How to ignore this error #

You can use the identifier callable.shadowTemplate to ignore this error using a comment:

// @phpstan-ignore callable.shadowTemplate
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: callable.shadowTemplate

Rules that report this error #

  • PHPStan\Rules\PhpDoc\IncompatiblePhpDocTypeRule [1] [2]
  • PHPStan\Rules\PhpDoc\IncompatiblePropertyHookPhpDocTypeRule [1] [2]
  • PHPStan\Rules\PhpDoc\IncompatiblePropertyPhpDocTypeRule [1] [2]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.