Menu

← Back to method.*

Error Identifier: method.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);

class Formatter
{
	/** @phpstan-pure */
	public function format(string $value): string
	{
		return strtoupper($value);
	}
}

function doFoo(Formatter $formatter): void
{
	$formatter->format('hello'); // ERROR: Call to method Formatter::format() on a separate line has no effect.
}

Why is it reported? #

A method call appears as a standalone statement but the method has no side effects. The return value is not assigned, returned, or used in any way. Since the method is pure (or has no impure points), calling it without using its result has no observable effect and is likely a mistake.

PHPStan detects methods marked as @phpstan-pure, as well as methods that have no impure points (no writes to properties, no I/O, no calls to impure functions).

How to fix it #

Use the return value of the method call:

 <?php declare(strict_types = 1);
 
 function doFoo(Formatter $formatter): void
 {
-	$formatter->format('hello');
+	$result = $formatter->format('hello');
 }

Or if the method should have a side effect, update its implementation so PHPStan recognises it as impure:

 <?php declare(strict_types = 1);
 
 class Formatter
 {
-	/** @phpstan-pure */
-	public function format(string $value): string
+	/** @phpstan-impure */
+	public function format(string $value): string
 	{
+		echo strtoupper($value);
 		return strtoupper($value);
 	}
 }

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\DeadCode\CallToMethodStatementWithoutImpurePointsRule [1]
  • PHPStan\Rules\Methods\CallToMethodStatementWithoutSideEffectsRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.