Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Last active June 7, 2020 15:20
Show Gist options
  • Save PJZ9n/3205092c8dcb6a3ef503f3528154551c to your computer and use it in GitHub Desktop.
Save PJZ9n/3205092c8dcb6a3ef503f3528154551c to your computer and use it in GitHub Desktop.
<?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!
}
}
<?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!
}
}
<?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