php8-type-system
php8-type-system copied to clipboard
A comprehensive guide of everything related to PHP8.1+ type system and the tools used for static analysis
PHP 8 type system in-depth, and tools for static analysis
This repo contains what I hope is a decent description of all aspects of PHP 8.1+ type system, the community tools to help work with type declarations and PHPDocs as well as the static analysers that rely on the type system to find inconsistencies and bugs in your programs.
-
PHP type system in depth, a complete description of the type system, all type declarations and related topics like casting and dealing will
null
values- Typing systems
- Type declaration syntax
- Why use types ?
-
Built-in type declarations
- Scalar type declarations
- Compound type declarations
- Return-only type declarations
- Others
-
Objects
- type declarations
- Types in inheritance
- Classes as argument types
- Classes as method return types
- Enums
- Numeric strings
- Union and intersection types
- Getting type information from a variable
- Casting
- Comparing and juggling types
- Strict types
- Dealing with nulls
-
Tools for static analysis
-
PHPDocs
- Type related tags
-
Static analysers
- Custom PHPDoc types
- Generics
- PHPStan
-
Tools to helps with PHPDocs and type declarations
- PHP CS Fixer
- Rector
- Runtime assertions
-
PHPDocs
- References Various relevant links to the PHP manual, RFCs for all type related features over the years, and community links