Menu

← Back to mul.*

Error Identifier: mul.rightNonNumeric

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 string $value */
$result = 5 * $value;

Why is it reported? #

This rule is part of phpstan-strict-rules.

The right operand of the multiplication operator (*) is not a numeric type. PHP will attempt to cast non-numeric values to numbers, which can lead to unexpected results or warnings. Strict rules require that only numeric types are used in arithmetic operations.

How to fix it #

Ensure the operand is a numeric type:

 <?php declare(strict_types = 1);
 
-/** @var string $value */
-$result = 5 * $value;
+/** @var int $value */
+$result = 5 * $value;

Or explicitly cast the value:

 <?php declare(strict_types = 1);
 
 /** @var string $value */
-$result = 5 * $value;
+$result = 5 * (int) $value;

How to ignore this error #

You can use the identifier mul.rightNonNumeric to ignore this error using a comment:

// @phpstan-ignore mul.rightNonNumeric
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: mul.rightNonNumeric

Rules that report this error #

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.