TSPHP introduces cast as a new modifier for types. One can write cast on the left side of the type of Fields, Variables or Function parameters (also method parameters) to indicate that assigned values or actual parameters will be cast to the desired type. The cast modifier turns explicit casts of the corresponding variable into implicit casts every time a value is assigned to the corresponding variable (see Type juggling for more information). However, the cast modifier will not include an automatic cast if an explicit cast from the source type to the target type is missing.
TSPHP supports casts over several types (this will most probably change - see - TSPHP-759Getting issue details... STATUS ). For instance, class A has an explicit cast to class B and class B has an explicit cast to class C. If one wants to cast the variable $a of type A to C, then one just needs to write (C)$a and not (C)(B)$a.
Please have a look at the following two examples which shows TSPHP code first and the corresponding output in PHP.