Menu

← Back to expr.*

Error Identifier: expr.resultUnused

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

function doFoo(stdClass $obj): void
{
	$obj->name;
}

Why is it reported? #

An expression is written on a separate line but its result is never used. The expression is evaluated and immediately discarded, which means the statement has no effect. This typically indicates a bug – a missing assignment, a forgotten function call, or dead code.

How to fix it #

If the expression was meant to be assigned, add the assignment:

 function doFoo(stdClass $obj): void
 {
-	$obj->name;
+	$name = $obj->name;
 }

If a method call was intended, add the missing parentheses or call:

 function doFoo(stdClass $obj): void
 {
-	$obj->name;
+	$obj->getName();
 }

If the expression is truly unnecessary, remove it:

 function doFoo(stdClass $obj): void
 {
-	$obj->name;
 }

How to ignore this error #

You can use the identifier expr.resultUnused to ignore this error using a comment:

// @phpstan-ignore expr.resultUnused
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: expr.resultUnused

Rules that report this error #

  • PHPStan\Rules\DeadCode\NoopRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.