Menu

← Back to postDec.*

Error Identifier: postDec.nonNumeric

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 stdClass $object */
$object--;

Why is it reported? #

The post-decrement operator ($x--) is intended for numeric types. Using it on a non-numeric value such as an object, array, or non-numeric string produces unexpected results or a runtime error.

This rule is part of phpstan-strict-rules.

How to fix it #

Ensure the operand is a numeric type:

-$value--;
+$numericValue--;

If the value might be non-numeric, convert it first:

-$value--;
+$value = ((int) $value) - 1;

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\Operators\OperandInArithmeticIncrementOrDecrementRule [1] phpstan/phpstan-strict-rules

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.