zendframework / zend-diactoros

PSR-7 HTTP Message implementation
BSD 3-Clause "New" or "Revised" License
1.55k stars 152 forks source link

Declare strict_types and use STH/RTH #329

Closed weierophinney closed 6 years ago

weierophinney commented 6 years ago

Adds RTH and scalar type hints wherever possible. However, in many cases, because we are implementing interfaces, we cannot provide parameter type hints without conflicting with the interface; return type hints are allowed, though, due to PHP's contravariant return type rules.

Constructors always add parameter types, however, which eliminates the need for many unit tests, as well as type checks within the constructors.

A number of additional code changes were made due to enabling strict types. In some cases, we were returning values that we should not have been based on the return signature. In other cases, we were not casting values before passing them to functions or methods, and should have.