Menu

← Back to possiblyImpure.*

Error Identifier: possiblyImpure.require

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

/** @phpstan-pure */
function loadConfig(): array
{
	require 'config.php';
	return $config;
}

Why is it reported? #

A function marked as @phpstan-pure contains a require or require_once statement. Including files can have side effects (such as defining functions, classes, or executing code), which makes the operation possibly impure.

How to fix it #

Remove the require from the pure function:

 <?php declare(strict_types = 1);
 
-/** @phpstan-pure */
 function loadConfig(): array
 {
 	require 'config.php';
 	return $config;
 }

How to ignore this error #

You can use the identifier possiblyImpure.require to ignore this error using a comment:

// @phpstan-ignore possiblyImpure.require
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: possiblyImpure.require

Rules that report this error #

  • PHPStan\Rules\Pure\PureFunctionRule [1]
  • PHPStan\Rules\Pure\PureMethodRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.