Skip to content

Assert::isAOf() requires class-string input in v2.x, breaking validation use case #341

@Orest-Divintari

Description

@Orest-Divintari

In version 2.0.0, the @param annotation for isAOf() was changed from object|string to ExpectedType|class-string<ExpectedType>, breaking the ability to validate uncertain strings.

Example use case:

public function doSomething(string $type) : object
{
    Assert::isAOf($type, SomeClass::class); // PHPStan error in v2.x
}

The problem:
When you receive a plain string from an external source, you need to validate that it's both a valid class name AND implements/extends the expected class. PHPStan now rejects this because string
doesn't match class-string<ExpectedType>.

Suggested fix:
Revert @param to object|string 
/**
 * @param object|string $value
 */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions