Add ?: operator

Details

Description

Add the ?: operator. Expand it in the parser to $a ?: $b; => $a ? $a : $b; Unfortunately, it is not as easy as that. If $a is a function and not a variable, then the function would be called twice.I removed the jump_in label because this has more impacts and will need more than one hour.

Steps are more or less

Write a corresponding integration test:

Add the corresponding code to the ch.tsphp.parser.test.integration.testutils.ExpressionHelper

Make the necessary modifications in the grammar file TSPHP.g:

you have to add the corresponding token

Include the operator in the expression rules (right where you can find the ternary operator '?')

add a corresponding integration test in the type checker

Should also be an ExpressionHelper

Make the necessary modifications in the TSPHPReferenceWalker.g

you have to add the operator

You need to modify TSPHPTypecheckWalker.g

in order that ?: is type checked as well

Add the necessary check to TSPHPTypecheckPhaseController

Add a corresponding test to the translator

Modify the grammar file of the translator

Add the operator, expand it to: $a ?: $b => $tmp = $a; $tmp ? $tmp : $b; – this way we make sure the behaviour is consistent among PHP versions other than 5.4 (5.4 makes the same mistake as my first thought, see above).