Menu

← Back to possiblyImpure.*

Error Identifier: possiblyImpure.betweenPhpTags

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
	{
		?>Some HTML output<?php
		return strtoupper($value);
	}
}

Why is it reported? #

The function or method is marked as @phpstan-pure but contains inline HTML between PHP closing (?>) and opening (<?php) tags. Outputting HTML to the browser is a side effect – it changes the state of the output buffer. Pure functions must not have side effects; they should only compute and return a value based on their inputs.

How to fix it #

Remove the inline HTML output from the pure function, or remove the @phpstan-pure annotation if the function genuinely needs to produce output:

 class Formatter
 {
 	/**
-	 * @phpstan-pure
+	 * @phpstan-impure
 	 */
 	public function format(string $value): string
 	{
 		?>Some HTML output<?php
 		return strtoupper($value);
 	}
 }
 

How to ignore this error #

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

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

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.