website/errors/assert.unknownExpr.md
<?php declare(strict_types = 1);
class Foo
{
/**
* @phpstan-assert string $this->barProp
*/
public function doBar(mixed $a): bool
{
return is_string($a);
}
}
The @phpstan-assert PHPDoc tag references a property or expression that does not exist on the class. PHPStan cannot verify the assertion because the target expression cannot be resolved. In the example above, $this->barProp does not exist on the class Foo.
Reference an existing property or parameter in the assert tag:
<?php declare(strict_types = 1);
class Foo
{
+ public mixed $barProp;
+
/**
* @phpstan-assert string $this->barProp
*/
public function doBar(mixed $a): bool
{
return is_string($a);
}
}
Or fix the assert tag to reference the correct expression:
<?php declare(strict_types = 1);
class Foo
{
/**
- * @phpstan-assert string $this->barProp
+ * @phpstan-assert string $a
*/
public function doBar(mixed $a): bool
{
return is_string($a);
}
}