Top "Type-hinting" questions

Type hinting binds function arguments to specific objects or strongly types them.

How can I catch a "catchable fatal error" on PHP type hinting?

I am trying to implement Type Hinting of PHP5 on one of my class, class ClassA { public function method_a (…

php fatal-error type-hinting
Type hinting for properties in PHP 7?

Does php 7 support type hinting for class properties? I mean, not just for setters/getters but for the property itself. …

php attributes php-7 type-hinting variable-types
Is it possible to specify multiple return types on PHP 7?

I have some methods that can return one of two return types. I'm using a framework utilizing MCV so refactoring …

php php-7 type-hinting
What are variable annotations in Python 3.6?

Python 3.6 is about to be released. PEP 494 -- Python 3.6 Release Schedule mentions the end of December, so I went through …

python python-3.x annotations type-hinting python-3.6
How should I use the Optional type hint?

I'm trying to understand how to use the Optional type hint. From PEP-484, I know I can use Optional for …

python python-3.x type-hinting
How can I specify the function type in my type hints?

I want to use type hints in my current Python 3.5 project. My function should receive a function as parameter. How …

python python-3.x python-3.5 type-hinting mypy
How to specify "nullable" return type with type hints

Suppose I have a function: def get_some_date(some_argument: int=None) -> %datetime_or_None%: if some_…

python python-3.x python-3.5 type-hinting
How to annotate types of multiple return values?

How do I use type hints to annotate a function that returns an Iterable that always yields two values: a …

python python-3.x python-3.5 type-hinting
PHP 7 interfaces, return type hinting and self

UPDATE: PHP 7.4 now does support covariance and contravariance which addresses the major issue raised in this question. I have run …

php interface return-type php-7 type-hinting
Type hints with user defined classes

Couldn't seem to find a definitive answer. I want to do a type hint for a function and the type …

python python-3.x types type-hinting user-defined-types