<?php
/**
* Behaves like a PHP array (unstructured)
*/
class Bag {
private $_data;
public function __construct(array $data) {
$this->data = $data;
}
public function some(Closure $fn) {
return new Bag(array_reduce($this->_data, function ($carry, $x) {
return $fn($x) || $carry;
}, false));
}
public function every(Closure $fn) {
return new Bag(array_reduce($this->_data, function ($carry, $x) {
return $fn($x) && $carry;
}, true));
}
public function reduce(Closure $fn) {
return new Bag(array_reduce($this->_data, $fn));
}
public function map(Closure $fn) {
return new Bag(array_map($fn, $this->_data));
}
}
Parse error: syntax error, unexpected T_FUNCTION in /in/iEMtl on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/iEMtl on line 9
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/iEMtl on line 7
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/iEMtl on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/iEMtl on line 7
Process exited with code 255.