Menu

← Back to parameter.*

Error Identifier: parameter.unionTypeNotSupported

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

function doFoo(int|string $value): void // ERROR: This function uses native union types but they're supported only on PHP 8.0 and later.
{
}

Why is it reported? #

Native union type syntax (int|string) for parameters was introduced in PHP 8.0. When PHPStan is configured to analyse code for a PHP version earlier than 8.0 (via the phpVersion configuration parameter), using native union types in parameter declarations is a syntax error. The code will not run on the targeted PHP version.

How to fix it #

If the code needs to run on PHP versions before 8.0, use PHPDoc to document the union type instead of the native syntax:

 <?php declare(strict_types = 1);
 
-function doFoo(int|string $value): void
+/**
+ * @param int|string $value
+ */
+function doFoo($value): void
 {
 }

Or update the phpVersion configuration in phpstan.neon if the project targets PHP 8.0 or later:

parameters:
    phpVersion: 80000

Non-ignorable error #

This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.

Rules that report this error #

  • PHPStan\Rules\Functions\ExistingClassesInArrowFunctionTypehintsRule [1] [2]
  • PHPStan\Rules\Functions\ExistingClassesInClosureTypehintsRule [1] [2]
  • PHPStan\Rules\Functions\ExistingClassesInTypehintsRule [1] [2]
  • PHPStan\Rules\Methods\ExistingClassesInTypehintsRule [1] [2]
  • PHPStan\Rules\Properties\ExistingClassesInPropertyHookTypehintsRule [1] [2]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.