Menu

← Back to parameter.*

Error Identifier: parameter.notByRef

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

interface Processor
{
	public function process(string &$value): void;
}

class MyProcessor implements Processor
{
	public function process(string $value): void
	{
	}
}

Why is it reported? #

A child class or implementation declares a parameter as not passed by reference, but the parent method or interface declares the corresponding parameter as passed by reference. This is a violation of the Liskov Substitution Principle.

This can also be reported when a @param-out PHPDoc tag is used on a parameter that is not passed by reference.

How to fix it #

Match the parent’s parameter passing convention:

 <?php declare(strict_types = 1);
 
 class MyProcessor implements Processor
 {
-	public function process(string $value): void
+	public function process(string &$value): void
 	{
 	}
 }

How to ignore this error #

You can use the identifier parameter.notByRef to ignore this error using a comment:

// @phpstan-ignore parameter.notByRef
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: parameter.notByRef

Rules that report this error #

  • PHPStan\Rules\Methods\ConsistentConstructorRule [1]
  • PHPStan\Rules\Methods\OverridingMethodRule [1]
  • PHPStan\Rules\PhpDoc\IncompatiblePhpDocTypeRule [1]
  • PHPStan\Rules\PhpDoc\IncompatiblePropertyHookPhpDocTypeRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.