vimeo/psalm

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

开放

#8,957 创建于 2022年12月20日

 (7 条评论) (0 个反应) (0 位负责人)PHP (668 个派生)batch import
Help wantedeasy problemsgood first issueinternal stubs/callmap

仓库指标

星标
 (5,369 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南