Jump to content

PHP Error Argument passed ,must be of the type array..


mdmeds

Recommended Posts

Hello everyone. Sorry for my bad English, i am from east Europe. So working on my site i have this error, evertything should work but i do not understand what is wrong. I am just learning php and working with code and script. Maybe someone have a solution for noob like me.

 

Error:

-[RECOVERABLE ERROR]-[2016.08.18 в (14:26:06)]{1}
    Message: Argument 5 passed to ShipType::__construct() must be of the type array, integer given, called in /calculateAttack.php on line 417 and defined
    File: /models/ShipType.php
    Line: 70
    URL: 
    Debug Backtrace:

The ShipType.php file:

public function __construct($id, $count, $rf, $shield, array $cost, $power, $weapons_tech = null, $shields_tech = null, $armour_tech = null)
    {
        parent::__construct($id, 0);

        $this->rf = $rf;
        $this->lastShots = 0;
        $this->lastShipHit = 0;
        $this->cost = $cost;

        $this->originalShield = $shield;
        $this->originalPower = $power;

        $this->singleShield = $shield;
        $this->singleLife = COST_TO_ARMOUR * array_sum($cost);
        $this->singlePower = $power;

        $this->increment($count);
        $this->setWeaponsTech($weapons_tech);
        $this->setArmourTech($armour_tech);
        $this->setShieldsTech($shields_tech);
    }

This is the line 70 in ShipType.php file. And the error is given by the array $cost!

public function __construct($id, $count, $rf, $shield, array $cost, $power, $weapons_tech = null, $shields_tech = null, $armour_tech = null)
    {

And the /calculateAttack.php line 417:

if ($id > ID_MIN_SHIPS && $id < ID_MAX_SHIPS)
    {
        return new Ship($id, $count, $rf, $shield, $restoreShields, $cost, $power, NULL, NULL, NULL, $rig, $skils);
    }
    return new Defense($id, $count, $rf, $shield, $restoreShields, $cost, $power, NULL, NULL, NULL, $rig, $skils);
}

And this is line 417 what give error.

return new Ship($id, $count, $rf, $shield, $restoreShields, $cost, $power, NULL, NULL, NULL, $rig, $skils);

Hope someone will help me figure this out.

Thanx!


 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...