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

__construct "Too few arguments"

Discussion in 'Development' started by Levi, Oct 13, 2017.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    error:

    Code:
    [13:31:19] [Server thread/CRITICAL]: ArgumentCountError: "Too few arguments to function mines\commands\Mines::__construct(), 1 passed in /home/pe/plugins/mines/src/mines/Main.php on line 81 and exactly 2 expected" (EXCEPTION) in "plugins/mines/src/mines/commands/Mines" at line 21
    code
    PHP:
     public function __construct(Main $mainPlayer $player){
            
    parent::__construct("mines""List of mines"null,[]);
            
    $this->main $main;
            
    $this->player $player;
        }
     
  2. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    fyi, it dont give me error when i remove Player. But the error say "too few arguments", it'll be even more too few if i remove Player $player
     
  3. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    You're constructing a new Mines command object with only your main class, while your constructor requires two arguments.
     
  4. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    how can i get the player on __construct then
     
  5. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    Once again you are posting a few lines of code and hoping people here are going to do the extra work needed to figure out the context... if you provide the full code on github or in code blocks here, you will get more help.
     
    Ayush and jasonwynn10 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.