Last active
May 25, 2022 10:02
-
-
Save mmoreram/d0965b4994a69f134036b265a260ec9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class X { | |
private int $a = 0; | |
public function incr() { | |
$this->a++; | |
} | |
public function a() { | |
return $this->a; | |
} | |
} | |
class A { | |
private readonly X $x; | |
public function __construct(X $x) { | |
$this->x = $x; | |
} | |
public function b() { | |
$this->x->incr(); | |
return $this->x->a(); | |
} | |
} | |
$a = new A(new X()); | |
var_dump($a->b()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The result is
1