Menu

Error Identifier: conditionalType.subjectNotFound

← Back to conditionalType.*

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

/**
 * @return (int is string ? true : false)
 */
function doFoo(): bool
{
	return true;
}

Why is it reported? #

A conditional return type uses a subject type (int) that does not reference any @template tag or function parameter. The subject of a conditional return type must be either a template type declared via @template or a parameter reference using the $param is Type syntax.

In the example above, int is a bare type name that is not declared as a template type, so PHPStan cannot evaluate the condition.

How to fix it #

If the condition depends on a parameter, use the $param is Type syntax:

 <?php declare(strict_types = 1);
 
 /**
+ * @param string|int $value
- * @return (int is string ? true : false)
+ * @return ($value is string ? true : false)
  */
-function doFoo(): bool
+function doFoo($value): bool
 {
-	return true;
+	return is_string($value);
 }

If you intend to use a template type as the subject, declare it with @template:

 <?php declare(strict_types = 1);
 
 /**
+ * @template T
- * @return (int is string ? true : false)
+ * @param T $value
+ * @return (T is string ? true : false)
  */
-function doFoo(): bool
+function doFoo($value): bool
 {
-	return true;
+	return is_string($value);
 }

How to ignore this error #

You can use the identifier conditionalType.subjectNotFound to ignore this error using a comment:

// @phpstan-ignore conditionalType.subjectNotFound
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: conditionalType.subjectNotFound

Rules that report this error #

  • PHPStan\Rules\PhpDoc\FunctionConditionalReturnTypeRule [1]
  • PHPStan\Rules\PhpDoc\MethodConditionalReturnTypeRule [1]
Theme
A
© 2026 PHPStan s.r.o.