Menu

← Back to callable.*

Error Identifier: callable.void

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

/** @var callable(): void $callback */
$callback = static function (): void {};

$result = $callback();

Why is it reported? #

The result of calling a callable that returns void is being used. A void return type indicates that the function or callable does not return a meaningful value. Using the result of such a call is a logic error because the value is always null and the function author has explicitly declared no value should be expected.

In the example above, $callback is typed as callable(): void, so assigning $callback() to $result is using a void return value.

How to fix it #

Do not use the return value of a void callable. Call it as a standalone statement instead:

 <?php declare(strict_types = 1);
 
 /** @var callable(): void $callback */
 $callback = static function (): void {};

-$result = $callback();
+$callback();

If you need the callable to return a value, change its type signature to reflect the actual return type.

How to ignore this error #

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

// @phpstan-ignore callable.void
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.void

Rules that report this error #

  • PHPStan\Rules\Classes\ClassAttributesRule [1]
  • PHPStan\Rules\Classes\ClassConstantAttributesRule [1]
  • PHPStan\Rules\Classes\InstantiationRule [1]
  • PHPStan\Rules\Constants\ConstantAttributesRule [1]
  • PHPStan\Rules\EnumCases\EnumCaseAttributesRule [1]
  • PHPStan\Rules\Functions\ArrowFunctionAttributesRule [1]
  • PHPStan\Rules\Functions\CallCallablesRule [1]
  • PHPStan\Rules\Functions\CallToFunctionParametersRule [1]
  • PHPStan\Rules\Functions\CallUserFuncRule [1]
  • PHPStan\Rules\Functions\ClosureAttributesRule [1]
  • PHPStan\Rules\Functions\FunctionAttributesRule [1]
  • PHPStan\Rules\Functions\ParamAttributesRule [1]
  • PHPStan\Rules\Methods\CallMethodsRule [1]
  • PHPStan\Rules\Methods\CallStaticMethodsRule [1]
  • PHPStan\Rules\Methods\MethodAttributesRule [1]
  • PHPStan\Rules\Properties\PropertyAttributesRule [1]
  • PHPStan\Rules\Properties\PropertyHookAttributesRule [1]
  • PHPStan\Rules\Traits\TraitAttributesRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.