Menu

Error Identifier: purePropertyHook.parameterPassedNotByRef

← Back to purePropertyHook.*

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

final class User
{
	public string $name {
		/**
		 * @pure-unless-parameter-passed $value
		 */
		set {
			$this->name = $value;
		}
	}
}

Why is it reported? #

The @pure-unless-parameter-passed tag marks a function as pure unless an argument is passed for the named parameter. It is meant for optional by-reference out-parameters: writing into the caller’s variable through such a parameter is the side effect that makes the call impure.

The $value parameter of a set property hook (PHP 8.4+) is passed by value — the hook only receives a copy of the assigned value and cannot write back into the caller’s variable. Passing it cannot produce a side effect on its own, so the tag has no meaning here. This mirrors pureMethod.parameterPassedNotByRef for regular methods.

The same tag also triggers purePropertyHook.nonOptionalParameterPassed, because $value is always passed.

How to fix it #

Remove the tag. Purity of a property hook can be declared with @phpstan-pure or @phpstan-impure instead:

 	public string $name {
-		/**
-		 * @pure-unless-parameter-passed $value
-		 */
 		set {
 			$this->name = $value;
 		}
 	}

How to ignore this error #

You can use the identifier purePropertyHook.parameterPassedNotByRef to ignore this error using a comment:

// @phpstan-ignore purePropertyHook.parameterPassedNotByRef
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: purePropertyHook.parameterPassedNotByRef

Rules that report this error #

  • PHPStan\Rules\Pure\PureFunctionRule [1]
  • PHPStan\Rules\Pure\PureMethodRule [1]
  • PHPStan\Rules\Pure\PurePropertyHookRule [1]
Theme
A
© 2026 PHPStan s.r.o.