belliash
55acf8111f
All checks were successful
The build was successful.
In most (all?) modern OOP languages class members visibility is assumed to be private and programmer has to consciously set it to public or protected. PHP has the different approach what can cause a security flaws in written scripts. AerScript will not follow this way, as it seems to be conceptually broken.
22 lines
513 B
Plaintext
22 lines
513 B
Plaintext
class Program {
|
|
private callback $condition = bool(int $x) { return ($x > 100); };
|
|
private int[] $numbers = {34, 56, 22, 1, 5, 67, 897, 123, 55, 101};
|
|
|
|
int[] filter(callback $condition, int[] $numbers) {
|
|
int $len = sizeof($numbers);
|
|
int[] $filtered;
|
|
for(int $i = 0; $i < $len; $i++) {
|
|
if($condition($numbers[$i])) {
|
|
$filtered[] = $numbers[$i];
|
|
}
|
|
}
|
|
return $filtered;
|
|
}
|
|
|
|
public void main() {
|
|
int[] $filtered = $this->filter($this->condition, $this->numbers);
|
|
var_dump($filtered);
|
|
}
|
|
|
|
}
|