Details

    • Type: New Feature
    • Status: Wait for approval
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 0.5.3
    • Fix Version/s: 0.5.7
    • Component/s: parser
    • Labels:
      None

      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

      1. Write a corresponding integration test:
        1. Add the corresponding code to the ch.tsphp.parser.test.integration.testutils.ExpressionHelper
      2. Make the necessary modifications in the grammar file TSPHP.g:
        1. you have to add the corresponding token
        2. Include the operator in the expression rules (right where you can find the ternary operator '?')
      3. add a corresponding integration test in the type checker
        1. Should also be an ExpressionHelper
      4. Make the necessary modifications in the TSPHPReferenceWalker.g
        1. you have to add the operator
      5. You need to modify TSPHPTypecheckWalker.g
        1. in order that ?: is type checked as well
      6. Add the necessary check to TSPHPTypecheckPhaseController
      7. Add a corresponding test to the translator
      8. Modify the grammar file of the translator
        1. 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).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tutteli Admin
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Remaining Estimate - 1 day
                  1d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified