run code in 200+ php & hhvm versions
Bugs & Features
<?php $message = "<p>This is more tricky than it may sound.</p> <p>The problem is that when a unit is unspawned it is immediately deleted. After that we can't report any events about the unit to the script because the unit no longer exists and we don't want to pass references to dead objects to the script.</p> <p>So when the physics system some time after the unspawn detects that the object has left the trigger we have no way of notifying the script about that.</p> <p>There are some potential ways of solving this problem:</p> <ul> <li>We could delay deleting the unit for a "couple of frames" until we have had time to report events about it to the script. However, this would create a new strange state for units to be in, an <em>(about-to-be-deleted)</em> state. This will severely increase code complexity and confusion since there would be a ton of places where you would have to check if you were dealing with a "real" unit or an "about-to-be-deleted" unit, both in the script and in the engine. Horrible.</li> <li>We could add a new event for the triggers <em>Destroyed</em>. The event would be triggered whenever something inside the trigger was destroyed. The event would not pass the unit (because the unit would be destroyed by the time it was triggered). In this way, you could react to the <em>Destroyed</em> message and act appropriately (e.g., scan your list of units inside the trigger for any deleted units). This still wouldn't give you the Enter/Leave symmetry that you perhaps want... instead you would get Enter/Destroy. And you wouldn't be able to tell which unit was destroyed.</li> <li>We could try to keep track of which units are inside which triggers (outside the physics system), so that when you called <em>unspawn()</em> we could immediately generate <em>Leave</em> events for the triggers, before destroying the unit. This would give you a <em>Leave</em> event with a working unit variable. However, tracking all of this would have a performance cost. Also, we still wouldn't have a perfectly symmetric solution, because this <em>Leave</em> event would be triggered immediately when <em>unspawn()</em> was called, unlike other trigger events that are triggered when we do a physics update.</li> </ul> <p>None of these solutions seem really good to me. I'm not so found of implementing a bad solution, because once we have implemented something we have to keep supporting it or break backwards compatibility, which means that if we pick a bad solution we could be stuck with it for a long time.</p>"; $message = preg_replace("/<\/p>((.|\n)+?)(?=<\/p>)/", "\n$1", $message);
Output for 5.4.0 - 5.4.32
Parse error: syntax error, unexpected 'couple' (T_STRING) in /in/gTkME on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/gTkME on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/gTkME on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/gTkME on line 7
Process exited with code 255.