Quick Answer
PHP has no native generics. Tools like PHPStan and Psalm support generic type annotations in docblocks using template tags. This gives type safety at static analysis time without runtime overhead. Libraries like doctrine/collections use these annotations. PHPStan level 8+ enforces generic constraints. Actual runtime generics require a future PHP RFC to be accepted.
Answer
PHP lacks runtime generics, but tools like Psalm and PHPStan add generic annotations for type-safe collections.
S
SugharaIQ Editorial Team
Verified Answer
This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.
PHP interview questions and answers for beginner, junior, mid-level, senior, and expert developers. Ideal for freshers and experienced candidates preparing for PHP roles.