Menu

← Back to postDec.*

Error Identifier: postDec.type

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

$arr = [];
$arr--;

Why is it reported? #

The post-decrement operator ($x--) cannot be used on certain types. For example, arrays, objects (other than SimpleXMLElement), and resources do not support decrement. On PHP 8.3+, decrementing non-numeric strings, null, and bool is also deprecated.

How to fix it #

Ensure the variable is of a type that supports the decrement operator:

-$arr = [];
-$arr--;
+$count = 10;
+$count--;

For non-numeric strings on PHP 8.3+, use str_decrement() instead:

-$str = 'b';
-$str--;
+$str = str_decrement('b');

How to ignore this error #

You can use the identifier postDec.type to ignore this error using a comment:

// @phpstan-ignore postDec.type
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: postDec.type

Rules that report this error #

  • PHPStan\Rules\Operators\InvalidIncDecOperationRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.