paquettg / leaguewrap

League of Legend API wrapper
MIT License
67 stars 28 forks source link

Masteries Tree Bug #34

Closed leandrosandmann closed 10 years ago

leandrosandmann commented 10 years ago

When i try to get MasteriesTree i receive this message:

A PHP Error was encountered Severity: 4096 Message: Argument 1 passed to LeagueWrap\Dto\AbstractDto::__construct() must be of the type array, null given, called in paquettg\leaguewrap\src\LeagueWrap\Dto\StaticData\MasteryTreeList.php on line 17 and defined Filename: Dto/AbstractDto.php Line Number: 13

Tastefull commented 10 years ago

My hotfix for this is done by replacing line 17 with this code

if (is_array($masteryTreeItem)) {
       $masteryTreeItemDto    = new MasteryTreeItem($masteryTreeItem);
} else {
       $masteryTreeItemDto    = new MasteryTreeItem(array("prereq" => "0", "masteryId" => 0));
}

The reason this error comes is because some of the values is in the tree can be null and the "MasteryTreeItem" can't. So what this does is creating a item with "prereg" "0" and "masteryid" 0. So when you run through it in your code, you should check for masteryid is 0 and this would mean a mastery item spacer

X X X X X n X X X X X X X X n X

The null only happends if there are data/items after it,

Kind regards \T

paquettg commented 10 years ago

Ah, that makes perfect sense. I'll add that hotfix in unless you want to create a pull request. If you want to i'll pull that in instead as you are the one who came up with the solution :)

Tastefull commented 10 years ago

You just go ahead and make the fix :)