Menu

← Back to callable.*

Error Identifier: callable.notSupported

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);

class Foo
{
	public function doFoo(): void
	{
		$callable = $this->doFoo(...);
	}
}

Why is it reported? #

First-class callable syntax (foo(...)) was introduced in PHP 8.1. When PHPStan is configured to analyse code for a PHP version earlier than 8.1, using this syntax is not valid and will cause a syntax error at runtime.

This error is also reported when trying to create a callable from the new operator (e.g., new Foo(...)), which is not supported in any PHP version.

How to fix it #

Use a Closure::fromCallable() call or a closure wrapper instead of the first-class callable syntax:

 <?php declare(strict_types = 1);
 
 class Foo
 {
 	public function doFoo(): void
 	{
-		$callable = $this->doFoo(...);
+		$callable = Closure::fromCallable([$this, 'doFoo']);
 	}
 }

Or configure PHPStan to analyse the code for PHP 8.1 or later by setting the phpVersion option in the configuration file.

Non-ignorable error #

This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.

Rules that report this error #

  • PHPStan\Rules\Classes\InstantiationCallableRule [1]
  • PHPStan\Rules\Functions\FunctionCallableRule [1]
  • PHPStan\Rules\Methods\MethodCallableRule [1]
  • PHPStan\Rules\Methods\StaticMethodCallableRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.