Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Created August 1, 2020 10:11
Show Gist options
  • Save PJZ9n/58073321aedd15ef417f0fcce3dc49f9 to your computer and use it in GitHub Desktop.
Save PJZ9n/58073321aedd15ef417f0fcce3dc49f9 to your computer and use it in GitHub Desktop.
メインクラスに静的なメンバ変数としてConfigを持つ
<?php
declare(strict_types=1);
use pocketmine\utils\Config;
class aClass
{
private static $config;
public static function getConfig(): Config
{
return self::$config;
}
public function onEnable(): void
{
self::$config = new Config("path");
}
}
class bClass
{
public function __construct()
{
$config = aClass::getConfig();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment