Menu

Error Identifier: function.duplicate

← Back to function.*

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 #

This error is reported when the same function name is declared in multiple files within the analysed codebase:

// file1.php
<?php declare(strict_types = 1);

namespace App;

function helper(): void
{
}
// file2.php
<?php declare(strict_types = 1);

namespace App;

function helper(): void
{
}

Why is it reported? #

The same function name is declared multiple times within the registered stub files.

How to fix it #

Remove the duplicate function declaration, keeping only one:

 <?php declare(strict_types = 1);
 
 // file2.php
 namespace App;

-function helper(): void
-{
-}

If both declarations are intentionally different, rename one of them:

 <?php declare(strict_types = 1);
 
 // file2.php
 namespace App;

-function helper(): void
+function helperAlternative(): void
 {
 }

How to ignore this error #

You can use the identifier function.duplicate to ignore this error using a comment:

// @phpstan-ignore function.duplicate
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: function.duplicate

Rules that report this error #

  • PHPStan\Rules\Functions\DuplicateFunctionDeclarationRule [1]
Theme
A
© 2026 PHPStan s.r.o.