vimeo/psalm

False positive PropertyNotSetInConstructor

オープン

#5,630 opened on 2021/04/14

 (21 件のコメント) (0 件のリアクション) (0 人の担当者)PHP (668 件のフォーク)batch import
Help wantedbugtraits

Repository metrics

Stars
 (5,369 個のスター)
PR merge metrics
 (PR metrics pending)

説明

<?php

trait CreatedAt {
    protected DateTimeImmutable $createdAt;

    private function onCreated(): void {
        $this->createdAt = new DateTimeImmutable();
    }
}

class Foo {
    use CreatedAt;

    public function __construct() {
    	$this->onCreated();
    }
}

class Bar extends Foo {}

Property $createdAt was initialized it Foo constructor. But psalm knows nothing about it in Bar.

https://psalm.dev/r/106a0483f7

コントリビューターガイド