Last active
June 7, 2020 15:20
-
-
Save PJZ9n/3205092c8dcb6a3ef503f3528154551c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| declare(strict_types=1); | |
| class a | |
| { | |
| /** @var string */ | |
| private static $foo; | |
| public static function getFoo(): string | |
| { | |
| return self::$foo; | |
| } | |
| public function __construct() | |
| { | |
| self::$foo = "hoge!"; | |
| } | |
| } | |
| class b | |
| { | |
| public function __construct() | |
| { | |
| echo a::getFoo() . PHP_EOL;//hoge! | |
| } | |
| } |
This file contains hidden or 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 | |
| declare(strict_types=1); | |
| class a | |
| { | |
| public function hoge(): void | |
| { | |
| $foo = "fuga!"; | |
| new b($foo); | |
| } | |
| } | |
| class b | |
| { | |
| public function __construct(string $foo) | |
| { | |
| echo $foo . PHP_EOL;//fuga! | |
| } | |
| } |
This file contains hidden or 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 | |
| declare(strict_types=1); | |
| class DataManager | |
| { | |
| public static $foo; | |
| } | |
| class EventListener | |
| { | |
| public function __construct() | |
| { | |
| DataManager::$foo = "piyo"; | |
| } | |
| } | |
| class FooCommand | |
| { | |
| public function __construct() | |
| { | |
| DataManager::$foo = "aaaaa"; | |
| } | |
| public function command(): void | |
| { | |
| echo DataManager::$foo; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment