Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 334 Bytes

NonInvariantPropertyType.md

File metadata and controls

20 lines (13 loc) · 334 Bytes

NonInvariantPropertyType

Emitted when a public or protected class property has a different type to the matching property in the parent class.

<?php

class A {
    public string $foo = 'hello';
}

class B extends A {
    public ?string $foo;
}

Why this is bad

For typed properties, this can cause a compile error.