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.
25 lines
458 B
Plaintext
25 lines
458 B
Plaintext
class Dog {
|
|
public string $name;
|
|
public string $color;
|
|
|
|
public void __construct(string $name, string $color) {
|
|
$this->name = $name;
|
|
$this->color = $color;
|
|
}
|
|
|
|
public callback greet(string $greeting) {
|
|
return void() using ($greeting) {
|
|
print("$greeting, I am a {$this->color} dog named {$this->name}\n");
|
|
};
|
|
}
|
|
}
|
|
|
|
class Program {
|
|
|
|
public void main() {
|
|
object $dog = new Dog('Alex', 'red');
|
|
callback $c = $dog->greet('Hello');
|
|
$c();
|
|
}
|
|
}
|