vimeo/psalm

MethodSignatureMismatch - Argument 1 of DateTime::__unserialize has wrong type 'mixed', expecting 'array<array-key, mixed>' as defined by DateTimeInterface::__unserialize

Open

#8 957 ouverte le 20 déc. 2022

Voir sur GitHub
 (7 commentaires) (0 réactions) (0 assignés)PHP (668 forks)batch import
Help wantedeasy problemsgood first issueinternal stubs/callmap

Métriques du dépôt

Stars
 (5 369 stars)
Métriques de merge PR
 (Merge moyen 3j 12h) (5 PRs mergées en 30 j)

Description

Running on PHP 8.2, I have this code:

I cannot reproduce it on psalm.dev, but I assume it has to do with stubs.

<?php

declare(strict_types=1);

namespace App\Extension\Type;

use DateTime as PHPGlobalDateTime;

class DateTime extends PHPGlobalDateTime
{
    public function __toString(): string
    {
        return $this->format('U');
    }
}

Getting:

ERROR: MethodSignatureMismatch - src/Extension/Type/DateTime.php:10:7 - Argument 1 of DateTime::__unserialize has wrong type 'mixed', expecting 'array<array-key, mixed>' as defined by DateTimeInterface::__unserialize (see https://psalm.dev/042) class DateTime extends PHPGlobalDateTime implements StringableDateTimeInterface

Guide contributeur