lotgd / core

Core functionality for Legend of the Green Dragon, a text-based RPG game.
GNU Affero General Public License v3.0
152 stars 15 forks source link

TimeKeeper->isNewDay checks for null argument which is not allowed by type hint #93

Closed Vassyli closed 7 years ago

Vassyli commented 7 years ago
    public function isNewDay(DateTime $lastInteractionTime): bool
    {
        if ($lastInteractionTime == null) {
            return true;
        }
        $t1 = $this->gameTime();
        $t2 = $this->convertToGameTime($lastInteractionTime);
        $d1 = $t1->format("Y-m-d");
        $d2 = $t2->format("Y-m-d");
        return $d1 != $d2;
    }

$lastInteractionTime cannot be null, yet the function checks for this value. Suggested fix: Change DateTime to ?DateTime.