Really looking forward to be able to use property hooks with #php84:
final class Calculator
{
public Closure $add { get => static fn (int|float $a, int|float $b) => $a + $b; }
public Closure $subtract { get => static fn (int|float $a, int|float $b) => $a - $b; }
public Closure $multiply { get => static fn (int|float $a, int|float $b) => $a * $b; }
}
$myCalculator = new Calculator();
var_dump(($myCalculator->add)(40, 2));
var_dump(($myCalculator->multiply)(21, 2));
[#]PHP
=> More informations about this toot | View the thread | More toots from timwolla@phpc.social
=> View php84 tag | View php tag This content has been proxied by September (3851b).Proxy Information
text/gemini