Toots for timwolla@phpc.social account

Written by Tim Düsterhus on 2024-10-28 at 10:40

Really looking forward to be able to use property hooks with #php84.

use function array_pop as p;

final class Calculator {

private $s = [];

public float $v { get => end($this->s); set { $this->s[] = $value; } }

public null $add { get { $s = &$this->s; $s[] = p($s) + p($s); return null; } }

public null $mul { get { $s = &$this->s; $s[] = p($s) * p($s); return null; } }

}

$c = new Calculator();

$c->v = 2;

$c->v = 20;

$c->v = 2;

$c->mul;

$c->add;

var_dump($c->v);

[#]PHP

=> More informations about this toot | View the thread

Written by Tim Düsterhus on 2024-10-23 at 13:39

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

Written by Tim Düsterhus on 2024-10-15 at 13:48

Really looking forward to be able to write code like this with #php84:

if (!new Foo()->bar() instanceof Baz) {

echo "Didn't get a Baz\n";

}

=> More informations about this toot | View the thread

=> This profile with reblog | Go to timwolla@phpc.social account

Proxy Information
Original URL
gemini://mastogem.picasoft.net/profile/109344752835088683
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
269.638545 milliseconds
Gemini-to-HTML Time
1.788839 milliseconds

This content has been proxied by September (3851b).