1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

cannot acess parent

Discussion in 'Plugin Help' started by GamakCZ, Jan 6, 2017.

  1. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    Hi, I need help with the construction plugin. To console me writes error:
    Code:
    Notice: Trying to get property of non-object in /home/gamakk/GS/plugins/SurvivalGames/src/SurvivalGames/Config/SGConfig.php on line 28
    [19:46:44] [Server thread/CRITICAL]: Error: "Cannot access parent:: when current class scope has no parent" (EXCEPTION) in "/SurvivalGames/src/SurvivalGames/Game/Arena/Arena" at line 29
    
    SG\src\SG\Game\Arena\Arena:
    PHP:
    /** @var SurvivalGames  */
    public $plugin;

    /** @var  SGConfig */
    public $config;

    /*29*/ public function __construct(SurvivalGames $plugin) {
    /*30*/    $this->plugin $plugin;
    /*31*/    $this->config $this->plugin->loader->config;
    /*32*/    parent::__construct($plugin);
    }
    SG\src\SG\Config\SGConfig:
    PHP:
    /*28*/public function __construct(Loader $loader) {
    /*29*/    parent::__construct($loader);
    /*30*/    $this->loader $loader;
    /*31*/    $this->arena $this->loader->main->arena;
    }
    Thank you in advance :).
     
  2. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    You don't need to call the parent constructor (parent::__construct()) unless the parent has a constructor or you want to use the full functionality of the parent class (you wouldn't call the parent constructor from an abstract class, you'd do it from a class extending it).
     
    Muqsit and applqpak like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.