Do PHP interfaces have properties?

前端 未结 2 1156
死守一世寂寞
死守一世寂寞 2021-02-11 11:57

Do interfaces in PHP have properties, or do they only have methods?

2条回答
  •  悲哀的现实
    2021-02-11 12:38

    You can declare properties in DocBlock for the interface. IDE's will then hint those properties for the interface (PhpStorm does) but this will not force the actual implementation of these fields in the implementing class. E. g.

    /**
     * @property string $password
     * @property string $username
     */
    interface IUserDocument
    {
    
    
    }
    

提交回复
热议问题