3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php namespace App\ServerArbiter; use App\ServerArbiter\Rules\Rule; /** * Class RuleSet * * @package App\ServerArbiter */ class RuleSet implements \Iterator { /** * @var Rule[] An array of Rule objects */ private $rules; /** * @var int Iterator position key */ private $position = 0; /** * @constructor */ public function __construct() { $this->position = 0; } /** * Add a Rule to the RuleSet * * @param Rule $rule */ public function addRule(Rule $rule) { if (!in_array($rule, $this->rules)) { $this->rules[] = $rule; } } /** * Remove a Rule from the RuleSet by it's key * * @param int $ruleKey The numeric key within the rules array to unset * * @throws \OutOfBoundsException When a non-existant key is provided * @throws \InvalidArgumentException When a non-integer parameter is provided */ public function removeRule($ruleKey) { if (is_int($ruleKey)) { if (array_key_exists($ruleKey, $this->rules)) { unset($this->rules[$ruleKey]); } else { throw new \OutOfBoundsException(sprintf( "%s was passed a out of bounds array key: %s does not exist in this ruleset", __METHOD__, $ruleKey )); } } else { throw new \InvalidArgumentException(sprintf( "%s expected an integer ruleKey parameter, got: '%s' instead", __METHOD__, $ruleKey )); } } /** * {@inheritdoc} * * @return Rule */ public function current() { return $this->rules[$this->position]; } /** * {@inheritdoc} */ public function next() { ++$this->position; } /** * {@inheritdoc} */ public function key() { return $this->position; } /** * {@inheritdoc} */ public function valid() { return isset($this->rules[$this->position]); } /** * {@inheritdoc} */ public function rewind() { $this->position = 0; } }
Output for 5.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/VnDHR on line 3
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/VnDHR on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/VnDHR on line 3
Process exited with code 255.